Add sync reset key bridge
This commit is contained in:
@@ -104,10 +104,12 @@ test.describe('D: Plugin API bridge', () => {
|
||||
await api.sync.setInterval(15);
|
||||
const configured = await api.sync.status();
|
||||
const syncNow = await api.sync.now();
|
||||
await api.sync.resetKey();
|
||||
const reset = await api.sync.status();
|
||||
await api.sync.disconnect();
|
||||
const disconnected = await api.sync.status();
|
||||
api.dispose();
|
||||
return { initial, configured, syncNow, disconnected };
|
||||
return { initial, configured, syncNow, reset, disconnected };
|
||||
});
|
||||
|
||||
expect(result.initial.statusLabel).toBe('disabled');
|
||||
@@ -115,6 +117,10 @@ test.describe('D: Plugin API bridge', () => {
|
||||
expect(result.configured.serverUrl).toBe('https://sync.example.test');
|
||||
expect(result.configured.syncInterval).toBe(15);
|
||||
expect(result.syncNow).toEqual({ pushed: 0, pulled: 0, serverSequence: 0 });
|
||||
expect(result.reset.configured).toBe(false);
|
||||
expect(result.reset.serverUrl).toBe('https://sync.example.test');
|
||||
expect(result.reset.tokenStored).toBe(false);
|
||||
expect(result.reset.statusLabel).toBe('disconnected');
|
||||
expect(result.disconnected.configured).toBe(false);
|
||||
expect(result.disconnected.statusLabel).toBe('disabled');
|
||||
});
|
||||
|
||||
@@ -311,6 +311,12 @@ export function createPluginAPI(pluginId) {
|
||||
return App.PluginSyncSetInterval(pluginId, Number(minutes) || 0);
|
||||
});
|
||||
},
|
||||
resetKey: function() {
|
||||
assertActive('sync.resetKey');
|
||||
return callBackendErrorString(pluginId, 'sync.resetKey', function() {
|
||||
return App.PluginSyncResetKey(pluginId);
|
||||
});
|
||||
},
|
||||
now: function() {
|
||||
assertActive('sync.now');
|
||||
return callBackend(pluginId, 'sync.now', function() {
|
||||
|
||||
@@ -1116,6 +1116,22 @@
|
||||
syncState.syncInterval = Number(minutes) || 0;
|
||||
return Promise.resolve('');
|
||||
},
|
||||
PluginSyncResetKey: function (pluginId) {
|
||||
var err = requirePluginSyncPermission(pluginId, false);
|
||||
if (err) return Promise.resolve(err);
|
||||
syncState.configured = false;
|
||||
syncState.deviceId = '';
|
||||
syncState.deviceName = '';
|
||||
syncState.connected = false;
|
||||
syncState.revoked = false;
|
||||
syncState.tokenStored = false;
|
||||
syncState.lastError = '';
|
||||
syncState.statusLabel = 'disconnected';
|
||||
pluginSettings[pluginId] = Object.assign({}, pluginSettings[pluginId] || {}, {
|
||||
syncStatus: syncState.statusLabel
|
||||
});
|
||||
return Promise.resolve('');
|
||||
},
|
||||
PluginSyncNow: function (pluginId) {
|
||||
var err = requirePluginSyncPermission(pluginId, true);
|
||||
if (err) return Promise.resolve([{}, err]);
|
||||
|
||||
Vendored
+2
@@ -84,6 +84,8 @@ export function PluginSyncDisconnect(arg1:string):Promise<string>;
|
||||
|
||||
export function PluginSyncNow(arg1:string):Promise<Record<string, any>|string>;
|
||||
|
||||
export function PluginSyncResetKey(arg1:string):Promise<string>;
|
||||
|
||||
export function PluginSyncSetInterval(arg1:string,arg2:number):Promise<string>;
|
||||
|
||||
export function PluginSyncStatus(arg1:string):Promise<api.SyncStatusDTO|string>;
|
||||
|
||||
@@ -154,6 +154,10 @@ export function PluginSyncNow(arg1) {
|
||||
return window['go']['api']['App']['PluginSyncNow'](arg1);
|
||||
}
|
||||
|
||||
export function PluginSyncResetKey(arg1) {
|
||||
return window['go']['api']['App']['PluginSyncResetKey'](arg1);
|
||||
}
|
||||
|
||||
export function PluginSyncSetInterval(arg1, arg2) {
|
||||
return window['go']['api']['App']['PluginSyncSetInterval'](arg1, arg2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user