diff --git a/package.json b/package.json index 34bcbd2c96..98372acec4 100644 --- a/package.json +++ b/package.json @@ -232,7 +232,7 @@ "mac-ca": "^1.0.6", "marked": "^4.0.12", "md5-file": "^5.0.0", - "mobx": "^6.3.7", + "mobx": "^6.5.0", "mobx-observable-history": "^2.0.3", "mobx-react": "^7.3.0", "mobx-utils": "^6.0.4", 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); + }, + ), ]); } diff --git a/yarn.lock b/yarn.lock index 88bcb07dad..774510d5cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9285,15 +9285,10 @@ mobx-utils@^6.0.4: resolved "https://registry.yarnpkg.com/mobx-utils/-/mobx-utils-6.0.4.tgz#5283a466ece8de0ac36ae3cfa1b1c032ec302b37" integrity sha512-CcTgFcCWN78eyRXU7OiKfhIVDEWFFoKdpfj49GIVcWykIQ4deXnaRnnKHElbVYFFgz1TOs8a3bDAq7qsSe864A== -mobx@^6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/mobx/-/mobx-6.3.0.tgz#a8fb693c3047bdfcb1eaff9aa48e36a7eb084f96" - integrity sha512-Aa1+VXsg4WxqJMTQfWoYuJi5UD10VZhiobSmcs5kcmI3BIT0aVtn7DysvCeDADCzl7dnbX+0BTHUj/v7gLlZpQ== - -mobx@^6.3.7: - version "6.3.7" - resolved "https://registry.yarnpkg.com/mobx/-/mobx-6.3.7.tgz#9ed85561e86da45141134c8fa20cf5f9c7246c3d" - integrity sha512-X7yU7eOEyxIBk4gjIi2UIilwdw48gXh0kcZ5ex3Rc+COJsJmJ4SNpf42uYea3aUqb1hedTv5xzJrq5Q55p0P5g== +mobx@^6.3.0, mobx@^6.5.0: + version "6.5.0" + resolved "https://registry.yarnpkg.com/mobx/-/mobx-6.5.0.tgz#dc2d028b1882737f6e813fc92454381e438b7ad3" + integrity sha512-pHZ/cySF00FVENDWIDzJyoObFahK6Eg4d0papqm6d7yMkxWTZ/S/csqJX1A3PsYy4t5k3z2QnlwuCfMW5lSEwA== mock-fs@^5.1.2: version "5.1.2"