diff --git a/src/common/user-store/user-store.ts b/src/common/user-store/user-store.ts index b72c8f6859..a948def9d8 100644 --- a/src/common/user-store/user-store.ts +++ b/src/common/user-store/user-store.ts @@ -169,11 +169,9 @@ export class UserStore extends BaseStore /* implements UserStore const curVal = this[key]; const newVal = fromStore((preferences)?.[key] as never) as never; - if ( - isObservableArray(curVal) - || isObservableSet(curVal) - || isObservableMap(curVal) - ) { + if (isObservableArray(curVal)) { + curVal.replace(newVal); + } else if (isObservableSet(curVal) || isObservableMap(curVal)) { curVal.replace(newVal); } else { this[key] = newVal; diff --git a/src/common/utils/tuple.ts b/src/common/utils/tuple.ts index 17586dda33..019dafcffc 100644 --- a/src/common/utils/tuple.ts +++ b/src/common/utils/tuple.ts @@ -42,3 +42,10 @@ export function* zip(...sources: Tuple): Iterator(length: L, value: T): Tuple { return array.filled(length, value) as Tuple; } + +/** + * A function for converting an explicit array to a tuple but without the `readonly` typing + */ +export function from(...args: T): [...T] { + return args; +} diff --git a/src/renderer/components/+preferences/kubeconfig-syncs.tsx b/src/renderer/components/+preferences/kubeconfig-syncs.tsx index b153d8fe28..de6b926824 100644 --- a/src/renderer/components/+preferences/kubeconfig-syncs.tsx +++ b/src/renderer/components/+preferences/kubeconfig-syncs.tsx @@ -11,7 +11,7 @@ import { Notice } from "../+extensions/notice"; import { KubeconfigSyncEntry, KubeconfigSyncValue, UserStore } from "../../../common/user-store"; import { isWindows } from "../../../common/vars"; import logger from "../../../main/logger"; -import { iter } from "../../utils"; +import { iter, tuple } from "../../utils"; import { SubTitle } from "../layout/sub-title"; import { PathPicker } from "../path-picker/path-picker"; import { Spinner } from "../spinner"; @@ -79,9 +79,12 @@ export class KubeconfigSyncs extends React.Component { this.loaded = true; disposeOnUnmount(this, [ - reaction(() => Array.from(this.syncs.entries(), ([filePath, { data }]) => [filePath, data]), syncs => { - UserStore.getInstance().syncKubeconfigEntries.replace(syncs); - }), + reaction( + () => Array.from(this.syncs.entries(), ([filePath, { data }]) => tuple.from(filePath, data)), + syncs => { + UserStore.getInstance().syncKubeconfigEntries.replace(syncs); + }, + ), ]); }