@@ -154,20 +154,15 @@ export async function loadDatabase(dbData: Uint8Array<ArrayBufferLike>, useSplas
154154 } , { once : true } ) ;
155155 } ) ;
156156
157- //currentField.set(FieldType.TetrisEdit);
158157 currentWindow . set ( WindowType . Splash ) ;
159158 currentFieldIndex . set ( - 1 ) ;
160159
161160 await waitForTransition ;
162161
163162 const firstFieldResult = getLatestFieldId ( ) ! ;
164- //if (firstFieldResult) {
165163 currentFieldIndex . set ( firstFieldResult ) ;
166164 currentWindow . set ( originalWindow ) ;
167165 WindowFadeDuration . set ( 300 ) ;
168- //}
169-
170-
171166 } else {
172167 currentFieldIndex . set ( - 1 ) ;
173168 const firstFieldResult = getLatestFieldId ( ) ;
@@ -218,7 +213,7 @@ export function createNodeDatabase(updateNode: DatabaseNode): number {
218213
219214
220215
221- export function deleteNodeDatabase ( node : DatabaseNode ) {
216+ export async function deleteNodeDatabase ( node : DatabaseNode ) {
222217 if ( ! db ) {
223218 throw new Error ( "Database is not initialized." ) ;
224219 }
@@ -229,12 +224,28 @@ export function deleteNodeDatabase(node: DatabaseNode) {
229224
230225 node . deleteNode ( db ) ;
231226
227+ if ( node . id === get ( currentFieldIndex ) ) {
228+ const originalWindow = get ( currentWindow ) ;
232229
230+ const waitForTransition = new Promise < void > ( ( resolve ) => {
231+ document . addEventListener ( "onWindowTransitionEnd" , async ( ) => {
232+ await new Promise ( resolve => setTimeout ( resolve , 100 ) ) ;
233+ resolve ( ) ;
234+ } , { once : true } ) ;
235+ } ) ;
233236
234- const firstFieldResult = getLatestFieldId ( ) ;
235- if ( firstFieldResult ) {
237+ currentWindow . set ( WindowType . Splash ) ;
238+ currentFieldIndex . set ( - 1 ) ;
239+
240+ await waitForTransition ;
241+
242+ const firstFieldResult = getLatestFieldId ( ) ! ;
236243 currentFieldIndex . set ( firstFieldResult ) ;
244+ currentWindow . set ( originalWindow ) ;
245+ WindowFadeDuration . set ( 300 ) ;
237246 }
247+
248+
238249}
239250
240251export function getNodeDatabase ( id : number ) : DatabaseNode | null {
0 commit comments