From 2476c1e86806696a71240201b82c5a2631662092 Mon Sep 17 00:00:00 2001 From: James Allen Date: Wed, 18 Nov 2015 15:23:23 +0000 Subject: [PATCH] Report unsaved changes after 60 seconds --- .../controllers/SavingNotificationController.coffee | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/web/public/coffee/ide/editor/controllers/SavingNotificationController.coffee b/services/web/public/coffee/ide/editor/controllers/SavingNotificationController.coffee index f9c68ca05f..0bffb60204 100644 --- a/services/web/public/coffee/ide/editor/controllers/SavingNotificationController.coffee +++ b/services/web/public/coffee/ide/editor/controllers/SavingNotificationController.coffee @@ -24,6 +24,8 @@ define [ if oldStatus[doc_id]? newStatus[doc_id] = oldStatus[doc_id] newStatus[doc_id].unsavedSeconds += 1 + if newStatus[doc_id].unsavedSeconds == 60 + reportUnsavedChanges(doc) else newStatus[doc_id] = { unsavedSeconds: 0 @@ -39,6 +41,12 @@ define [ $scope.docSavingStatusCount = newUnsavedCount $scope.$apply() + reportUnsavedChanges = (doc) -> + ide.reportError new Error("unsaved changes"), { + inflightOp: doc?.getInflightOp(), + pendingOp: doc?.getPendingOp() + } + warnAboutUnsavedChanges = () -> if Document.hasUnsavedChanges() return "You have unsaved changes. If you leave now they will not be saved."