Remove de-planned pinia store
This commit is contained in:
@@ -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 }
|
||||
})
|
||||
@@ -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}
|
||||
});
|
||||
Reference in New Issue
Block a user