Remove de-planned pinia store

This commit is contained in:
2025-02-08 21:14:09 -05:00
parent bdb03c68dc
commit a2e564087b
2 changed files with 0 additions and 72 deletions

View File

@@ -1,24 +0,0 @@
import { defineStore } from 'pinia'
import {ref} from "vue";
import {useClient} from "@/plugins/api.js";
export const useMessageStore = defineStore('message', () => {
const messageCount = ref(0);
const trackedSubject = ref('');
async function fetchMessageCount(subjectId){
const client = useClient();
try {
let uri = `/api/message-count/${subjectId}`;
const response = await client.get(uri);
messageCount.value = response.data.count;
trackedSubject.value = subjectId;
} catch (error) {
console.error("Failed to fetch messages", error);
}
return messageCount.value;
}
return { messageCount, trackedSubject, fetchMessageCount }
})

View File

@@ -1,48 +0,0 @@
import {defineStore} from "pinia";
import {useSessionStorage} from "@vueuse/core";
import {useClient} from "@/plugins/api.js";
import {useAuthStore} from "@/stores/authStore.js";
import {watch, onMounted} from "vue";
export const useSubscriptionStore = defineStore(
'subscription',
() => {
const authStore = useAuthStore()
watch(
() => authStore.isAuthenticated,
async (newValue) => {
if (newValue) {
await loadSubscriptions()
} else {
subscriptions.value = {}
}
})
const subscriptions = useSessionStorage(
'subscription-subscriptions',
{})
function isSubscribeTo(creatorId) {
return !!subscriptions.value[creatorId];
}
async function loadSubscriptions() {
try {
const client = useClient()
const response = await client.get(`/api/membership/active`);
subscriptions.value = response.data.reduce(
(acc, sub) => {
acc[sub.creatorId] = sub;
return acc;
},
{});
} catch (error) {
console.error("Error loading subscriptions:", error);
}
}
return {subscriptions, isSubscribeTo}
});