feat: Make PWA installable with icons and screenshots

This commit is contained in:
Jesse Wierzbinski 2024-06-15 12:41:23 -10:00
parent 60cbe129bb
commit d0b82e822d
No known key found for this signature in database
122 changed files with 552 additions and 48 deletions

48
utils/auth.ts Normal file
View file

@ -0,0 +1,48 @@
import { nanoid } from "nanoid";
export const signInWithCode = (code: string, appData: ApplicationData) => {
const identity = useCurrentIdentity();
const identities = useIdentities();
const client = useClient();
client.value
?.fetchAccessToken(
appData.client_id,
appData.client_secret,
code,
new URL("/", useRequestURL().origin).toString(),
)
.then(async (res) => {
const tempClient = useClient(res.data).value;
const [accountOutput, instanceOutput] = await Promise.all([
tempClient.verifyAccountCredentials(),
tempClient.getInstance(),
]);
// Get account data
if (
!identities.value.find(
(i) => i.account.id === accountOutput.data.id,
)
)
identity.value = {
id: nanoid(),
tokens: res.data,
account: accountOutput.data,
instance: instanceOutput.data,
permissions: [],
emojis: [],
};
// Remove code from URL
window.history.replaceState(
{},
document.title,
window.location.pathname,
);
// Redirect to home
window.location.pathname = "/";
});
};