Skip to content

Commit

Permalink
#74 add event filterings for layout sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreezag committed Aug 17, 2024
1 parent 3159c30 commit 7782b90
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/shared/stores/events/events-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const useEventsStore = defineStore("eventsStore", {
const { availableEvents } = useSettingsStore();

this.events = events
.filter((el) => availableEvents.includes(el.type as EventType))
.filter((el) => availableEvents.includes(el.type))
.slice(0, MAX_EVENTS_COUNT);

this.syncCachedWithActive(events.map(({ uuid }) => uuid));
Expand All @@ -97,7 +97,7 @@ export const useEventsStore = defineStore("eventsStore", {
addList(events: ServerEvent<unknown>[]): void {
const { availableEvents } = useSettingsStore();
events
.filter((el) => availableEvents.includes(el.type as EventType))
.filter((el) => availableEvents.includes(el.type))
.forEach((event) => {
const isExistedEvent: boolean = this.events.some((el): boolean => el.uuid === event.uuid);
if (!isExistedEvent) {
Expand Down
4 changes: 2 additions & 2 deletions src/shared/stores/settings/settings-store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {defineStore} from "pinia";
import {REST_API_URL} from "../../lib/io/constants";
import type {EventType, TSettings} from "../../types";
import { type EventType, type TSettings} from "../../types";
import {THEME_MODES} from "./constants";
import {
getStoredEventsCountVisibility,
Expand Down Expand Up @@ -47,7 +47,7 @@ export const useSettingsStore = defineStore("settingsStore", {

if (settings?.client?.events) {
// TODO: meed to move to the events store
this.availableEvents = settings?.client?.events as EventType[]
this.availableEvents = settings?.client?.events
}

this.isFetched = true
Expand Down
2 changes: 1 addition & 1 deletion src/shared/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type EventType = OneOfValues<typeof EVENT_TYPES>;

export interface ServerEvent<T> {
uuid: EventId,
type: EventType | string,
type: EventType,
payload: T,
project: string | null,
timestamp: number // unavailable for some ray dump events
Expand Down
4 changes: 2 additions & 2 deletions src/shared/types/settings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EVENT_TYPES } from "./events";
import {type EventType} from "./events";

export type TProfile = {
username: string,
Expand All @@ -13,7 +13,7 @@ export type TSettings = {
},
version: string,
client: {
events: EVENT_TYPES[],
events: EventType[],
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/widgets/ui/layout-sidebar/layout-sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const logout = () => {
const path = computed(() => useRoute().path);
const { apiVersion } = storeToRefs(useSettingsStore());
const { apiVersion, availableEvents } = storeToRefs(useSettingsStore());
const clientVersion = ref(
!version || version === "0.0.1" ? "@dev" : `v${version}`,
Expand All @@ -122,6 +122,10 @@ const setProject = (projectKey: string) => {
isVisibleProjects.value = false;
};
const filteredNavOrder = computed(() =>
EVENTS_NAV_ORDER.filter((type) => availableEvents.value.includes(type)),
);
const makeShortTitle = (title: string) => (title || "").substring(0, 2);
const generateRadialGradient = (input: string) =>
`linear-gradient(to right, ${textToColors(input || "").join(", ")})`;
Expand Down Expand Up @@ -170,7 +174,7 @@ const generateRadialGradient = (input: string) =>
</NuxtLink>
</template>

<template v-for="type in EVENTS_NAV_ORDER" :key="type">
<template v-for="type in filteredNavOrder" :key="type">
<NuxtLink
:to="EVENTS_LINKS_MAP[type].path"
:title="EVENTS_LINKS_MAP[type].title"
Expand Down

0 comments on commit 7782b90

Please sign in to comment.