mirror of
https://github.com/versia-pub/frontend.git
synced 2025-12-06 16:38:20 +01:00
fix: 🐛 Fixes with not refreshing localStorage me value
This commit is contained in:
parent
14a37d3585
commit
32c13d4c99
12
app.vue
12
app.vue
|
|
@ -22,6 +22,7 @@ const client = useMegalodon(tokenData);
|
||||||
const instance = useInstance(client);
|
const instance = useInstance(client);
|
||||||
const description = useExtendedDescription(client);
|
const description = useExtendedDescription(client);
|
||||||
const me = useMe();
|
const me = useMe();
|
||||||
|
const customEmojis = useCustomEmojis(client);
|
||||||
|
|
||||||
useSeoMeta({
|
useSeoMeta({
|
||||||
titleTemplate: (titleChunk) => {
|
titleTemplate: (titleChunk) => {
|
||||||
|
|
@ -82,6 +83,17 @@ watch(
|
||||||
},
|
},
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Refresh custom emojis and instance data and me on every reload
|
||||||
|
if (tokenData.value) {
|
||||||
|
await client.value?.verifyAccountCredentials().then((res) => {
|
||||||
|
me.value = res.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
client.value?.getInstanceCustomEmojis().then((res) => {
|
||||||
|
customEmojis.value = res.data;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Content warning textbox -->
|
<!-- Content warning textbox -->
|
||||||
<div v-if="cw !== null" class="mb-4">
|
<div v-if="cw" class="mb-4">
|
||||||
<input type="text" v-model="cwContent" placeholder="Add a content warning"
|
<input type="text" v-model="cwContent" placeholder="Add a content warning"
|
||||||
class="w-full p-2 mt-1 text-sm prose prose-invert bg-dark-900 rounded focus:!ring-0 !ring-none !border-none !outline-none placeholder:text-zinc-500 appearance-none focus:!border-none focus:!outline-none" />
|
class="w-full p-2 mt-1 text-sm prose prose-invert bg-dark-900 rounded focus:!ring-0 !ring-none !border-none !outline-none placeholder:text-zinc-500 appearance-none focus:!border-none focus:!outline-none" />
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
<ComposerButton title="Add a file">
|
<ComposerButton title="Add a file">
|
||||||
<iconify-icon width="1.25rem" height="1.25rem" icon="tabler:file-upload" aria-hidden="true" />
|
<iconify-icon width="1.25rem" height="1.25rem" icon="tabler:file-upload" aria-hidden="true" />
|
||||||
</ComposerButton>
|
</ComposerButton>
|
||||||
<ComposerButton title="Add content warning" @click="cw = cw === null ? '' : null" :toggled="cw !== null">
|
<ComposerButton title="Add content warning" @click="cw = !cw" :toggled="cw">
|
||||||
<iconify-icon width="1.25rem" height="1.25rem" icon="tabler:rating-18-plus" aria-hidden="true" />
|
<iconify-icon width="1.25rem" height="1.25rem" icon="tabler:rating-18-plus" aria-hidden="true" />
|
||||||
</ComposerButton>
|
</ComposerButton>
|
||||||
<ButtonsPrimary :loading="submitting" @click="send" class="ml-auto rounded-full">
|
<ButtonsPrimary :loading="submitting" @click="send" class="ml-auto rounded-full">
|
||||||
|
|
@ -68,7 +68,7 @@ const { Control_Enter, Command_Enter, Control_Alt } = useMagicKeys();
|
||||||
const respondingTo = ref<Status | null>(null);
|
const respondingTo = ref<Status | null>(null);
|
||||||
const respondingType = ref<"reply" | "quote" | null>(null);
|
const respondingType = ref<"reply" | "quote" | null>(null);
|
||||||
const me = useMe();
|
const me = useMe();
|
||||||
const cw = ref(null as string | null);
|
const cw = ref(false);
|
||||||
const cwContent = ref("");
|
const cwContent = ref("");
|
||||||
const markdown = ref(true);
|
const markdown = ref(true);
|
||||||
|
|
||||||
|
|
@ -130,8 +130,8 @@ const send = async () => {
|
||||||
respondingType.value === "quote"
|
respondingType.value === "quote"
|
||||||
? respondingTo.value?.id
|
? respondingTo.value?.id
|
||||||
: null,
|
: null,
|
||||||
spoiler_text: cw ? cwContent.value.trim() : undefined,
|
spoiler_text: cw.value ? cwContent.value.trim() : undefined,
|
||||||
sensitive: !!cw,
|
sensitive: cw.value,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
|
|
|
||||||
7
composables/CustomEmojis.ts
Normal file
7
composables/CustomEmojis.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
import type { Mastodon } from "megalodon";
|
||||||
|
import type { Emoji } from "~/types/mastodon/emoji";
|
||||||
|
|
||||||
|
export const useCustomEmojis = (client: MaybeRef<Mastodon | null>) => {
|
||||||
|
// Cache in localStorage
|
||||||
|
return useLocalStorage<Emoji[]>("lysand:custom_emojis", []);
|
||||||
|
};
|
||||||
|
|
@ -100,8 +100,7 @@ const redirect_uri = query.redirect_uri as string;
|
||||||
const client_id = query.client_id;
|
const client_id = query.client_id;
|
||||||
const scope = query.scope ? decodeURIComponent(query.scope as string) : "";
|
const scope = query.scope ? decodeURIComponent(query.scope as string) : "";
|
||||||
|
|
||||||
const validUrlParameters =
|
const validUrlParameters = application && redirect_uri && client_id && scope;
|
||||||
application && redirect_uri && client_id && scope;
|
|
||||||
|
|
||||||
const oauthScopeText: Record<string, string> = {
|
const oauthScopeText: Record<string, string> = {
|
||||||
"rw:accounts": "$VERB your account information",
|
"rw:accounts": "$VERB your account information",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue