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');
// 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 iAmAdmin = $i != null && $i.isAdmin;
@ -178,19 +178,11 @@ export function updateAccount(accountData: Account) {
export function updateAccountPartial(accountData: Partial<Account>) {
if (!$i) return;
if (accountData === null) {
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));
}
}
export async function refreshAccount() {
if (!$i) return;