diff --git a/frontend/src/stores/messageStore.js b/frontend/src/stores/messageStore.js deleted file mode 100644 index cee1374..0000000 --- a/frontend/src/stores/messageStore.js +++ /dev/null @@ -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 } -}) \ No newline at end of file diff --git a/frontend/src/stores/subscriptionStore.js b/frontend/src/stores/subscriptionStore.js deleted file mode 100644 index 05f1a9f..0000000 --- a/frontend/src/stores/subscriptionStore.js +++ /dev/null @@ -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} - }); \ No newline at end of file