Reset mlSearchEnabled on first login

This commit is contained in:
Shailesh Pandit 2022-01-31 13:50:56 +05:30
parent 69cdf5179f
commit 55b896ab81
3 changed files with 13 additions and 7 deletions

View file

@ -565,7 +565,7 @@ export default function App({ Component, err }) {
mlWorkManager.setMlSearchEnabled(mlSearchConfig.enabled);
eventBus.emit(Events.APP_START);
} catch (e) {
logError(e, 'Error in appStart handlers');
logError(e, 'Error while loading mlSearchEnabled');
}
};
@ -627,11 +627,15 @@ export default function App({ Component, err }) {
setTimeout(() => setFlashMessage(null), 5000);
};
const updateMlSearchEnabled = async (enabled: boolean) => {
const mlSearchConfig = await getMLSearchConfig();
mlSearchConfig.enabled = enabled;
await updateMLSearchConfig(mlSearchConfig);
setMlSearchEnabled(enabled);
mlWorkManager.setMlSearchEnabled(enabled);
try {
const mlSearchConfig = await getMLSearchConfig();
mlSearchConfig.enabled = enabled;
await updateMLSearchConfig(mlSearchConfig);
setMlSearchEnabled(enabled);
mlWorkManager.setMlSearchEnabled(enabled);
} catch (e) {
logError(e, 'Error while updating mlSearchEnabled');
}
};
// ho ja yaar
return (

View file

@ -73,6 +73,8 @@ export default function Credentials() {
keyAttributes,
key
);
// TODO: not required after reseting appContext on first login
appContext.updateMlSearchEnabled(false);
}
await SaveKeyInSessionStore(SESSION_KEYS.ENCRYPTION_KEY, key);
await decryptAndStoreToken(key);

View file

@ -242,7 +242,7 @@ class MLWorkManager {
public stopSyncJob(terminateWorker: boolean = true) {
try {
console.log('MLWorkManager.stopSyncJob');
this.mlSyncJob.stop();
this.mlSyncJob?.stop();
terminateWorker && this.terminateSyncJobWorker();
} catch (e) {
logError(e, 'Failed to stop MLSync Job');