mirror of
https://github.com/versia-pub/frontend.git
synced 2025-12-06 08:28:20 +01:00
fix: 🐛 Don't auto mention yourself when replying/quoting yourself
This commit is contained in:
parent
86e254b7e7
commit
a2a2149776
17
app.vue
17
app.vue
|
|
@ -15,11 +15,12 @@ useServerSeoMeta({
|
|||
provideHeadlessUseId(() => useId());
|
||||
|
||||
const code = useRequestURL().searchParams.get("code");
|
||||
const appData = useAppData();
|
||||
const tokenData = useTokenData();
|
||||
const client = useMegalodon(tokenData);
|
||||
const me = useMe();
|
||||
|
||||
if (code) {
|
||||
const client = useMegalodon();
|
||||
const appData = useAppData();
|
||||
const tokenData = useTokenData();
|
||||
if (appData.value) {
|
||||
client.value
|
||||
?.fetchAccessToken(
|
||||
|
|
@ -40,6 +41,16 @@ if (code) {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
watch(tokenData, async () => {
|
||||
if (tokenData.value && !me.value) {
|
||||
const response = await client.value?.verifyAccountCredentials()
|
||||
|
||||
if (response?.data) {
|
||||
me.value = response.data;
|
||||
}
|
||||
}
|
||||
}, { immediate: true })
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
|
|||
|
|
@ -40,11 +40,13 @@ const { input: content } = useTextareaAutosize({
|
|||
const { Control_Enter, Command_Enter } = useMagicKeys();
|
||||
const respondingTo = ref<Status | null>(null);
|
||||
const respondingType = ref<"reply" | "quote" | null>(null);
|
||||
const me = useMe();
|
||||
|
||||
onMounted(() => {
|
||||
useListen("composer:reply", (note: Status) => {
|
||||
respondingTo.value = note;
|
||||
respondingType.value = "reply";
|
||||
if (note.account.id !== me.value?.id)
|
||||
content.value = `@${note.account.acct} `;
|
||||
textarea.value?.focus();
|
||||
});
|
||||
|
|
@ -52,6 +54,7 @@ onMounted(() => {
|
|||
useListen("composer:quote", (note: Status) => {
|
||||
respondingTo.value = note;
|
||||
respondingType.value = "quote";
|
||||
if (note.account.id !== me.value?.id)
|
||||
content.value = `@${note.account.acct} `;
|
||||
textarea.value?.focus();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ const loadingAuth = ref(false);
|
|||
const appData = useAppData();
|
||||
const tokenData = useTokenData();
|
||||
const client = useMegalodon();
|
||||
const me = useMe();
|
||||
|
||||
const compose = () => {
|
||||
useEvent("composer:open");
|
||||
|
|
@ -124,8 +125,9 @@ const signOut = async () => {
|
|||
tokenData.value.access_token,
|
||||
tokenData.value.access_token,
|
||||
)
|
||||
.catch(() => {});
|
||||
.catch(() => { });
|
||||
|
||||
tokenData.value = null;
|
||||
me.value = null;
|
||||
};
|
||||
</script>
|
||||
8
composables/Me.ts
Normal file
8
composables/Me.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import { StorageSerializers } from "@vueuse/core";
|
||||
import type { Account } from "~/types/mastodon/account";
|
||||
|
||||
export const useMe = () => {
|
||||
return useLocalStorage<Account | null>("lysand:me", null, {
|
||||
serializer: StorageSerializers.object,
|
||||
});
|
||||
};
|
||||
|
|
@ -10,9 +10,6 @@ export const useMegalodon = (
|
|||
|
||||
return computed(
|
||||
() =>
|
||||
new Mastodon(
|
||||
useBaseUrl().value,
|
||||
ref(tokenData).value?.access_token,
|
||||
),
|
||||
new Mastodon(useBaseUrl().value, toValue(tokenData)?.access_token),
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue