Skip to content

Commit c221dbc

Browse files
committed
Fix Restore Project bug that prevents backing up project in filesystem with PWV
1 parent e1d14da commit c221dbc

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

public/pwv.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
// backup_project: (async () => {}),
1010
// restore_project: (async () => ""),
1111
// run_project: (async () => {}),
12+
// log: (async () => {}),
1213
// }
1314
// }

src/contexts/appData.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,12 @@ const createAppDataContext = () => {
176176

177177
const existingId = await loadExistingId();
178178
setProjectId(existingId);
179+
179180
if (isDesktop()) {
180181
const restoredProject = await getRestoredProject();
181-
saveData(`p:${existingId}`, restoredProject);
182+
if (restoredProject) {
183+
saveData(`p:${existingId}`, restoredProject);
184+
}
182185
}
183186

184187
await loadProject(

src/defs/PyWebview.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface PyWebview {
1212
backup_project: (content: string) => Promise<boolean>;
1313
restore_project: () => Promise<string>;
1414
run_project: (script: string) => Promise<void>;
15+
log: (message: string) => Promise<void>;
1516
}
1617
}
1718

src/utils/desktopTools.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ const setupDesktopTools = () => {
117117
return getApi()!.run_project(script);
118118
}
119119

120+
const log = async (message: string): Promise<void> => {
121+
if (!isDesktop()) return;
122+
await waitForPWV();
123+
return getApi()!.log(message);
124+
}
125+
120126
return {
121127
isDesktop,
122128
closeWindow,
@@ -127,6 +133,7 @@ const setupDesktopTools = () => {
127133
backupProject,
128134
getRestoredProject,
129135
runProject,
136+
log,
130137
}
131138
};
132139

@@ -140,5 +147,6 @@ export const {
140147
backupProject,
141148
getRestoredProject,
142149
runProject,
150+
log,
143151
} = setupDesktopTools();
144152

0 commit comments

Comments
 (0)