mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-07-18 21:21:11 +02:00
make workflow mode sticky across navigation
This commit is contained in:
parent
b3bd89a478
commit
af0fcce127
1 changed files with 10 additions and 1 deletions
|
|
@ -32,7 +32,11 @@ export function App({
|
||||||
defaultModel: string;
|
defaultModel: string;
|
||||||
chatWidgetHost: string;
|
chatWidgetHost: string;
|
||||||
}) {
|
}) {
|
||||||
const [mode, setMode] = useState<'draft' | 'live'>('draft');
|
const [mode, setMode] = useState<'draft' | 'live'>(() => {
|
||||||
|
if (typeof window === 'undefined') return 'draft';
|
||||||
|
const stored = window.localStorage.getItem(`workflow_mode_${initialProjectData.id}`);
|
||||||
|
return stored === 'live' || stored === 'draft' ? stored : 'draft';
|
||||||
|
});
|
||||||
const [project, setProject] = useState<z.infer<typeof Project>>(initialProjectData);
|
const [project, setProject] = useState<z.infer<typeof Project>>(initialProjectData);
|
||||||
const [dataSources, setDataSources] = useState<z.infer<typeof DataSource>[]>(initialDataSources);
|
const [dataSources, setDataSources] = useState<z.infer<typeof DataSource>[]>(initialDataSources);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
@ -101,6 +105,11 @@ export function App({
|
||||||
}, [dataSources, initialProjectData.id]);
|
}, [dataSources, initialProjectData.id]);
|
||||||
|
|
||||||
function handleSetMode(mode: 'draft' | 'live') {
|
function handleSetMode(mode: 'draft' | 'live') {
|
||||||
|
try {
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
window.localStorage.setItem(`workflow_mode_${initialProjectData.id}`, mode);
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
setMode(mode);
|
setMode(mode);
|
||||||
// Reload data to ensure we have the latest workflow data for the current mode
|
// Reload data to ensure we have the latest workflow data for the current mode
|
||||||
reloadData();
|
reloadData();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue