mirror of
https://github.com/versia-pub/frontend.git
synced 2026-03-13 03:29:16 +01:00
refactor: ♻️ Rewrite state system to use Pinia for composer and auth
This commit is contained in:
parent
a6db9e059d
commit
b510782a30
80 changed files with 999 additions and 1011 deletions
|
|
@ -52,6 +52,7 @@ const emit = defineEmits<{
|
|||
pick: [emoji: z.infer<typeof CustomEmoji> | UnicodeEmoji];
|
||||
}>();
|
||||
|
||||
const authStore = useAuthStore();
|
||||
const open = ref(false);
|
||||
const selectedEmoji = ref<z.infer<typeof CustomEmoji> | UnicodeEmoji | null>(
|
||||
null,
|
||||
|
|
@ -59,12 +60,10 @@ const selectedEmoji = ref<z.infer<typeof CustomEmoji> | UnicodeEmoji | null>(
|
|||
const emojiContainer = useTemplateRef<HTMLDivElement>("emojiContainer");
|
||||
const filter = ref("");
|
||||
|
||||
const customEmojis = computed(() => identity.value?.emojis ?? []);
|
||||
|
||||
const customEmojiCategories = computed(() => {
|
||||
const categories: Record<string, z.infer<typeof CustomEmoji>[]> = {};
|
||||
|
||||
for (const emoji of customEmojis.value) {
|
||||
for (const emoji of authStore.emojis) {
|
||||
const categoryName = emoji.category || "Uncategorized";
|
||||
|
||||
if (!categories[categoryName]) {
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ const { reaction, emoji, statusId } = defineProps<{
|
|||
emoji?: z.infer<typeof CustomEmoji>;
|
||||
}>();
|
||||
|
||||
const authStore = useAuthStore();
|
||||
|
||||
const formatNumber = (number: number) =>
|
||||
new Intl.NumberFormat(getLocale(), {
|
||||
notation: "compact",
|
||||
|
|
@ -63,12 +65,13 @@ const formatNumber = (number: number) =>
|
|||
const accounts = ref<z.infer<typeof Account>[] | null>(null);
|
||||
|
||||
const refreshReactions = async () => {
|
||||
const { data } = await client.value.getStatusReactions(statusId);
|
||||
const { data } = await authStore.client.getStatusReactions(statusId);
|
||||
const accountIds =
|
||||
data.find((r) => r.name === reaction.name)?.account_ids.slice(0, 10) ??
|
||||
[];
|
||||
|
||||
const { data: accountsData } = await client.value.getAccounts(accountIds);
|
||||
const { data: accountsData } =
|
||||
await authStore.client.getAccounts(accountIds);
|
||||
|
||||
accounts.value = accountsData;
|
||||
};
|
||||
|
|
@ -76,7 +79,7 @@ const refreshReactions = async () => {
|
|||
const react = async () => {
|
||||
const id = toast.loading(m.gray_stale_antelope_roam());
|
||||
|
||||
const { data } = await client.value.createEmojiReaction(
|
||||
const { data } = await authStore.client.createEmojiReaction(
|
||||
statusId,
|
||||
reaction.name,
|
||||
);
|
||||
|
|
@ -89,7 +92,7 @@ const react = async () => {
|
|||
const unreact = async () => {
|
||||
const id = toast.loading(m.many_weary_bat_intend());
|
||||
|
||||
const { data } = await client.value.deleteEmojiReaction(
|
||||
const { data } = await authStore.client.deleteEmojiReaction(
|
||||
statusId,
|
||||
reaction.name,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue