Fix an error when logging out was causing state issues
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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>
|
||||
@@ -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},
|
||||
|
||||
Reference in New Issue
Block a user