|
|
@ -1,8 +1,7 @@
|
|
|
|
import { isBoolean } from 'lodash';
|
|
|
|
import { isBoolean } from 'lodash';
|
|
|
|
|
|
|
|
|
|
|
|
import { PayloadAction, createSlice } from '@reduxjs/toolkit';
|
|
|
|
import { PayloadAction, createSlice } from '@reduxjs/toolkit';
|
|
|
|
import { SettingsKey } from '../../data/settings-key';
|
|
|
|
import { SettingsKey } from '../../data/settings-key'; // ok: does not import anything else
|
|
|
|
import { Storage } from '../../util/storage';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const SettingsBoolsKeyTrackedInRedux = [
|
|
|
|
const SettingsBoolsKeyTrackedInRedux = [
|
|
|
|
SettingsKey.someDeviceOutdatedSyncing,
|
|
|
|
SettingsKey.someDeviceOutdatedSyncing,
|
|
|
@ -44,33 +43,31 @@ const settingsSlice = createSlice({
|
|
|
|
// Once the storage is ready,
|
|
|
|
// Once the storage is ready,
|
|
|
|
initialState: getSettingsInitialState(),
|
|
|
|
initialState: getSettingsInitialState(),
|
|
|
|
reducers: {
|
|
|
|
reducers: {
|
|
|
|
updateAllOnStorageReady(state) {
|
|
|
|
updateAllOnStorageReady(
|
|
|
|
const linkPreview = Storage.get(SettingsKey.settingsLinkPreview, false);
|
|
|
|
state,
|
|
|
|
const outdatedSync = Storage.get(SettingsKey.someDeviceOutdatedSyncing, false);
|
|
|
|
{
|
|
|
|
const hasBlindedMsgRequestsEnabled = Storage.get(
|
|
|
|
payload,
|
|
|
|
SettingsKey.hasBlindedMsgRequestsEnabled,
|
|
|
|
}: PayloadAction<{
|
|
|
|
false
|
|
|
|
settingsLinkPreview: boolean;
|
|
|
|
);
|
|
|
|
someDeviceOutdatedSyncing: boolean;
|
|
|
|
const hasFollowSystemThemeEnabled = Storage.get(
|
|
|
|
hasBlindedMsgRequestsEnabled: boolean;
|
|
|
|
SettingsKey.hasFollowSystemThemeEnabled,
|
|
|
|
hasFollowSystemThemeEnabled: boolean;
|
|
|
|
false
|
|
|
|
hasShiftSendEnabled: boolean;
|
|
|
|
);
|
|
|
|
}>
|
|
|
|
const hasShiftSendEnabled = Storage.get(SettingsKey.hasShiftSendEnabled, false);
|
|
|
|
) {
|
|
|
|
state.settingsBools.someDeviceOutdatedSyncing = isBoolean(outdatedSync)
|
|
|
|
const {
|
|
|
|
? outdatedSync
|
|
|
|
hasBlindedMsgRequestsEnabled,
|
|
|
|
: false;
|
|
|
|
hasFollowSystemThemeEnabled,
|
|
|
|
state.settingsBools['link-preview-setting'] = isBoolean(linkPreview) ? linkPreview : false; // this is the value of SettingsKey.settingsLinkPreview
|
|
|
|
settingsLinkPreview,
|
|
|
|
state.settingsBools.hasBlindedMsgRequestsEnabled = isBoolean(hasBlindedMsgRequestsEnabled)
|
|
|
|
someDeviceOutdatedSyncing,
|
|
|
|
? hasBlindedMsgRequestsEnabled
|
|
|
|
hasShiftSendEnabled,
|
|
|
|
: false;
|
|
|
|
} = payload;
|
|
|
|
|
|
|
|
|
|
|
|
state.settingsBools.hasFollowSystemThemeEnabled = isBoolean(hasFollowSystemThemeEnabled)
|
|
|
|
|
|
|
|
? hasFollowSystemThemeEnabled
|
|
|
|
|
|
|
|
: false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
state.settingsBools.hasShiftSendEnabled = isBoolean(hasShiftSendEnabled)
|
|
|
|
state.settingsBools.someDeviceOutdatedSyncing = someDeviceOutdatedSyncing;
|
|
|
|
? hasShiftSendEnabled
|
|
|
|
state.settingsBools['link-preview-setting'] = settingsLinkPreview;
|
|
|
|
: false;
|
|
|
|
state.settingsBools.hasBlindedMsgRequestsEnabled = hasBlindedMsgRequestsEnabled;
|
|
|
|
|
|
|
|
state.settingsBools.hasFollowSystemThemeEnabled = hasFollowSystemThemeEnabled;
|
|
|
|
|
|
|
|
state.settingsBools.hasShiftSendEnabled = hasShiftSendEnabled;
|
|
|
|
|
|
|
|
|
|
|
|
return state;
|
|
|
|
return state;
|
|
|
|
},
|
|
|
|
},
|
|
|
|