Skip to content

Commit f751a50

Browse files
luizhf42gustavosbarreto
authored andcommitted
refactor(ui): move hasNamespaces computed to namespaces store
1 parent 47b5330 commit f751a50

File tree

6 files changed

+8
-7
lines changed

6 files changed

+8
-7
lines changed

ui/src/components/AppBar/AppBar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ const userId = computed(() => authStore.id);
215215
const currentUser = computed(() => authStore.username);
216216
const isBillingActive = computed(() => billingStore.isActive);
217217
const theme = computed(() => layoutStore.theme);
218-
const hasNamespaces = computed(() => namespacesStore.namespaceList.length > 0);
218+
const hasNamespaces = computed(() => namespacesStore.hasNamespaces);
219219
const isChatCreated = computed(() => supportStore.isChatCreated);
220220
const identifier = computed(() => supportStore.identifier);
221221
const isDarkMode = ref(theme.value === "dark");

ui/src/components/Namespace/Namespace.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ const showAddDialog = ref(false);
166166
167167
const currentNamespace = computed(() => namespacesStore.currentNamespace);
168168
const namespaceList = computed(() => namespacesStore.namespaceList);
169-
const hasNamespaces = computed(() => namespacesStore.namespaceList.length > 0);
169+
const hasNamespaces = computed(() => namespacesStore.hasNamespaces);
170170
const showInstructionsDialog = ref(false);
171171
const userId = computed(() => authStore.id || localStorage.getItem("id") || "");
172172

ui/src/components/User/UserDelete.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ import useAuthStore from "@/store/modules/auth";
3939
import useNamespacesStore from "@/store/modules/namespaces";
4040
4141
const authStore = useAuthStore();
42-
const { namespaceList } = useNamespacesStore();
43-
const hasNamespaces = namespaceList.length > 0;
42+
const { hasNamespaces } = useNamespacesStore();
4443
const snackbar = useSnackbar();
4544
const router = useRouter();
4645
const showDialog = defineModel<boolean>({ default: false });

ui/src/components/User/UserWarning.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const showForceRecoveryMail = computed(() => authStore.showForceRecoveryMail);
8181
const showPaywall = computed(() => usersStore.showPaywall);
8282
const stats = computed(() => statsStore.stats);
8383
const currentAnnouncement = computed(() => announcementStore.currentAnnouncement);
84-
const hasNamespaces = computed(() => namespacesStore.namespaceList.length > 0);
84+
const hasNamespaces = computed(() => namespacesStore.hasNamespaces);
8585
const showDeviceChooser = computed(() => devicesStore.showDeviceChooser);
8686
const showBillingWarning = computed({
8787
get() {

ui/src/layouts/AppLayout.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ const namespacesStore = useNamespacesStore();
187187
const spinnerStore = useSpinnerStore();
188188
const { getPrivateKeyList } = usePrivateKeysStore();
189189
const currentRoute = computed(() => router.currentRoute);
190-
const hasNamespaces = computed(() => namespacesStore.namespaceList.length !== 0);
190+
const hasNamespaces = computed(() => namespacesStore.hasNamespaces);
191191
const theme = computed(() => layoutStore.theme);
192192
193193
const { lgAndUp } = useDisplay();

ui/src/store/modules/namespaces.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { defineStore } from "pinia";
2-
import { ref } from "vue";
2+
import { computed, ref } from "vue";
33
import * as namespacesApi from "../api/namespaces";
44
import {
55
INamespace,
@@ -14,6 +14,7 @@ const useNamespacesStore = defineStore("namespaces", () => {
1414
const currentNamespace = ref<INamespace>({} as INamespace);
1515
const namespaceList = ref<Array<INamespace>>([]);
1616
const userStatus = ref<string>();
17+
const hasNamespaces = computed(() => namespaceList.value.length > 0);
1718

1819
const fetchNamespaceList = async (data?: { page?: number; perPage?: number; filter?: string }) => {
1920
const res = await namespacesApi.fetchNamespaces(data?.page || 1, data?.perPage || 10, data?.filter);
@@ -99,6 +100,7 @@ const useNamespacesStore = defineStore("namespaces", () => {
99100
currentNamespace,
100101
namespaceList,
101102
userStatus,
103+
hasNamespaces,
102104

103105
createNamespace,
104106
fetchNamespaceList,

0 commit comments

Comments
 (0)