1
0
forked from mirror/misskey
misskey/packages/frontend/src/scripts/embed-page.ts

38 lines
878 B
TypeScript
Raw Normal View History

/*
* 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);
}
});
}