Skip to content

Commit

Permalink
[#58] move stores under src/shared folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreezag committed Mar 3, 2024
1 parent 0e73b57 commit 66f785b
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 22 deletions.
4 changes: 2 additions & 2 deletions layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script lang="ts" setup>
import { computed, ref, onMounted } from "vue";
import { ref, onMounted } from "vue";
import { LayoutSidebar } from "~/src/widgets/ui";
import { useEvents } from "~/src/shared/lib/use-events";
import { useSettings } from "~/src/shared/lib/use-settings";
import SfdumpWrap from "~/src/shared/lib/vendor/dumper";
import { useSettingsStore } from "~/src/shared/stores/settings";
import { version } from "../package.json";
import { useSettingsStore } from "~/stores/settings";
SfdumpWrap(window.document);
useSettingsStore();
Expand Down
2 changes: 1 addition & 1 deletion pages/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { computed } from "vue";
// eslint-disable-next-line @conarti/feature-sliced/layers-slices
import { useHead } from "#app";
import { PageHeader } from "~/src/widgets/ui";
import { useSettingsStore, THEME_MODES } from "~/src/shared/stores/settings";
import { IconSvg } from "~/src/shared/ui";
import { useSettingsStore, THEME_MODES } from "~/stores/settings";
const settingsStore = useSettingsStore();
const { changeTheme, changeNavbar } = settingsStore;
Expand Down
3 changes: 1 addition & 2 deletions src/shared/lib/use-api-transport/use-api-transport.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { RayContentLock } from "~/src/entities/ray/types";
import { useEventStore, useConnectionStore } from "../../stores";
import type { EventId, EventType } from '../../types';
import { useCentrifuge, useEventsRequests } from "../io";
import { useConnectionStore } from "~/stores/connections";
import { useEventStore } from "~/stores/events";

const CHECK_CONNECTION_INTERVAL = 10000
export const useApiTransport = () => {
Expand Down
4 changes: 1 addition & 3 deletions src/shared/lib/use-events/use-events-api.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { storeToRefs } from "pinia";
import type { Ref } from 'vue';
import { useEventStore, useCachedIdsStore, useLockedIdsStore } from "../../stores";
import type { EventId, EventType, ServerEvent } from '../../types';
import { useApiTransport } from '../use-api-transport'
import { useCachedIdsStore } from "~/stores/cached-ids";
import { useEventStore } from "~/stores/events";
import { useLockedIdsStore } from "~/stores/locked-ids";


export type TUseEventsApi = {
Expand Down
4 changes: 1 addition & 3 deletions src/shared/lib/use-events/use-events.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { storeToRefs } from "pinia";
import type { Ref } from "vue";
import type { RayContentLock } from "~/src/entities/ray/types";
import { type TCachedEventsEmptyMap, type TEventsGroup , useCachedIdsStore, useLockedIdsStore } from "../../stores";
import type { ServerEvent, NormalizedEvent, EventId } from '../../types';
import { useApiTransport } from "../use-api-transport";
import { normalizeUnknownEvent } from "./normalize-unknown-event";
import { type TUseEventsApi, useEventsApi } from "./use-events-api";
import type { TCachedEventsEmptyMap, TEventsGroup } from "~/stores/cached-ids";
import { useCachedIdsStore } from "~/stores/cached-ids";
import { useLockedIdsStore } from "~/stores/locked-ids";


type TUseEvents = () => {
Expand Down
7 changes: 3 additions & 4 deletions stores/cached-ids.ts → src/shared/stores/cached-ids.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { defineStore } from "pinia";
import { PAGE_TYPES } from "~/src/shared/constants";
import { LOCAL_STORAGE_KEYS } from '~/src/shared/types';
import type { EventId, OneOfValues } from '~/src/shared/types';
import { useEventStore } from "~/stores/events";
import { PAGE_TYPES } from "../constants";
import { type EventId, type OneOfValues, LOCAL_STORAGE_KEYS } from '../types';
import { useEventStore } from "./events";

export type TEventsGroup = OneOfValues<typeof PAGE_TYPES>

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions stores/events.ts → src/shared/stores/events.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineStore } from "pinia";
import type { EventId, EventType, ServerEvent } from '~/src/shared/types';
import { useLockedIdsStore } from "~/stores/locked-ids";
import type { EventId, EventType, ServerEvent } from '../types';
import { useLockedIdsStore } from "./locked-ids";


export const useEventStore = defineStore("useEventStore", {
Expand Down
5 changes: 5 additions & 0 deletions src/shared/stores/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from './cached-ids'
export * from './connections'
export * from './events'
export * from './locked-ids'
export * from './settings'
3 changes: 1 addition & 2 deletions stores/locked-ids.ts → src/shared/stores/locked-ids.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { defineStore } from "pinia";
import { LOCAL_STORAGE_KEYS } from '~/src/shared/types';
import type { EventId } from '~/src/shared/types';
import { type EventId, LOCAL_STORAGE_KEYS } from '../types';

const { localStorage } = window;
const getLockedIds = (): EventId[] => {
Expand Down
2 changes: 1 addition & 1 deletion stores/settings.ts → src/shared/stores/settings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineStore } from "pinia";
import { LOCAL_STORAGE_KEYS } from "~/src/shared/types";
import { LOCAL_STORAGE_KEYS } from "../types";

export const THEME_MODES = {
LIGHT: "light",
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/ui/layout-sidebar/layout-sidebar.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts" setup>
import { storeToRefs } from "pinia";
import { computed } from "vue";
import { useConnectionStore } from "~/src/shared/stores/connections";
import { IconSvg } from "~/src/shared/ui";
import { useConnectionStore } from "~/stores/connections";
type Props = {
apiVersion: string;
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/ui/page-layout/page-layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { computed } from "vue";
import { useHead } from "#app";
import { PAGE_TYPES } from "~/src/shared/constants";
import { useEvents } from "~/src/shared/lib/use-events";
import type { TEventsGroup } from "~/src/shared/stores/cached-ids";
import type { EventType } from "~/src/shared/types";
import { PauseButton } from "~/src/shared/ui/pause-button";
import { EventCard } from "../event-card";
import { PageHeader } from "../page-header";
import { PagePlaceholder } from "../page-placeholder";
import type { TEventsGroup } from "~/stores/cached-ids";
type Props = {
title?: string;
Expand Down

0 comments on commit 66f785b

Please sign in to comment.