Skip to content

Commit ea86f33

Browse files
committed
fix: wrap database deletion in an async IIFE for proper execution flow
1 parent d24e1f5 commit ea86f33

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/components/Terminal.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,16 @@ const Terminal = forwardRef<TerminalHandle, TerminalProps>(
103103
writePrompt();
104104
} else if (cmd === 'reset') {
105105
term.writeln('\x1b[33mClearing room data...\x1b[0m');
106-
const dbNames = await indexedDB.databases?.() ?? [];
107-
for (const db of dbNames) {
108-
if (db.name && db.name.startsWith('collab-code-')) {
109-
indexedDB.deleteDatabase(db.name);
106+
(async () => {
107+
const dbNames = await indexedDB.databases?.() ?? [];
108+
for (const db of dbNames) {
109+
if (db.name && db.name.startsWith('collab-code-')) {
110+
indexedDB.deleteDatabase(db.name);
111+
}
110112
}
111-
}
112-
term.writeln('\x1b[32mDone. Reloading...\x1b[0m');
113-
setTimeout(() => window.location.reload(), 500);
113+
term.writeln('\x1b[32mDone. Reloading...\x1b[0m');
114+
setTimeout(() => window.location.reload(), 500);
115+
})();
114116
} else if (cmd === 'help') {
115117
term.writeln(' \x1b[1;32mrun\x1b[0m — compile & execute Java');
116118
term.writeln(' \x1b[1;32mclear\x1b[0m — clear terminal');

0 commit comments

Comments
 (0)