mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-01 13:14:16 +08:00
Keep track of sync completion timestamps
This commit is contained in:
parent
ce61326f7c
commit
ddf73b6b02
3 changed files with 14 additions and 2 deletions
|
@ -49,8 +49,9 @@ const buildAccountWith = ({name, email, provider, settings, credentials}) => {
|
|||
name: name,
|
||||
provider: provider,
|
||||
emailAddress: email,
|
||||
syncPolicy: SyncPolicy.defaultPolicy(),
|
||||
connectionSettings: settings,
|
||||
syncPolicy: SyncPolicy.defaultPolicy(),
|
||||
lastSyncCompletions: [],
|
||||
})
|
||||
account.setCredentials(credentials);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const crypto = require('crypto');
|
||||
const {JSONType} = require('../../database-types');
|
||||
const {JSONType, JSONARRAYType} = require('../../database-types');
|
||||
|
||||
const {DB_ENCRYPTION_ALGORITHM, DB_ENCRYPTION_PASSWORD} = process.env;
|
||||
|
||||
|
@ -12,6 +12,7 @@ module.exports = (sequelize, Sequelize) => {
|
|||
connectionCredentials: Sequelize.STRING,
|
||||
syncPolicy: JSONType('syncPolicy'),
|
||||
syncError: JSONType('syncError', {defaultValue: null}),
|
||||
lastSyncCompletions: JSONARRAYType('lastSyncCompletions'),
|
||||
}, {
|
||||
classMethods: {
|
||||
associate: ({AccountToken}) => {
|
||||
|
@ -29,6 +30,7 @@ module.exports = (sequelize, Sequelize) => {
|
|||
connection_settings: this.connectionSettings,
|
||||
sync_policy: this.syncPolicy,
|
||||
sync_error: this.syncError,
|
||||
lastSyncCompletions: this.lastSyncCompletions,
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -176,6 +176,15 @@ class SyncWorker {
|
|||
onSyncDidComplete() {
|
||||
const {afterSync} = this._account.syncPolicy;
|
||||
|
||||
let lastSyncCompletions = [...this._account.lastSyncCompletions]
|
||||
lastSyncCompletions = [Date.now(), ...lastSyncCompletions]
|
||||
if (lastSyncCompletions.length > 10) {
|
||||
lastSyncCompletions.pop()
|
||||
}
|
||||
this._account.lastSyncCompletions = lastSyncCompletions
|
||||
this._account.save()
|
||||
console.log('Syncworker: Completed sync cycle')
|
||||
|
||||
if (afterSync === 'idle') {
|
||||
return this._getIdleFolder()
|
||||
.then((idleFolder) => this._conn.openBox(idleFolder.name))
|
||||
|
|
Loading…
Reference in a new issue