🚑 Fix last guild

This commit is contained in:
SebClem 2022-06-22 19:24:05 +02:00
parent f1dffa0b07
commit b27eeb8a03
Signed by: sebclem
GPG Key ID: 5A4308F6A359EA50
4 changed files with 13 additions and 23 deletions

View File

@ -9,6 +9,8 @@
active-color="primary" active-color="primary"
:to="getToUrl(guild)" :to="getToUrl(guild)"
:disabled="shouldBeDisabled(guild)" :disabled="shouldBeDisabled(guild)"
:data-guild-id="guild.id"
@click="clickOnGuild(guild.id)"
> >
<v-list-item-avatar <v-list-item-avatar
start start
@ -75,6 +77,10 @@ function getToUrl(guild: Guild): RouteLocationRaw {
}, },
}; };
} }
function clickOnGuild(guildId: string) {
mutualGuildsStore.lastGuildId = guildId;
}
</script> </script>
<style scoped></style> <style scoped></style>

View File

@ -24,14 +24,14 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import GuildHeaderComponent from "@/components/guild/GuildHeaderComponent.vue";
import { useMutualGuildsStore } from "@/stores/mutualGuilds"; import { useMutualGuildsStore } from "@/stores/mutualGuilds";
import { redirectIfNoGuild } from "@/tools/GuildTools"; import { redirectIfNoGuild } from "@/tools/GuildTools";
import { ref, watch } from "vue"; import { ref } from "vue";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import AudioPreviewComponent from "../components/guild/home/AudioPreviewComponent.vue"; import AudioPreviewComponent from "../components/guild/home/AudioPreviewComponent.vue";
import SettingPreviewComponent from "../components/guild/home/SettingPreviewComponent.vue"; import SettingPreviewComponent from "../components/guild/home/SettingPreviewComponent.vue";
import StatsPreviewComponent from "../components/guild/home/StatsPreviewComponent.vue"; import StatsPreviewComponent from "../components/guild/home/StatsPreviewComponent.vue";
import GuildHeaderComponent from "@/components/guild/GuildHeaderComponent.vue";
const guildStore = useMutualGuildsStore(); const guildStore = useMutualGuildsStore();
const route = useRoute(); const route = useRoute();
@ -39,15 +39,6 @@ const router = useRouter();
const guild = ref(guildStore.getGuild(route.params.guildId as string)); const guild = ref(guildStore.getGuild(route.params.guildId as string));
redirectIfNoGuild(guild.value, router); redirectIfNoGuild(guild.value, router);
watch(
() => route.params.guildId,
(value, oldValue) => {
guild.value = guildStore.getGuild(value as string);
guildStore.lastGuildId = guild.value?.id;
redirectIfNoGuild(guild.value, router);
}
);
</script> </script>
<style scoped></style> <style scoped></style>

View File

@ -10,27 +10,19 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import GuildHeaderComponent from "@/components/guild/GuildHeaderComponent.vue";
import { useMutualGuildsStore } from "@/stores/mutualGuilds"; import { useMutualGuildsStore } from "@/stores/mutualGuilds";
import { redirectIfNoGuild } from "@/tools/GuildTools"; import { redirectIfNoGuild } from "@/tools/GuildTools";
import { ref, watch } from "vue"; import { ref } from "vue";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import SettingListComponent from "../components/guild/Settings/SettingListComponent.vue"; import SettingListComponent from "../components/guild/Settings/SettingListComponent.vue";
import GuildHeaderComponent from "@/components/guild/GuildHeaderComponent.vue";
const guildStore = useMutualGuildsStore(); const guildStore = useMutualGuildsStore();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const guild = ref(guildStore.getGuild(route.params.guildId as string)); const guild = ref(guildStore.getGuild(route.params.guildId as string));
redirectIfNoGuild(guild.value, router); redirectIfNoGuild(guild.value, router);
watch(
() => route.params.guildId,
(value, oldValue) => {
guild.value = guildStore.getGuild(value as string);
guildStore.lastGuildId = guild.value?.id;
redirectIfNoGuild(guild.value, router);
}
);
</script> </script>
<style scoped></style> <style scoped></style>

View File

@ -15,11 +15,12 @@ import { useMutualGuildsStore } from "@/stores/mutualGuilds";
import { useUserStore } from "@/stores/user"; import { useUserStore } from "@/stores/user";
import { onBeforeMount } from "vue"; import { onBeforeMount } from "vue";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
const userStore = useUserStore(); const userStore = useUserStore();
const mutualGuildStore = useMutualGuildsStore();
const router = useRouter(); const router = useRouter();
onBeforeMount(() => { onBeforeMount(() => {
const mutualGuildStore = useMutualGuildsStore();
if (userStore.isLoggedIn) { if (userStore.isLoggedIn) {
if (!mutualGuildStore.lastGuildId) { if (!mutualGuildStore.lastGuildId) {
mutualGuildStore.lastGuildId = mutualGuildStore.guilds[0]?.id; mutualGuildStore.lastGuildId = mutualGuildStore.guilds[0]?.id;