MCPcopy
hub / github.com/callumalpass/tasknotes / close

Method close

src/modals/TaskEditModal.ts:276–301  ·  view source on GitHub ↗

* Override close() to detect unsaved changes and prompt user. * This method is synchronous to match Obsidian's Modal.close() signature.

()

Source from the content-addressed store, hash-verified

274 * This method is synchronous to match Obsidian's Modal.close() signature.
275 */
276 close(): void {
277 // If we're already forcing close or showing confirmation, proceed
278 if (this.pendingClose) {
279 this.pendingClose = false;
280 super.close();
281 return;
282 }
283
284 // Prevent re-entrancy if confirmation is already showing
285 if (this.isShowingConfirmation) {
286 return;
287 }
288
289 // Check for unsaved changes
290 const changes = this.getChanges();
291 const hasChanges = Object.keys(changes).length > 0;
292
293 if (!hasChanges) {
294 // No changes, close immediately
295 super.close();
296 return;
297 }
298
299 // Show confirmation modal asynchronously
300 void this.showUnsavedChangesConfirmation();
301 }
302
303 /**
304 * Show confirmation modal for unsaved changes.

Callers 4

handleSaveMethod · 0.95
openTaskNoteMethod · 0.95
archiveTaskMethod · 0.95
createActionButtonsMethod · 0.95

Calls 3

getChangesMethod · 0.95
closeMethod · 0.65

Tested by

no test coverage detected