mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-13 20:15:04 -05:00
refactor(ui): make workflow published status server-side state
Whether a workflow is published or not shouldn't be something stored on the client. It's properly server-side state. This change removes the `is_published` flag from redux and updates all references to the flag to use the getWorkflow query. It also updates the socket event listener that handles session complete events. When a validation run completes, we invalidate the tags for the getWorkflow query. We need to do a bit of juggling to avoid a race condition (documented in the code). Works well though.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { MenuItem } from '@invoke-ai/ui-library';
|
||||
import { useAppSelector } from 'app/store/storeHooks';
|
||||
import { useDoesWorkflowHaveUnsavedChanges } from 'features/nodes/components/sidePanel/workflow/IsolatedWorkflowBuilderWatcher';
|
||||
import { selectWorkflowIsPublished } from 'features/nodes/store/workflowSlice';
|
||||
import { useIsWorkflowPublished } from 'features/nodes/components/sidePanel/workflow/publish';
|
||||
import { useSaveOrSaveAsWorkflow } from 'features/workflowLibrary/hooks/useSaveOrSaveAsWorkflow';
|
||||
import { memo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@@ -11,7 +10,7 @@ const SaveWorkflowMenuItem = () => {
|
||||
const { t } = useTranslation();
|
||||
const saveOrSaveAsWorkflow = useSaveOrSaveAsWorkflow();
|
||||
const doesWorkflowHaveUnsavedChanges = useDoesWorkflowHaveUnsavedChanges();
|
||||
const isPublished = useAppSelector(selectWorkflowIsPublished);
|
||||
const isPublished = useIsWorkflowPublished();
|
||||
|
||||
return (
|
||||
<MenuItem
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
formFieldInitialValuesChanged,
|
||||
workflowCategoryChanged,
|
||||
workflowIDChanged,
|
||||
workflowIsPublishedChanged,
|
||||
workflowNameChanged,
|
||||
} from 'features/nodes/store/workflowSlice';
|
||||
import type { WorkflowV3 } from 'features/nodes/types/workflow';
|
||||
@@ -65,7 +64,6 @@ export const useCreateLibraryWorkflow = (): CreateLibraryWorkflowReturn => {
|
||||
meta: { category },
|
||||
} = data.workflow;
|
||||
dispatch(workflowIDChanged(id));
|
||||
dispatch(workflowIsPublishedChanged(false));
|
||||
dispatch(workflowNameChanged(name));
|
||||
dispatch(workflowCategoryChanged(category));
|
||||
dispatch(newWorkflowSaved({ category }));
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { useAppSelector } from 'app/store/storeHooks';
|
||||
import { selectWorkflowIsPublished } from 'features/nodes/store/workflowSlice';
|
||||
import { useIsWorkflowPublished } from 'features/nodes/components/sidePanel/workflow/publish';
|
||||
import { useBuildWorkflowFast } from 'features/nodes/util/workflow/buildWorkflow';
|
||||
import { saveWorkflowAs } from 'features/workflowLibrary/components/SaveWorkflowAsDialog';
|
||||
import { isLibraryWorkflow, useSaveLibraryWorkflow } from 'features/workflowLibrary/hooks/useSaveLibraryWorkflow';
|
||||
@@ -12,7 +11,7 @@ import { useCallback } from 'react';
|
||||
*/
|
||||
export const useSaveOrSaveAsWorkflow = () => {
|
||||
const buildWorkflow = useBuildWorkflowFast();
|
||||
const isPublished = useAppSelector(selectWorkflowIsPublished);
|
||||
const isPublished = useIsWorkflowPublished();
|
||||
const { saveWorkflow } = useSaveLibraryWorkflow();
|
||||
|
||||
const saveOrSaveAsWorkflow = useCallback(() => {
|
||||
|
||||
Reference in New Issue
Block a user