basic support for Shared Access Accounts

This commit is contained in:
Hazelnoot 2025-06-21 00:43:17 -04:00
parent 7715f36a99
commit fa5a46f379
22 changed files with 789 additions and 32 deletions

View file

@ -16,6 +16,7 @@ import { prefer } from '@/preferences.js';
import { store } from '@/store.js';
import { $i } from '@/i.js';
import { signout } from '@/signout.js';
import * as os from '@/os';
type AccountWithToken = Misskey.entities.MeDetailed & { token: string };
@ -299,6 +300,15 @@ export async function openAccountMenu(opts: {
}
});
},
}, {
text: i18n.ts.sharedAccess,
action: () => {
getAccountWithSharedAccessDialog().then((res) => {
if (res != null) {
os.success();
}
});
},
}],
}, {
type: 'link',
@ -324,6 +334,24 @@ export async function openAccountMenu(opts: {
});
}
export function getAccountWithSharedAccessDialog(): Promise<{ id: string, token: string } | null> {
return new Promise((resolve) => {
const { dispose } = popup(defineAsyncComponent(() => import('@/components/SkSigninSharedAccessDialog.vue')), {}, {
done: async (res: { id: string, i: string }) => {
const user = await fetchAccount(res.i, res.id, true);
await addAccount(host, user, res.i);
resolve({ id: res.id, token: res.i });
},
cancelled: () => {
resolve(null);
},
closed: () => {
dispose();
},
});
});
}
export function getAccountWithSigninDialog(): Promise<{ id: string, token: string } | null> {
return new Promise((resolve) => {
const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkSigninDialog.vue')), {}, {