mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-09 14:16:02 +08:00
[client-sync] Add error handling when creating syncback requests
Summary: see title. also convert to es6 Test Plan: manual Reviewers: evan, halla Reviewed By: halla Differential Revision: https://phab.nylas.com/D4225
This commit is contained in:
parent
eb64ae67d2
commit
6532d3c647
1 changed files with 10 additions and 6 deletions
|
@ -1,14 +1,15 @@
|
||||||
const _ = require('underscore')
|
import _ from 'underscore'
|
||||||
const Serialization = require('./serialization');
|
import Boom from 'boom';
|
||||||
const SyncProcessManager = require('../local-sync-worker/sync-process-manager')
|
import Serialization from './serialization';
|
||||||
|
import SyncProcessManager from '../local-sync-worker/sync-process-manager'
|
||||||
|
|
||||||
|
|
||||||
const wakeSyncWorker = _.debounce((accountId, reason) => {
|
const wakeSyncWorker = _.debounce((accountId, reason) => {
|
||||||
SyncProcessManager.wakeWorkerForAccount(accountId, {interrupt: true, reason})
|
SyncProcessManager.wakeWorkerForAccount(accountId, {interrupt: true, reason})
|
||||||
}, 500)
|
}, 500)
|
||||||
|
|
||||||
module.exports = {
|
export async function createAndReplyWithSyncbackRequest(request, reply, syncRequestArgs = {}) {
|
||||||
async createAndReplyWithSyncbackRequest(request, reply, syncRequestArgs = {}) {
|
try {
|
||||||
const account = request.auth.credentials
|
const account = request.auth.credentials
|
||||||
const {wakeSync = true} = syncRequestArgs
|
const {wakeSync = true} = syncRequestArgs
|
||||||
syncRequestArgs.accountId = account.id
|
syncRequestArgs.accountId = account.id
|
||||||
|
@ -21,5 +22,8 @@ module.exports = {
|
||||||
}
|
}
|
||||||
reply(Serialization.jsonStringify(syncbackRequest))
|
reply(Serialization.jsonStringify(syncbackRequest))
|
||||||
return syncbackRequest
|
return syncbackRequest
|
||||||
},
|
} catch (err) {
|
||||||
|
reply(Boom.wrap(err))
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue