mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-04 08:15:41 +00:00
fix: sync the setting that deletes junk mail for good between devices
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { beforeEach, describe, expect, it } from 'vitest';
|
||||
import { useSettingsStore } from '../settings-store';
|
||||
|
||||
// "Permanently delete junk" is a choice on the Message list page; it has to
|
||||
// reach the server copy like the rest, or another device (or a restore)
|
||||
// quietly goes back to moving junk to the trash.
|
||||
describe('settings-store permanentlyDeleteJunk sync', () => {
|
||||
beforeEach(() => {
|
||||
useSettingsStore.getState().resetToDefaults();
|
||||
});
|
||||
|
||||
it('is in the snapshot pushed to the server and in a file export', () => {
|
||||
useSettingsStore.getState().updateSetting('permanentlyDeleteJunk', true);
|
||||
expect(JSON.parse(useSettingsStore.getState().exportSettings({ forSync: true })).permanentlyDeleteJunk).toBe(true);
|
||||
expect(JSON.parse(useSettingsStore.getState().exportSettings()).permanentlyDeleteJunk).toBe(true);
|
||||
});
|
||||
|
||||
it('comes back from a synced copy', () => {
|
||||
useSettingsStore.getState().updateSetting('permanentlyDeleteJunk', true);
|
||||
const blob = useSettingsStore.getState().exportSettings({ forSync: true });
|
||||
useSettingsStore.getState().resetToDefaults();
|
||||
expect(useSettingsStore.getState().permanentlyDeleteJunk).toBe(false);
|
||||
expect(useSettingsStore.getState().importSettings(blob)).toBe(true);
|
||||
expect(useSettingsStore.getState().permanentlyDeleteJunk).toBe(true);
|
||||
});
|
||||
|
||||
it('ignores a value that is not a boolean', () => {
|
||||
expect(useSettingsStore.getState().importSettings(JSON.stringify({ permanentlyDeleteJunk: 'yes' }))).toBe(true);
|
||||
expect(useSettingsStore.getState().permanentlyDeleteJunk).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1334,6 +1334,7 @@ export const useSettingsStore = create<SettingsState>()(
|
||||
deleteAction: state.deleteAction,
|
||||
returnToListAfterAction: state.returnToListAfterAction,
|
||||
confirmBulkDelete: state.confirmBulkDelete,
|
||||
permanentlyDeleteJunk: state.permanentlyDeleteJunk,
|
||||
clearSearchOnFolderChange: state.clearSearchOnFolderChange,
|
||||
searchDefaultScope: state.searchDefaultScope,
|
||||
showPreview: state.showPreview,
|
||||
@@ -1635,6 +1636,10 @@ export const useSettingsStore = create<SettingsState>()(
|
||||
if (key === 'searchDefaultScope' && !isSearchDefaultScope(settings[key])) {
|
||||
return;
|
||||
}
|
||||
// Anything but a real true must not turn on deleting junk for good.
|
||||
if (key === 'permanentlyDeleteJunk' && typeof settings[key] !== 'boolean') {
|
||||
return;
|
||||
}
|
||||
if (DEVICE_LOCAL_SETTING_KEYS.has(key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user