summaryrefslogtreecommitdiff
path: root/packages/client/src
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-07-06 07:08:45 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2022-07-06 07:08:45 +0900
commitefafc31c9b52b0a306736fdacd2298e1ae8b5fa0 (patch)
treef492eef0efadd50f2f5e0c9000ff0fb6ab0c5cd6 /packages/client/src
parentrevert: feat: styled error screen (#8930) (diff)
downloadmisskey-efafc31c9b52b0a306736fdacd2298e1ae8b5fa0.tar.gz
misskey-efafc31c9b52b0a306736fdacd2298e1ae8b5fa0.tar.bz2
misskey-efafc31c9b52b0a306736fdacd2298e1ae8b5fa0.zip
fix(client): テーマを作成するとクライアントが起動しなくなる
Diffstat (limited to 'packages/client/src')
-rw-r--r--packages/client/src/pages/settings/theme.vue10
-rw-r--r--packages/client/src/pages/theme-editor.vue2
-rw-r--r--packages/client/src/store.ts8
3 files changed, 17 insertions, 3 deletions
diff --git a/packages/client/src/pages/settings/theme.vue b/packages/client/src/pages/settings/theme.vue
index 1bdad3e75a..d330e1ba25 100644
--- a/packages/client/src/pages/settings/theme.vue
+++ b/packages/client/src/pages/settings/theme.vue
@@ -97,7 +97,10 @@ const darkThemeId = computed({
return darkTheme.value.id;
},
set(id) {
- ColdDeviceStorage.set('darkTheme', themes.value.find(x => x.id === id));
+ const t = themes.value.find(x => x.id === id);
+ if (t) { // テーマエディタでテーマを作成したときなどは、themesに反映されないため undefined になる
+ ColdDeviceStorage.set('darkTheme', t);
+ }
},
});
const lightTheme = ColdDeviceStorage.ref('lightTheme');
@@ -106,7 +109,10 @@ const lightThemeId = computed({
return lightTheme.value.id;
},
set(id) {
- ColdDeviceStorage.set('lightTheme', themes.value.find(x => x.id === id));
+ const t = themes.value.find(x => x.id === id);
+ if (t) { // テーマエディタでテーマを作成したときなどは、themesに反映されないため undefined になる
+ ColdDeviceStorage.set('lightTheme', t);
+ }
},
});
const darkMode = computed(defaultStore.makeGetterSetter('darkMode'));
diff --git a/packages/client/src/pages/theme-editor.vue b/packages/client/src/pages/theme-editor.vue
index 44b5a05f27..548e60614b 100644
--- a/packages/client/src/pages/theme-editor.vue
+++ b/packages/client/src/pages/theme-editor.vue
@@ -192,7 +192,7 @@ async function saveAs() {
theme.name = name;
theme.author = `@${$i.username}@${toUnicode(host)}`;
if (description) theme.desc = description;
- addTheme(theme);
+ await addTheme(theme);
applyTheme(theme);
if (defaultStore.state.darkMode) {
ColdDeviceStorage.set('darkTheme', theme);
diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts
index d87e05a4de..5033333313 100644
--- a/packages/client/src/store.ts
+++ b/packages/client/src/store.ts
@@ -304,6 +304,14 @@ export class ColdDeviceStorage {
}
public static set<T extends keyof typeof ColdDeviceStorage.default>(key: T, value: typeof ColdDeviceStorage.default[T]): void {
+ // 呼び出し側のバグ等で undefined が来ることがある
+ // undefined を文字列として localStorage に入れると参照する際の JSON.parse でコケて不具合の元になるため無視
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+ if (value === undefined) {
+ console.error(`attempt to store undefined value for key '${key}'`);
+ return;
+ }
+
localStorage.setItem(PREFIX + key, JSON.stringify(value));
for (const watcher of this.watchers) {