mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-07-06 20:42:15 +02:00
Fix logic around transitions back to draft mode from live mode
This commit is contained in:
parent
c46468be90
commit
00e72daefc
1 changed files with 4 additions and 30 deletions
|
|
@ -61,7 +61,7 @@ interface StateItem {
|
||||||
chatKey: number;
|
chatKey: number;
|
||||||
lastUpdatedAt: string;
|
lastUpdatedAt: string;
|
||||||
isLive: boolean;
|
isLive: boolean;
|
||||||
showWorkflowChangeBanner: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
|
|
@ -260,12 +260,7 @@ function reducer(state: State, action: Action): State {
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "clear_workflow_change_banner": {
|
|
||||||
newState = produce(state, draft => {
|
|
||||||
draft.present.showWorkflowChangeBanner = false;
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "set_saving": {
|
case "set_saving": {
|
||||||
newState = produce(state, draft => {
|
newState = produce(state, draft => {
|
||||||
draft.present.saving = action.saving;
|
draft.present.saving = action.saving;
|
||||||
|
|
@ -335,7 +330,7 @@ function reducer(state: State, action: Action): State {
|
||||||
// If this is a workflow modification in live mode, switch to draft
|
// If this is a workflow modification in live mode, switch to draft
|
||||||
if (isWorkflowModification && isLive) {
|
if (isWorkflowModification && isLive) {
|
||||||
draft.isLive = false;
|
draft.isLive = false;
|
||||||
draft.showWorkflowChangeBanner = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
|
@ -949,7 +944,7 @@ export function WorkflowEditor({
|
||||||
chatKey: 0,
|
chatKey: 0,
|
||||||
lastUpdatedAt: workflow.lastUpdatedAt,
|
lastUpdatedAt: workflow.lastUpdatedAt,
|
||||||
isLive,
|
isLive,
|
||||||
showWorkflowChangeBanner: false,
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1034,27 +1029,6 @@ export function WorkflowEditor({
|
||||||
}
|
}
|
||||||
}, [isLive]);
|
}, [isLive]);
|
||||||
|
|
||||||
// If reducer switched to draft (internal flag) while outer prop is still live,
|
|
||||||
// trigger external mode change and show banner. Guard against publish in-flight.
|
|
||||||
useEffect(() => {
|
|
||||||
if (isLive && state.present.isLive === false && !state.present.publishing) {
|
|
||||||
onChangeMode('draft');
|
|
||||||
setShowBuildModeBanner(true);
|
|
||||||
setTimeout(() => setShowBuildModeBanner(false), 5000);
|
|
||||||
}
|
|
||||||
}, [isLive, state.present.isLive, state.present.publishing, onChangeMode]);
|
|
||||||
|
|
||||||
// Show banner when switching from live to draft due to workflow changes
|
|
||||||
useEffect(() => {
|
|
||||||
if (state.present.showWorkflowChangeBanner) {
|
|
||||||
setShowBuildModeBanner(true);
|
|
||||||
// Auto-hide banner after 5 seconds
|
|
||||||
setTimeout(() => setShowBuildModeBanner(false), 5000);
|
|
||||||
// Clear the flag
|
|
||||||
dispatch({ type: "clear_workflow_change_banner" });
|
|
||||||
}
|
|
||||||
}, [state.present.showWorkflowChangeBanner]);
|
|
||||||
|
|
||||||
// Reset initial state when user interacts with copilot or opens other menus
|
// Reset initial state when user interacts with copilot or opens other menus
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (state.present.selection !== null) {
|
if (state.present.selection !== null) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue