Skip to content

Commit 786d713

Browse files
committed
refactor: convert managerStateStore to composable
- Move managerStateStore from store to composable pattern - All functions are non-reactive utilities that don't need state management - Follows Pinia guideline: "If it's not reactive, it shouldn't be in a store" - Update all import paths across 8 files - Move and update test file accordingly This change improves architecture consistency as other utility functions in the codebase also use composables rather than stores when reactivity is not required.
1 parent bfcc77b commit 786d713

File tree

8 files changed

+58
-69
lines changed

8 files changed

+58
-69
lines changed

src/components/dialog/content/LoadWorkflowWarning.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ import { computed } from 'vue'
5858
import NoResultsPlaceholder from '@/components/common/NoResultsPlaceholder.vue'
5959
import MissingCoreNodesMessage from '@/components/dialog/content/MissingCoreNodesMessage.vue'
6060
import { useMissingNodes } from '@/composables/nodePack/useMissingNodes'
61+
import { useManagerState } from '@/composables/useManagerState'
6162
import { useComfyManagerStore } from '@/stores/comfyManagerStore'
62-
import { useManagerStateStore } from '@/stores/managerStateStore'
6363
import type { MissingNodeType } from '@/types/comfy'
6464
import { ManagerTab } from '@/types/comfyManagerTypes'
6565
@@ -74,6 +74,7 @@ const { missingNodePacks, isLoading, error, missingCoreNodes } =
7474
useMissingNodes()
7575
7676
const comfyManagerStore = useComfyManagerStore()
77+
const managerState = useManagerState()
7778
7879
// Check if any of the missing packs are currently being installed
7980
const isInstalling = computed(() => {
@@ -104,20 +105,18 @@ const uniqueNodes = computed(() => {
104105
})
105106
})
106107
107-
const managerStateStore = useManagerStateStore()
108-
109108
// Show manager buttons unless manager is disabled
110109
const showManagerButtons = computed(() => {
111-
return managerStateStore.shouldShowManagerButtons()
110+
return managerState.shouldShowManagerButtons()
112111
})
113112
114113
// Only show Install All button for NEW_UI (new manager with v4 support)
115114
const showInstallAllButton = computed(() => {
116-
return managerStateStore.shouldShowInstallButton()
115+
return managerState.shouldShowInstallButton()
117116
})
118117
119118
const openManager = async () => {
120-
await managerStateStore.openManager({
119+
await managerState.openManager({
121120
initialTab: ManagerTab.Missing,
122121
showToastOnLegacyError: true
123122
})

src/components/helpcenter/HelpCenterMenuContent.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ import { useI18n } from 'vue-i18n'
142142
143143
import PuzzleIcon from '@/components/icons/PuzzleIcon.vue'
144144
import { useConflictAcknowledgment } from '@/composables/useConflictAcknowledgment'
145+
import { useManagerState } from '@/composables/useManagerState'
145146
import { type ReleaseNote } from '@/services/releaseService'
146147
import { useCommandStore } from '@/stores/commandStore'
147-
import { useManagerStateStore } from '@/stores/managerStateStore'
148148
import { useReleaseStore } from '@/stores/releaseStore'
149149
import { useSettingStore } from '@/stores/settingStore'
150150
import { ManagerTab } from '@/types/comfyManagerTypes'
@@ -314,7 +314,7 @@ const menuItems = computed<MenuItem[]>(() => {
314314
label: t('helpCenter.managerExtension'),
315315
showRedDot: shouldShowManagerRedDot.value,
316316
action: async () => {
317-
await useManagerStateStore().openManager({
317+
await useManagerState().openManager({
318318
initialTab: ManagerTab.All,
319319
showToastOnLegacyError: false
320320
})

src/components/topbar/CommandMenubar.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ import { useI18n } from 'vue-i18n'
106106
import SubgraphBreadcrumb from '@/components/breadcrumb/SubgraphBreadcrumb.vue'
107107
import SettingDialogContent from '@/components/dialog/content/SettingDialogContent.vue'
108108
import SettingDialogHeader from '@/components/dialog/header/SettingDialogHeader.vue'
109+
import { useManagerState } from '@/composables/useManagerState'
109110
import { useCommandStore } from '@/stores/commandStore'
110111
import { useDialogStore } from '@/stores/dialogStore'
111-
import { useManagerStateStore } from '@/stores/managerStateStore'
112112
import { useMenuItemStore } from '@/stores/menuItemStore'
113113
import { useSettingStore } from '@/stores/settingStore'
114114
import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore'
@@ -124,6 +124,8 @@ const dialogStore = useDialogStore()
124124
const settingStore = useSettingStore()
125125
const { t } = useI18n()
126126
127+
const managerState = useManagerState()
128+
127129
const menuRef = ref<
128130
({ dirty: boolean } & TieredMenuMethods & TieredMenuState) | null
129131
>(null)
@@ -156,10 +158,8 @@ const showSettings = (defaultPanel?: string) => {
156158
})
157159
}
158160
159-
const managerStateStore = useManagerStateStore()
160-
161161
const showManageExtensions = async () => {
162-
await managerStateStore.openManager({
162+
await managerState.openManager({
163163
initialTab: ManagerTab.All,
164164
showToastOnLegacyError: false
165165
})

src/composables/useConflictDetection.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { computed, getCurrentInstance, onUnmounted, readonly, ref } from 'vue'
33

44
import { useInstalledPacks } from '@/composables/nodePack/useInstalledPacks'
55
import { useConflictAcknowledgment } from '@/composables/useConflictAcknowledgment'
6+
import { useManagerState } from '@/composables/useManagerState'
67
import config from '@/config'
78
import { useComfyManagerService } from '@/services/comfyManagerService'
89
import { useComfyRegistryService } from '@/services/comfyRegistryService'
910
import { useComfyManagerStore } from '@/stores/comfyManagerStore'
1011
import { useConflictDetectionStore } from '@/stores/conflictDetectionStore'
11-
import { useManagerStateStore } from '@/stores/managerStateStore'
1212
import { useSystemStatsStore } from '@/stores/systemStatsStore'
1313
import type { SystemStats } from '@/types'
1414
import type { components } from '@/types/comfyRegistryTypes'
@@ -638,8 +638,8 @@ export function useConflictDetection() {
638638
async function initializeConflictDetection(): Promise<void> {
639639
try {
640640
// Check if manager is disabled before running conflict detection
641-
const managerStore = useManagerStateStore()
642-
if (!managerStore.isManagerEnabled()) {
641+
const managerState = useManagerState()
642+
if (!managerState.isManagerEnabled()) {
643643
console.log(
644644
'[ConflictDetection] Manager is disabled, skipping conflict detection'
645645
)

src/composables/useCoreCommands.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useFirebaseAuthActions } from '@/composables/auth/useFirebaseAuthActions'
22
import { useSelectedLiteGraphItems } from '@/composables/canvas/useSelectedLiteGraphItems'
3+
import { ManagerUIState, useManagerState } from '@/composables/useManagerState'
34
import { useModelSelectorDialog } from '@/composables/useModelSelectorDialog'
45
import {
56
DEFAULT_DARK_COLOR_PALETTE,
@@ -24,10 +25,6 @@ import { useExecutionStore } from '@/stores/executionStore'
2425
import { useCanvasStore, useTitleEditorStore } from '@/stores/graphStore'
2526
import { useHelpCenterStore } from '@/stores/helpCenterStore'
2627
import { useNodeOutputStore } from '@/stores/imagePreviewStore'
27-
import {
28-
ManagerUIState,
29-
useManagerStateStore
30-
} from '@/stores/managerStateStore'
3128
import { useQueueSettingsStore, useQueueStore } from '@/stores/queueStore'
3229
import { useSettingStore } from '@/stores/settingStore'
3330
import { useSubgraphNavigationStore } from '@/stores/subgraphNavigationStore'
@@ -719,7 +716,7 @@ export function useCoreCommands(): ComfyCommand[] {
719716
label: 'Custom Nodes Manager',
720717
versionAdded: '1.12.10',
721718
function: async () => {
722-
await useManagerStateStore().openManager({
719+
await useManagerState().openManager({
723720
showToastOnLegacyError: true
724721
})
725722
}
@@ -730,8 +727,8 @@ export function useCoreCommands(): ComfyCommand[] {
730727
label: 'Check for Custom Node Updates',
731728
versionAdded: '1.17.0',
732729
function: async () => {
733-
const managerStore = useManagerStateStore()
734-
const state = managerStore.getManagerUIState()
730+
const managerState = useManagerState()
731+
const state = managerState.getManagerUIState()
735732

736733
// For DISABLED state, show error toast instead of opening settings
737734
if (state === ManagerUIState.DISABLED) {
@@ -744,7 +741,7 @@ export function useCoreCommands(): ComfyCommand[] {
744741
return
745742
}
746743

747-
await managerStore.openManager({
744+
await managerState.openManager({
748745
initialTab: ManagerTab.UpdateAvailable,
749746
showToastOnLegacyError: false
750747
})
@@ -756,7 +753,7 @@ export function useCoreCommands(): ComfyCommand[] {
756753
label: 'Install Missing Custom Nodes',
757754
versionAdded: '1.17.0',
758755
function: async () => {
759-
await useManagerStateStore().openManager({
756+
await useManagerState().openManager({
760757
initialTab: ManagerTab.Missing,
761758
showToastOnLegacyError: false
762759
})
@@ -866,7 +863,7 @@ export function useCoreCommands(): ComfyCommand[] {
866863
icon: 'mdi mdi-puzzle-outline',
867864
label: 'Manager',
868865
function: async () => {
869-
await useManagerStateStore().openManager({
866+
await useManagerState().openManager({
870867
initialTab: ManagerTab.All,
871868
showToastOnLegacyError: false
872869
})
@@ -934,7 +931,7 @@ export function useCoreCommands(): ComfyCommand[] {
934931
label: 'Custom Nodes (Legacy)',
935932
versionAdded: '1.16.4',
936933
function: async () => {
937-
await useManagerStateStore().openManager({
934+
await useManagerState().openManager({
938935
legacyCommand: 'Comfy.Manager.CustomNodesManager.ToggleVisibility',
939936
showToastOnLegacyError: true,
940937
isLegacyOnly: true
@@ -947,7 +944,7 @@ export function useCoreCommands(): ComfyCommand[] {
947944
label: 'Manager Menu (Legacy)',
948945
versionAdded: '1.16.4',
949946
function: async () => {
950-
await useManagerStateStore().openManager({
947+
await useManagerState().openManager({
951948
showToastOnLegacyError: true,
952949
isLegacyOnly: true
953950
})
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { defineStore } from 'pinia'
2-
31
import { t } from '@/i18n'
42
import { api } from '@/scripts/api'
53
import { useDialogService } from '@/services/dialogService'
@@ -14,7 +12,7 @@ export enum ManagerUIState {
1412
NEW_UI = 'new'
1513
}
1614

17-
export const useManagerStateStore = defineStore('managerState', () => {
15+
export function useManagerState() {
1816
const systemStatsStore = useSystemStatsStore()
1917

2018
/**
@@ -179,4 +177,4 @@ export const useManagerStateStore = defineStore('managerState', () => {
179177
shouldShowManagerButtons,
180178
openManager
181179
}
182-
})
180+
}

src/services/comfyManagerService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import axios, { AxiosError, AxiosResponse } from 'axios'
22
import { v4 as uuidv4 } from 'uuid'
33
import { ref } from 'vue'
44

5+
import { useManagerState } from '@/composables/useManagerState'
56
import { api } from '@/scripts/api'
6-
import { useManagerStateStore } from '@/stores/managerStateStore'
77
import { components } from '@/types/generatedManagerTypes'
88
import { isAbortError } from '@/utils/typeGuardUtil'
99

@@ -54,8 +54,8 @@ export const useComfyManagerService = () => {
5454

5555
// Check if manager service should be available
5656
const isManagerServiceAvailable = () => {
57-
const managerStore = useManagerStateStore()
58-
return managerStore.isNewManagerUI()
57+
const managerState = useManagerState()
58+
return managerState.isNewManagerUI()
5959
}
6060

6161
const handleRequestError = (

0 commit comments

Comments
 (0)