Merge pull request #164 from konnectors/fix/accountData

fix: add account data update permission + handle async saveAccountData
This commit is contained in:
Schoumi 2019-07-23 15:14:20 +02:00 committed by GitHub
commit 9f59097c07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View File

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

View File

@ -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