enhance: embedページではstoreの保存先を完全に分離するように

This commit is contained in:
kakkokari-gtyih
2024-06-01 21:03:39 +09:00
parent ecf7945fe8
commit e9b3b5ffcd
13 changed files with 168 additions and 23 deletions

View File

@@ -0,0 +1,37 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { miLocalStorage } from "@/local-storage.js";
import type { Keys } from "@/local-storage.js";
export function isEmbedPage() {
return location.pathname.startsWith('/embed');
}
/**
* EmbedページではlocalStorageを使用できないようにしているが、
* 動作に必要な値はsafeSessionStoragemiLocalStorage内のやつに移動する
*/
export function initEmbedPageLocalStorage() {
if (!isEmbedPage()) {
return;
}
const keysToDuplicate: Keys[] = [
'v',
'lastVersion',
'instance',
'instanceCachedAt',
'lang',
'locale',
'localeVersion',
];
keysToDuplicate.forEach(key => {
const value = window.localStorage.getItem(key);
if (value && !miLocalStorage.getItem(key)) {
miLocalStorage.setItem(key, value);
}
});
}