fix: add account data update permission + handle async saveAccountData

This commit is contained in:
doubleface 2019-07-23 15:11:01 +02:00
부모 f61ecb8ce2
커밋 36ae448cb2
2개의 변경된 파일3개의 추가작업 그리고 6개의 파일을 삭제

파일 보기

@ -46,10 +46,7 @@
"type": "io.cozy.files"
},
"accounts": {
"type": "io.cozy.accounts",
"verbs": [
"GET"
]
"type": "io.cozy.accounts"
}
},
"developer": {

파일 보기

@ -165,7 +165,7 @@ async function getList(params, urlPart, subItem, splitPart) {
/* Function that retrieve all new declaration not sync before */
async function getAllDeclaration(params, declarationList) {
let accData = this.getAccountData()
let exist = Object.keys(accData).length > 0
let exist = Object.keys(accData).includes('lastSaved')
let bills = []
let lastPeriod = declarationList.length - 1
if (exist) {
@ -177,7 +177,7 @@ async function getAllDeclaration(params, declarationList) {
const bill = await getDeclaration(params, declarationList[i])
bills.push(bill)
accData.lastSaved = declarationList[i]
this.saveAccountData(accData, { merge: false })
await this.saveAccountData(accData, { merge: false })
} catch (error) {
log('error', error)
break