diff --git a/frontend/dashboard/package.json b/frontend/dashboard/package.json index de08bea3e..ee599d905 100644 --- a/frontend/dashboard/package.json +++ b/frontend/dashboard/package.json @@ -44,7 +44,6 @@ "lucide-vue-next": "0.368.0", "naive-ui": "2.38.1", "nested-css-to-flat": "1.0.5", - "pinia": "2.1.7", "plyr": "3.7.8", "radix-vue": "1.7.0", "tailwind-merge": "2.2.2", diff --git a/frontend/dashboard/src/api/auth.ts b/frontend/dashboard/src/api/auth.ts index a05aa8b4c..6a44a227b 100644 --- a/frontend/dashboard/src/api/auth.ts +++ b/frontend/dashboard/src/api/auth.ts @@ -1,6 +1,6 @@ import { useQueryClient } from '@tanstack/vue-query' import { createRequest, useQuery } from '@urql/vue' -import { defineStore } from 'pinia' +import { createGlobalState } from '@vueuse/core' import { computed } from 'vue' import { useMutation } from '@/composables/use-mutation.js' @@ -46,15 +46,15 @@ export const profileQuery = createRequest(graphql(` export const userInvalidateQueryKey = 'UserInvalidateQueryKey' -export const useProfile = defineStore('auth/profile', () => { +export const useProfile = createGlobalState(() => { const { data: response, executeQuery, fetching } = useQuery({ query: profileQuery.query, variables: { }, context: { key: profileQuery.key, - additionalTypenames: [userInvalidateQueryKey] - } + additionalTypenames: [userInvalidateQueryKey], + }, }) const computedUser = computed(() => { @@ -75,7 +75,7 @@ export const useProfile = defineStore('auth/profile', () => { selectedDashboardId: user.selectedDashboardId, selectedDashboardTwitchUser: user.selectedDashboardTwitchUser, hideOnLandingPage: user.hideOnLandingPage, - availableDashboards: user.availableDashboards + availableDashboards: user.availableDashboards, } }) @@ -96,11 +96,11 @@ export function useLogout() { } return { - execute + execute, } } -export const useUserSettings = defineStore('userSettings', () => { +export const useUserSettings = createGlobalState(() => { const userPublicSettingsInvalidateKey = 'UserPublicSettingsInvalidateKey' const usePublicQuery = () => useQuery({ @@ -117,8 +117,8 @@ export const useUserSettings = defineStore('userSettings', () => { `), variables: {}, context: { - additionalTypenames: [userPublicSettingsInvalidateKey] - } + additionalTypenames: [userPublicSettingsInvalidateKey], + }, }) const usePublicMutation = () => useMutation(graphql(` @@ -143,11 +143,11 @@ export const useUserSettings = defineStore('userSettings', () => { usePublicQuery, usePublicMutation, useApiKeyGenerateMutation, - useUserUpdateMutation + useUserUpdateMutation, } }) -export const useDashboard = defineStore('auth/dashboard', () => { +export const useDashboard = createGlobalState(() => { const urqlClient = useUrqlClient() const mutationSetDashboard = useMutation(graphql(` @@ -166,7 +166,7 @@ export const useDashboard = defineStore('auth/dashboard', () => { } return { - setDashboard + setDashboard, } }) @@ -215,23 +215,23 @@ export const PERMISSIONS_FLAGS: Flag[] = [ { perm: ChannelRolePermissionEnum.ManageAlerts, description: 'Can manage alerts' }, 'delimiter', { perm: ChannelRolePermissionEnum.ViewGames, description: 'Can view games' }, - { perm: ChannelRolePermissionEnum.ManageGames, description: 'Can manage games' } + { perm: ChannelRolePermissionEnum.ManageGames, description: 'Can manage games' }, ] export function useUserAccessFlagChecker(flag: ChannelRolePermissionEnum) { - const profile = useProfile() + const { data: profile } = useProfile() return computed(() => { - if (!profile.data?.availableDashboards || !profile.data?.selectedDashboardId) return false + if (!profile.value?.availableDashboards || !profile.value?.selectedDashboardId) return false - if (profile.data.id === profile.data.selectedDashboardId) { + if (profile.value.id === profile.value.selectedDashboardId) { return true } - if (profile.data.isBotAdmin) return true + if (profile.value.isBotAdmin) return true - const dashboard = profile.data?.availableDashboards.find(dashboard => { - return dashboard.id === profile.data?.selectedDashboardId + const dashboard = profile.value?.availableDashboards.find(dashboard => { + return dashboard.id === profile.value?.selectedDashboardId }) if (!dashboard) return false diff --git a/frontend/dashboard/src/api/chat-alerts.ts b/frontend/dashboard/src/api/chat-alerts.ts index d3e850829..efb57545b 100644 --- a/frontend/dashboard/src/api/chat-alerts.ts +++ b/frontend/dashboard/src/api/chat-alerts.ts @@ -1,5 +1,5 @@ import { useQuery } from '@urql/vue' -import { defineStore } from 'pinia' +import { createGlobalState } from '@vueuse/core' import { computed } from 'vue' import type { GetAllChatAlertsQuery } from '@/gql/graphql.js' @@ -11,7 +11,7 @@ export type ChatAlerts = GetAllChatAlertsQuery['chatAlerts'] const invalidationKey = 'ChatAlertsInvalidateKey' -export const useChatAlertsApi = defineStore('api/chat-alerts', () => { +export const useChatAlertsApi = createGlobalState(() => { const { data } = useQuery({ variables: {}, context: { additionalTypenames: [invalidationKey] }, @@ -117,7 +117,7 @@ export const useChatAlertsApi = defineStore('api/chat-alerts', () => { } } } - `) + `), }) const chatAlerts = computed(() => data.value?.chatAlerts) @@ -132,6 +132,6 @@ export const useChatAlertsApi = defineStore('api/chat-alerts', () => { return { chatAlerts, - useMutationUpdateChatAlerts + useMutationUpdateChatAlerts, } }) diff --git a/frontend/dashboard/src/api/commands/commands-groups.ts b/frontend/dashboard/src/api/commands/commands-groups.ts index b43257b38..8c8b79508 100644 --- a/frontend/dashboard/src/api/commands/commands-groups.ts +++ b/frontend/dashboard/src/api/commands/commands-groups.ts @@ -1,5 +1,5 @@ import { useQuery } from '@urql/vue' -import { defineStore } from 'pinia' +import { createGlobalState } from '@vueuse/core' import { invalidationKey as commandsInvalidationKey } from './commands.js' @@ -8,7 +8,7 @@ import { graphql } from '@/gql/gql.js' const invalidationKey = 'CommandsGroupsInvalidateKey' -export const useCommandsGroupsApi = defineStore('api/commands-groups', () => { +export const useCommandsGroupsApi = createGlobalState(() => { const useQueryGroups = () => useQuery({ query: graphql(` query GetAllCommandsGroups { @@ -21,8 +21,8 @@ export const useCommandsGroupsApi = defineStore('api/commands-groups', () => { `), variables: {}, context: { - additionalTypenames: [invalidationKey] - } + additionalTypenames: [invalidationKey], + }, }) const useMutationDeleteGroup = () => useMutation( @@ -31,7 +31,7 @@ export const useCommandsGroupsApi = defineStore('api/commands-groups', () => { commandsGroupsRemove(id: $id) } `), - [invalidationKey, commandsInvalidationKey] + [invalidationKey, commandsInvalidationKey], ) const useMutationCreateGroup = () => useMutation( @@ -40,7 +40,7 @@ export const useCommandsGroupsApi = defineStore('api/commands-groups', () => { commandsGroupsCreate(opts: $opts) } `), - [invalidationKey] + [invalidationKey], ) const useMutationUpdateGroup = () => useMutation( @@ -49,13 +49,13 @@ export const useCommandsGroupsApi = defineStore('api/commands-groups', () => { commandsGroupsUpdate(id: $id,opts: $opts) } `), - [invalidationKey, commandsInvalidationKey] + [invalidationKey, commandsInvalidationKey], ) return { useQueryGroups, useMutationDeleteGroup, useMutationCreateGroup, - useMutationUpdateGroup + useMutationUpdateGroup, } }) diff --git a/frontend/dashboard/src/api/commands/commands.ts b/frontend/dashboard/src/api/commands/commands.ts index 04a4c0dfc..2400b45e8 100644 --- a/frontend/dashboard/src/api/commands/commands.ts +++ b/frontend/dashboard/src/api/commands/commands.ts @@ -1,12 +1,12 @@ import { useQuery } from '@urql/vue' -import { defineStore } from 'pinia' +import { createGlobalState } from '@vueuse/core' import { useMutation } from '@/composables/use-mutation.js' import { graphql } from '@/gql/gql.js' export const invalidationKey = 'CommandsInvalidateKey' -export const useCommandsApi = defineStore('api/commands', () => { +export const useCommandsApi = createGlobalState(() => { const useQueryCommands = () => useQuery({ query: graphql(` query GetAllCommands { @@ -48,9 +48,9 @@ export const useCommandsApi = defineStore('api/commands', () => { } `), context: { - additionalTypenames: [invalidationKey] + additionalTypenames: [invalidationKey], }, - variables: {} + variables: {}, }) const useMutationDeleteCommand = () => useMutation( @@ -59,7 +59,7 @@ export const useCommandsApi = defineStore('api/commands', () => { commandsRemove(id: $id) } `), - [invalidationKey] + [invalidationKey], ) const useMutationCreateCommand = () => useMutation( @@ -68,7 +68,7 @@ export const useCommandsApi = defineStore('api/commands', () => { commandsCreate(opts: $opts) } `), - [invalidationKey] + [invalidationKey], ) const useMutationUpdateCommand = () => useMutation( @@ -77,13 +77,13 @@ export const useCommandsApi = defineStore('api/commands', () => { commandsUpdate(id: $id, opts: $opts) } `), - [invalidationKey] + [invalidationKey], ) return { useQueryCommands, useMutationDeleteCommand, useMutationCreateCommand, - useMutationUpdateCommand + useMutationUpdateCommand, } }) diff --git a/frontend/dashboard/src/api/community-users.ts b/frontend/dashboard/src/api/community-users.ts index 77e6863a5..22e12647b 100644 --- a/frontend/dashboard/src/api/community-users.ts +++ b/frontend/dashboard/src/api/community-users.ts @@ -1,5 +1,5 @@ import { useQuery } from '@urql/vue' -import { defineStore } from 'pinia' +import { createGlobalState } from '@vueuse/core' import type { CommunityUsersOpts, GetAllCommunityUsersQuery } from '@/gql/graphql.js' import type { Ref } from 'vue' @@ -11,14 +11,14 @@ export type CommunityUser = GetAllCommunityUsersQuery['communityUsers']['users'] const invalidationKey = 'CommunityInvalidateKey' -export const useCommunityUsersApi = defineStore('api/community-users', () => { +export const useCommunityUsersApi = createGlobalState(() => { const useCommunityUsers = (variables: Ref) => useQuery({ context: { - additionalTypenames: [invalidationKey] + additionalTypenames: [invalidationKey], }, get variables() { return { - opts: variables.value + opts: variables.value, } }, query: graphql(` @@ -39,7 +39,7 @@ export const useCommunityUsersApi = defineStore('api/community-users', () => { } } } - `) + `), }) const useMutationCommunityReset = () => useMutation(graphql(` @@ -50,6 +50,6 @@ export const useCommunityUsersApi = defineStore('api/community-users', () => { return { useCommunityUsers, - useMutationCommunityReset + useMutationCommunityReset, } }) diff --git a/frontend/dashboard/src/api/games/games.ts b/frontend/dashboard/src/api/games/games.ts index ca394e7ff..9834558fd 100644 --- a/frontend/dashboard/src/api/games/games.ts +++ b/frontend/dashboard/src/api/games/games.ts @@ -1,12 +1,12 @@ import { useQuery } from '@urql/vue' -import { defineStore } from 'pinia' +import { createGlobalState } from '@vueuse/core' import { useMutation } from '@/composables/use-mutation' import { graphql } from '@/gql' const gamesInvalidationKey = 'gamesInvalidationKey' -export const useGamesApi = defineStore('games/8ball', () => { +export const useGamesApi = createGlobalState(() => { const useGamesQuery = () => useQuery({ query: graphql(` query Games { @@ -42,8 +42,8 @@ export const useGamesApi = defineStore('games/8ball', () => { `), variables: {}, context: { - additionalTypenames: [gamesInvalidationKey] - } + additionalTypenames: [gamesInvalidationKey], + }, }) const useEightBallMutation = () => useMutation( @@ -55,7 +55,7 @@ export const useGamesApi = defineStore('games/8ball', () => { } } `), - [gamesInvalidationKey] + [gamesInvalidationKey], ) const useDuelMutation = () => useMutation( @@ -66,7 +66,7 @@ export const useGamesApi = defineStore('games/8ball', () => { } } `), - [gamesInvalidationKey] + [gamesInvalidationKey], ) const useRussianRouletteMutation = () => useMutation( @@ -77,13 +77,13 @@ export const useGamesApi = defineStore('games/8ball', () => { } } `), - [gamesInvalidationKey] + [gamesInvalidationKey], ) return { useGamesQuery, useEightBallMutation, useDuelMutation, - useRussianRouletteMutation + useRussianRouletteMutation, } }) diff --git a/frontend/dashboard/src/api/greetings.ts b/frontend/dashboard/src/api/greetings.ts index 28b218520..eabccad7c 100644 --- a/frontend/dashboard/src/api/greetings.ts +++ b/frontend/dashboard/src/api/greetings.ts @@ -1,5 +1,5 @@ import { useQuery } from '@urql/vue' -import { defineStore } from 'pinia' +import { createGlobalState } from '@vueuse/core' import type { GetAllGreetingsQuery } from '@/gql/graphql.js' @@ -10,7 +10,7 @@ export type Greetings = GetAllGreetingsQuery['greetings'][0] const invalidationKey = 'GreetingsInvalidateKey' -export const useGreetingsApi = defineStore('api/greetings', () => { +export const useGreetingsApi = createGlobalState(() => { const useQueryGreetings = () => useQuery({ variables: {}, context: { additionalTypenames: [invalidationKey] }, diff --git a/frontend/dashboard/src/api/keywords.ts b/frontend/dashboard/src/api/keywords.ts index d5bc7d1a2..decc6bba8 100644 --- a/frontend/dashboard/src/api/keywords.ts +++ b/frontend/dashboard/src/api/keywords.ts @@ -1,5 +1,5 @@ import { useQuery } from '@urql/vue' -import { defineStore } from 'pinia' +import { createGlobalState } from '@vueuse/core' import type { GetAllKeywordsQuery } from '@/gql/graphql.js' @@ -14,7 +14,7 @@ export type Keyword = Omit & { const invalidateKey = 'KeywordsInvalidateKey' -export const useKeywordsApi = defineStore('api/keywords', () => { +export const useKeywordsApi = createGlobalState(() => { const useQueryKeywords = () => useQuery({ variables: {}, context: { additionalTypenames: [invalidateKey] }, @@ -31,7 +31,7 @@ export const useKeywordsApi = defineStore('api/keywords', () => { usageCount } } - `) + `), }) const useMutationCreateKeyword = () => useMutation(graphql(` @@ -60,6 +60,6 @@ export const useKeywordsApi = defineStore('api/keywords', () => { useQueryKeywords, useMutationCreateKeyword, useMutationUpdateKeyword, - useMutationRemoveKeyword + useMutationRemoveKeyword, } }) diff --git a/frontend/dashboard/src/api/roles.ts b/frontend/dashboard/src/api/roles.ts index 09e04b658..6ffda2c3d 100644 --- a/frontend/dashboard/src/api/roles.ts +++ b/frontend/dashboard/src/api/roles.ts @@ -1,12 +1,12 @@ import { useQuery } from '@urql/vue' -import { defineStore } from 'pinia' +import { createGlobalState } from '@vueuse/core' import { useMutation } from '@/composables/use-mutation' import { graphql } from '@/gql' const rolesInvalidateKey = 'rolesInvalidateKey' -export const useRoles = defineStore('api/channelRoles', () => { +export const useRoles = createGlobalState(() => { const useRolesQuery = () => useQuery({ query: graphql(` query ChannelRoles { @@ -31,8 +31,8 @@ export const useRoles = defineStore('api/channelRoles', () => { `), variables: {}, context: { - additionalTypenames: [rolesInvalidateKey] - } + additionalTypenames: [rolesInvalidateKey], + }, }) const useRolesDeleteMutation = () => useMutation( @@ -41,7 +41,7 @@ export const useRoles = defineStore('api/channelRoles', () => { rolesRemove(id: $id) } `), - [rolesInvalidateKey] + [rolesInvalidateKey], ) const useRolesCreateMutation = () => useMutation( @@ -50,7 +50,7 @@ export const useRoles = defineStore('api/channelRoles', () => { rolesCreate(opts: $opts) } `), - [rolesInvalidateKey] + [rolesInvalidateKey], ) const useRolesUpdateMutation = () => useMutation( @@ -59,13 +59,13 @@ export const useRoles = defineStore('api/channelRoles', () => { rolesUpdate(id: $id, opts: $opts) } `), - [rolesInvalidateKey] + [rolesInvalidateKey], ) return { useRolesQuery, useRolesDeleteMutation, useRolesCreateMutation, - useRolesUpdateMutation + useRolesUpdateMutation, } }) diff --git a/frontend/dashboard/src/api/timers.ts b/frontend/dashboard/src/api/timers.ts index 377529969..625937269 100644 --- a/frontend/dashboard/src/api/timers.ts +++ b/frontend/dashboard/src/api/timers.ts @@ -1,5 +1,5 @@ import { useQuery } from '@urql/vue' -import { defineStore } from 'pinia' +import { createGlobalState } from '@vueuse/core' import type { GetAllTimersQuery, TimerCreateInput } from '@/gql/graphql.js' @@ -11,7 +11,7 @@ export type EditableTimer = TimerCreateInput & { id?: string } const invalidationKey = 'TimersInvalidateKey' -export const useTimersApi = defineStore('api/timers', () => { +export const useTimersApi = createGlobalState(() => { const useQueryTimers = () => useQuery({ variables: {}, context: { additionalTypenames: [invalidationKey] }, @@ -29,7 +29,7 @@ export const useTimersApi = defineStore('api/timers', () => { } } } - `) + `), }) const useMutationCreateTimer = () => useMutation(graphql(` @@ -58,6 +58,6 @@ export const useTimersApi = defineStore('api/timers', () => { useQueryTimers, useMutationCreateTimer, useMutationUpdateTimer, - useMutationRemoveTimer + useMutationRemoveTimer, } }) diff --git a/frontend/dashboard/src/api/variables.ts b/frontend/dashboard/src/api/variables.ts index a4c9eaf01..1e03df7b8 100644 --- a/frontend/dashboard/src/api/variables.ts +++ b/frontend/dashboard/src/api/variables.ts @@ -1,5 +1,5 @@ import { useQuery } from '@urql/vue' -import { defineStore } from 'pinia' +import { createGlobalState } from '@vueuse/core' import { computed } from 'vue' import type { GetCustomAndBuiltInVariablesQuery } from '@/gql/graphql.js' @@ -14,7 +14,7 @@ const invalidationKey = 'VariablesInvalidateKey' export type CustomVariable = GetCustomAndBuiltInVariablesQuery['variables'][number] export type EditableCustomVariable = SetOptional -export const useVariablesApi = defineStore('api/variables', () => { +export const useVariablesApi = createGlobalState(() => { const variablesQuery = useQuery({ variables: {}, context: { additionalTypenames: [invalidationKey] }, @@ -36,7 +36,7 @@ export const useVariablesApi = defineStore('api/variables', () => { canBeUsedInRegistry } } - `) + `), }) const customVariables = computed(() => { @@ -50,7 +50,7 @@ export const useVariablesApi = defineStore('api/variables', () => { canBeUsedInRegistry: variable.type !== VariableType.Script, type: variable.type, response: variable.response, - evalValue: variable.evalValue + evalValue: variable.evalValue, })) ?? [] return mapped @@ -63,7 +63,7 @@ export const useVariablesApi = defineStore('api/variables', () => { visible: variable.visible, example: variable.example || `${variable.name}`, isBuiltIn: true, - canBeUsedInRegistry: variable.canBeUsedInRegistry + canBeUsedInRegistry: variable.canBeUsedInRegistry, })) ?? [] return mapped @@ -72,7 +72,7 @@ export const useVariablesApi = defineStore('api/variables', () => { const allVariables = computed(() => { return [ ...customVariables.value, - ...builtInVariables.value + ...builtInVariables.value, ] }) @@ -109,6 +109,6 @@ export const useVariablesApi = defineStore('api/variables', () => { isLoading, useMutationCreateVariable, useMutationUpdateVariable, - useMutationRemoveVariable + useMutationRemoveVariable, } }) diff --git a/frontend/dashboard/src/components/alerts/modal.vue b/frontend/dashboard/src/components/alerts/modal.vue index 259c90c03..3956a5628 100644 --- a/frontend/dashboard/src/components/alerts/modal.vue +++ b/frontend/dashboard/src/components/alerts/modal.vue @@ -12,9 +12,8 @@ import { NModal, NSelect, NSlider, - NSpace + NSpace, } from 'naive-ui' -import { storeToRefs } from 'pinia' import { computed, onMounted, ref, toRaw } from 'vue' import { useI18n } from 'vue-i18n' @@ -26,7 +25,7 @@ import { useAlertsManager, useFiles, useProfile, - useTwitchGetUsers + useTwitchGetUsers, } from '@/api' import { useCommandsApi } from '@/api/commands/commands' import { useGreetingsApi } from '@/api/greetings' @@ -50,7 +49,7 @@ const formValue = ref({ commandIds: [], rewardIds: [], greetingsIds: [], - keywordsIds: [] + keywordsIds: [], }) onMounted(() => { @@ -69,8 +68,8 @@ const rules: FormRules = { } return true - } - } + }, + }, } const manager = useAlertsManager() @@ -86,7 +85,7 @@ async function save() { if (data.id) { await updater.mutateAsync({ ...data, - id: data.id! + id: data.id!, }) } else { await creator.mutateAsync(data) @@ -99,14 +98,14 @@ const { data: files } = useFiles() const selectedAudio = computed(() => files.value?.files.find(f => f.id === formValue.value.audioId)) const showAudioModal = ref(false) -const { data: profile } = storeToRefs(useProfile()) +const { data: profile } = useProfile() async function testAudio() { if (!selectedAudio.value?.id || !profile.value) return const query = new URLSearchParams({ channel_id: profile.value.selectedDashboardId, - file_id: selectedAudio.value.id + file_id: selectedAudio.value.id, }) const req = await fetch(`${window.location.origin}/api-old/files/?${query}`) @@ -121,7 +120,7 @@ async function testAudio() { const commandsManager = useCommandsApi() const { data: commands } = commandsManager.useQueryCommands() const commandsSelectOptions = computed(() => commands.value?.commands - .map((command) => ({ label: command.name, value: command.id })) + .map((command) => ({ label: command.name, value: command.id })), ) const greetingsManager = useGreetingsApi() @@ -139,7 +138,7 @@ const greetingsSelectOptions = computed(() => { const keywordsManager = useKeywordsApi() const { data: keywords } = keywordsManager.useQueryKeywords() const keywordsSelectOptions = computed(() => keywords.value?.keywords - .map(k => ({ label: k.text, value: k.id })) + .map(k => ({ label: k.text, value: k.id })), ) diff --git a/frontend/dashboard/src/components/dashboard/chat.vue b/frontend/dashboard/src/components/dashboard/chat.vue index b1b540cb9..f3451dc70 100644 --- a/frontend/dashboard/src/components/dashboard/chat.vue +++ b/frontend/dashboard/src/components/dashboard/chat.vue @@ -1,44 +1,42 @@ diff --git a/frontend/dashboard/src/components/dashboard/stream.vue b/frontend/dashboard/src/components/dashboard/stream.vue index 193b7613f..e3a76878f 100644 --- a/frontend/dashboard/src/components/dashboard/stream.vue +++ b/frontend/dashboard/src/components/dashboard/stream.vue @@ -1,29 +1,27 @@ diff --git a/frontend/dashboard/src/components/events/modal.vue b/frontend/dashboard/src/components/events/modal.vue index af2909cc2..2491dab59 100644 --- a/frontend/dashboard/src/components/events/modal.vue +++ b/frontend/dashboard/src/components/events/modal.vue @@ -1,208 +1,205 @@ diff --git a/frontend/dashboard/src/components/integrations/discord.vue b/frontend/dashboard/src/components/integrations/discord.vue index 62d311943..0088e8f92 100644 --- a/frontend/dashboard/src/components/integrations/discord.vue +++ b/frontend/dashboard/src/components/integrations/discord.vue @@ -1,134 +1,134 @@