Skip to content

Commit 32c13d4

Browse files
committed
fix: 🐛 Fixes with not refreshing localStorage me value
1 parent 14a37d3 commit 32c13d4

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

app.vue

+12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const client = useMegalodon(tokenData);
2222
const instance = useInstance(client);
2323
const description = useExtendedDescription(client);
2424
const me = useMe();
25+
const customEmojis = useCustomEmojis(client);
2526
2627
useSeoMeta({
2728
titleTemplate: (titleChunk) => {
@@ -82,6 +83,17 @@ watch(
8283
},
8384
{ immediate: true },
8485
);
86+
87+
// Refresh custom emojis and instance data and me on every reload
88+
if (tokenData.value) {
89+
await client.value?.verifyAccountCredentials().then((res) => {
90+
me.value = res.data;
91+
});
92+
}
93+
94+
client.value?.getInstanceCustomEmojis().then((res) => {
95+
customEmojis.value = res.data;
96+
});
8597
</script>
8698

8799
<style>

components/composer/composer.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</div>
2525
</div>
2626
<!-- Content warning textbox -->
27-
<div v-if="cw !== null" class="mb-4">
27+
<div v-if="cw" class="mb-4">
2828
<input type="text" v-model="cwContent" placeholder="Add a content warning"
2929
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" />
3030
</div>
@@ -45,7 +45,7 @@
4545
<ComposerButton title="Add a file">
4646
<iconify-icon width="1.25rem" height="1.25rem" icon="tabler:file-upload" aria-hidden="true" />
4747
</ComposerButton>
48-
<ComposerButton title="Add content warning" @click="cw = cw === null ? '' : null" :toggled="cw !== null">
48+
<ComposerButton title="Add content warning" @click="cw = !cw" :toggled="cw">
4949
<iconify-icon width="1.25rem" height="1.25rem" icon="tabler:rating-18-plus" aria-hidden="true" />
5050
</ComposerButton>
5151
<ButtonsPrimary :loading="submitting" @click="send" class="ml-auto rounded-full">
@@ -68,7 +68,7 @@ const { Control_Enter, Command_Enter, Control_Alt } = useMagicKeys();
6868
const respondingTo = ref<Status | null>(null);
6969
const respondingType = ref<"reply" | "quote" | null>(null);
7070
const me = useMe();
71-
const cw = ref(null as string | null);
71+
const cw = ref(false);
7272
const cwContent = ref("");
7373
const markdown = ref(true);
7474
@@ -130,8 +130,8 @@ const send = async () => {
130130
respondingType.value === "quote"
131131
? respondingTo.value?.id
132132
: null,
133-
spoiler_text: cw ? cwContent.value.trim() : undefined,
134-
sensitive: !!cw,
133+
spoiler_text: cw.value ? cwContent.value.trim() : undefined,
134+
sensitive: cw.value,
135135
}),
136136
})
137137
.then(async (res) => {

composables/CustomEmojis.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { Mastodon } from "megalodon";
2+
import type { Emoji } from "~/types/mastodon/emoji";
3+
4+
export const useCustomEmojis = (client: MaybeRef<Mastodon | null>) => {
5+
// Cache in localStorage
6+
return useLocalStorage<Emoji[]>("lysand:custom_emojis", []);
7+
};

pages/oauth/consent.vue

+1-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ const redirect_uri = query.redirect_uri as string;
100100
const client_id = query.client_id;
101101
const scope = query.scope ? decodeURIComponent(query.scope as string) : "";
102102
103-
const validUrlParameters =
104-
application && redirect_uri && client_id && scope;
103+
const validUrlParameters = application && redirect_uri && client_id && scope;
105104
106105
const oauthScopeText: Record<string, string> = {
107106
"rw:accounts": "$VERB your account information",

0 commit comments

Comments
 (0)