Fix an error when logging out was causing state issues

This commit is contained in:
Jonathan Bourdon
2024-08-05 13:17:22 -04:00
parent 9cbf63339a
commit 3a98b38a71
5 changed files with 12 additions and 11 deletions

View File

@@ -9,8 +9,10 @@ export const useAuthStore = defineStore(
() => {
const clientApi = useClient()
const router = useRouter()
const accessToken = useSessionStorage('auth-accessToken', undefined)
const refreshToken = useSessionStorage('auth-refreshToken', undefined)
const isAuthenticated = computed(() => !!accessToken.value)
function updateTokens(data) {
@@ -25,9 +27,9 @@ export const useAuthStore = defineStore(
})
}
function logout() {
async function logout() {
cleanTokens()
router.push('/')
await router.push('/')
}
async function login(email, password) {

View File

@@ -10,7 +10,7 @@ export const useUserStore = defineStore(
const authStore = useAuthStore()
const authWatcher = watch(
() => authStore.isAuthenticated,
async (newValue, oldValue) => {
async (newValue) => {
if (newValue) {
await fetchCurrentUserProfile()
} else {

View File

@@ -45,16 +45,15 @@ const creatorIdWatcher = watch(
(newCreatorId) => {
if (newCreatorId) {
// Reset contents and last_id when the creatorId changes
contents.value = [];
last_id = null;
contents.value = []
last_id = null
// Fetch contents for the new creator
fetchContents({
done: () => {
}
});
}
},
{immediate: true})
})
async function fetchContents({done}) {
try {

View File

@@ -61,7 +61,7 @@ const closeDialog = () => {
<template>
<button
v-if="creator.id === userStore.user.id"
v-if="creator && userStore.user && creator.id === userStore.user.id"
class="flex items-center text-white transform transition-transform duration-200 hover:text-gray-300 hover:scale-125 px-4"
@click="isDialogActive = true">
<v-icon style="font-size: 35px; height: 35px; width: 55px;">mdi-text-box-plus-outline</v-icon>

View File

@@ -59,7 +59,7 @@
<div class="text-2xl text-center lg:text-left">
<p :style="{ color: creator.profileColors.accent }">{{ creator.occupation }}</p>
</div>
<div class="text-lg text-white" >{{creator.subscriberCount}} Abonnés</div>
<div class="text-lg text-white">{{ creator.subscriberCount }} Abonnés</div>
</div>
<!-- Buttons -->
@@ -69,7 +69,7 @@
<subscribe-button :creator="creator"></subscribe-button>
<CreatePostButton :creator="creator"/>
<publish-content-button :creator="creator"/>
</div>
@@ -79,10 +79,10 @@
</template>
<script setup>
import CreatePostButton from "@/views/contents/CreatePostButton.vue";
import SizeIndicator from "@/views/tools/SizeIndicator.vue";
import AboutYou from "@/views/creators/CreatorDescriptionBtn.vue";
import SubscribeButton from "@/views/creators/SubscribeButton.vue";
import PublishContentButton from "@/views/contents/PublishContentButton.vue";
const props = defineProps({
creator: {type: Object, required: true},