fix(tabsContext.tsx): add optional 'silent' parameter to the saveFlow function to control whether to show success message or not
fix(PageComponent/index.tsx): pass 'true' as the second argument to the saveFlow function to prevent showing success message when saving flow every 30 seconds fix(types/tabs/index.ts): update the saveFlow function signature to include the optional 'silent' parameter
This commit is contained in:
parent
1b3564ed3d
commit
6fd2b0c743
3 changed files with 7 additions and 5 deletions
|
|
@ -52,7 +52,7 @@ const TabsContextInitialValue: TabsContextType = {
|
||||||
isBuilt: false,
|
isBuilt: false,
|
||||||
setIsBuilt: (state: boolean) => {},
|
setIsBuilt: (state: boolean) => {},
|
||||||
hardReset: () => {},
|
hardReset: () => {},
|
||||||
saveFlow: async (flow: FlowType) => {},
|
saveFlow: async (flow: FlowType, silent?: boolean) => {},
|
||||||
lastCopiedSelection: null,
|
lastCopiedSelection: null,
|
||||||
setLastCopiedSelection: (selection: any) => {},
|
setLastCopiedSelection: (selection: any) => {},
|
||||||
tabsState: {},
|
tabsState: {},
|
||||||
|
|
@ -588,13 +588,15 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveFlow(newFlow: FlowType) {
|
async function saveFlow(newFlow: FlowType, silent?: boolean) {
|
||||||
try {
|
try {
|
||||||
// updates flow in db
|
// updates flow in db
|
||||||
const updatedFlow = await updateFlowInDatabase(newFlow);
|
const updatedFlow = await updateFlowInDatabase(newFlow);
|
||||||
if (updatedFlow) {
|
if (updatedFlow) {
|
||||||
// updates flow in state
|
// updates flow in state
|
||||||
|
if (!silent) {
|
||||||
setSuccessData({ title: "Changes saved successfully" });
|
setSuccessData({ title: "Changes saved successfully" });
|
||||||
|
}
|
||||||
setFlows((prevState) => {
|
setFlows((prevState) => {
|
||||||
const newFlows = [...prevState];
|
const newFlows = [...prevState];
|
||||||
const index = newFlows.findIndex((flow) => flow.id === newFlow.id);
|
const index = newFlows.findIndex((flow) => flow.id === newFlow.id);
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ export default function Page({
|
||||||
let updatedSeconds = prevSeconds + 1;
|
let updatedSeconds = prevSeconds + 1;
|
||||||
|
|
||||||
if (updatedSeconds % 30 === 0) {
|
if (updatedSeconds % 30 === 0) {
|
||||||
saveFlow(flow);
|
saveFlow(flow, true);
|
||||||
updatedSeconds = 0;
|
updatedSeconds = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { tweakType } from "../components";
|
||||||
import { FlowType } from "../flow";
|
import { FlowType } from "../flow";
|
||||||
|
|
||||||
export type TabsContextType = {
|
export type TabsContextType = {
|
||||||
saveFlow: (flow: FlowType) => Promise<void>;
|
saveFlow: (flow: FlowType, silent?: boolean) => Promise<void>;
|
||||||
save: () => void;
|
save: () => void;
|
||||||
tabId: string;
|
tabId: string;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue