refactor(frontend): os.tsに引き込んだscripts/api.tsの再exportをやめる (#12694)

* refactor(frontend): os.tsに引き込んだscripts/api.tsの再exportをやめる

* fix

* fix

* renate to "misskeyApi"

* rename file
This commit is contained in:
おさむのひと
2024-01-04 18:32:46 +09:00
committed by GitHub
parent ea41cc6ec0
commit fa9c4a19b9
191 changed files with 581 additions and 468 deletions

View File

@@ -5,7 +5,7 @@
import { Theme, getBuiltinThemes } from '@/scripts/theme.js';
import { miLocalStorage } from '@/local-storage.js';
import { api } from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { $i } from '@/account.js';
const lsCacheKey = $i ? `themes:${$i.id}` as const : null;
@@ -19,7 +19,7 @@ export async function fetchThemes(): Promise<void> {
if ($i == null) return;
try {
const themes = await api('i/registry/get', { scope: ['client'], key: 'themes' });
const themes = await misskeyApi('i/registry/get', { scope: ['client'], key: 'themes' });
miLocalStorage.setItem(lsCacheKey!, JSON.stringify(themes));
} catch (err) {
if (err.code === 'NO_SUCH_KEY') return;
@@ -35,13 +35,13 @@ export async function addTheme(theme: Theme): Promise<void> {
}
await fetchThemes();
const themes = getThemes().concat(theme);
await api('i/registry/set', { scope: ['client'], key: 'themes', value: themes });
await misskeyApi('i/registry/set', { scope: ['client'], key: 'themes', value: themes });
miLocalStorage.setItem(lsCacheKey!, JSON.stringify(themes));
}
export async function removeTheme(theme: Theme): Promise<void> {
if ($i == null) return;
const themes = getThemes().filter(t => t.id !== theme.id);
await api('i/registry/set', { scope: ['client'], key: 'themes', value: themes });
await misskeyApi('i/registry/set', { scope: ['client'], key: 'themes', value: themes });
miLocalStorage.setItem(lsCacheKey!, JSON.stringify(themes));
}