Skip to content

Commit

Permalink
Report errors in the ui
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelklehr committed Oct 11, 2017
1 parent 2ffeadc commit 47c34a1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/entries/background-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ browser.alarms.onAlarm.addListener(alarm => {
var accounts = d['accounts']
for (var accountId in accounts) {
syncAccount(accountId)
.catch(err => console.warn(err))
}
})
})
Expand Down Expand Up @@ -63,14 +62,14 @@ window.syncAccount = function(accountId) {
return Promise.resolve()
}
syncing[accountId] = true
Account.get(accountId)
return Account.get(accountId)
.then((account) => {
return account.sync()
})
.then(() => {delete syncing[accountId]})
.catch((er) => {
.catch((error) => {
delete syncing[accountId]
console.error(er)
console.error(error)
})
.then(() => next[accountId] && next[accountId]())
}
3 changes: 3 additions & 0 deletions src/lib/Account.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,8 @@ export default class Account {
.then(() => {
this.setData({...this.getData(), syncing: false})
})
.catch((err) => {
return this.setData({...this.getData(), error: err.message, syncing: false})
})
}
}
Binary file added src/lib/adapters/.Nextcloud.js.swo
Binary file not shown.
15 changes: 14 additions & 1 deletion src/lib/adapters/Nextcloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,20 @@ export default class NextcloudAdapter {
<td><label for="password">Password:</label></td>
<td><input value={new InputInitializeHook(data.password)} type="password" className="password" name="password" ev-keydown={onchangePassword} ev-blur={onchangePassword}/></td></tr>
<tr><td></td><td>
<span className="status">{data.syncing === true? '↻ Syncing...' : ( data.valid == true? '✓ connected' : (data.valid == false? '✘ error' : '… checking'))}</span>
<span className="status">{
data.syncing === true?
'↻ Syncing...' :
(data.error?
<span title={data.error}>✘ Error!</span> :
(data.valid == true?
'✓ connected' :
(data.valid == false?
'✘ couldn\'t connect' :
'… checking'
)
)
)
}</span>
<a href="#" className="btn remove" ev-click={() => ctl.delete()}>Delete</a>
<a href="#" className={'btn forceSync '+(data.syncing || !data.valid? 'disabled' : '')} ev-click={() => (!data.syncing && data.valid) && ctl.sync()}>force Sync</a>
</td></tr>
Expand Down

0 comments on commit 47c34a1

Please sign in to comment.