This commit is contained in:
kakkokari-gtyih 2024-11-27 11:18:04 +09:00
parent edd9a94ea8
commit fa56d6ea57

View file

@ -22,7 +22,7 @@ type Account = Misskey.entities.MeDetailed & { token: string };
const accountData = miLocalStorage.getItem('account'); const accountData = miLocalStorage.getItem('account');
// TODO: 外部からはreadonlyに // TODO: 外部からはreadonlyに
export let $i = accountData ? reactive(JSON.parse(accountData) as Account) : null; export const $i = accountData ? reactive(JSON.parse(accountData) as Account) : null;
export const iAmModerator = $i != null && ($i.isAdmin === true || $i.isModerator === true); export const iAmModerator = $i != null && ($i.isAdmin === true || $i.isModerator === true);
export const iAmAdmin = $i != null && $i.isAdmin; export const iAmAdmin = $i != null && $i.isAdmin;
@ -178,18 +178,10 @@ export function updateAccount(accountData: Account) {
export function updateAccountPartial(accountData: Partial<Account>) { export function updateAccountPartial(accountData: Partial<Account>) {
if (!$i) return; if (!$i) return;
for (const [key, value] of Object.entries(accountData)) {
if (accountData === null) { $i[key] = value;
void fetchAccount($i.token).then((accountData) => {
$i = accountData;
miLocalStorage.setItem('account', JSON.stringify($i));
});
} else {
for (const [key, value] of Object.entries(accountData)) {
$i[key] = value;
}
miLocalStorage.setItem('account', JSON.stringify($i));
} }
miLocalStorage.setItem('account', JSON.stringify($i));
} }
export async function refreshAccount() { export async function refreshAccount() {