Remove redudant applySettingFB
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
import firebase from "firebase"
|
||||
import { currentUser$ } from "./auth"
|
||||
import {
|
||||
applySettingFB,
|
||||
settingsStore,
|
||||
SettingsType,
|
||||
} from "~/newstore/settings"
|
||||
import { applySetting, settingsStore, SettingsType } from "~/newstore/settings"
|
||||
|
||||
/**
|
||||
* Used locally to prevent infinite loop when settings sync update
|
||||
@@ -51,7 +47,7 @@ export function initSettings() {
|
||||
Object.keys(dispatch.payload).forEach((key) => {
|
||||
writeSettings(key, dispatch.payload[key])
|
||||
})
|
||||
} else if (dispatch.dispatcher !== "applySettingFB") {
|
||||
} else {
|
||||
writeSettings(
|
||||
dispatch.payload.settingKey,
|
||||
settingsStore.value[dispatch.payload.settingKey as keyof SettingsType]
|
||||
@@ -86,7 +82,7 @@ export function initSettings() {
|
||||
loadedSettings = false
|
||||
settings.forEach((e) => {
|
||||
if (e && e.name && e.value != null) {
|
||||
applySettingFB(e.name, e.value)
|
||||
applySetting(e.name, e.value)
|
||||
}
|
||||
})
|
||||
loadedSettings = true
|
||||
|
||||
@@ -64,22 +64,6 @@ const dispatchers = defineDispatchers({
|
||||
const result: Partial<SettingsType> = {}
|
||||
result[settingKey] = value
|
||||
|
||||
return result
|
||||
},
|
||||
applySettingFB<K extends keyof SettingsType>(
|
||||
_currentState: SettingsType,
|
||||
{ settingKey, value }: { settingKey: K; value: SettingsType[K] }
|
||||
) {
|
||||
if (!validKeys.includes(settingKey)) {
|
||||
console.log(
|
||||
`Ignoring non-existent setting key '${settingKey}' assignment by firebase`
|
||||
)
|
||||
return {}
|
||||
}
|
||||
|
||||
const result: Partial<SettingsType> = {}
|
||||
result[settingKey] = value
|
||||
|
||||
return result
|
||||
},
|
||||
})
|
||||
@@ -120,16 +104,3 @@ export function applySetting<K extends keyof SettingsType>(
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function applySettingFB<K extends keyof SettingsType>(
|
||||
settingKey: K,
|
||||
value: SettingsType[K]
|
||||
) {
|
||||
settingsStore.dispatch({
|
||||
dispatcher: "applySettingFB",
|
||||
payload: {
|
||||
settingKey,
|
||||
value,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user