From 9f2ead1f69fb4ab51ae689589f0851c66c56fdd6 Mon Sep 17 00:00:00 2001 From: Kushagra Gour Date: Sat, 13 Jan 2018 09:58:50 +0530 Subject: [PATCH] script: prevent remote saving on unloadbefore --- src/script.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/script.js b/src/script.js index 7e7e100..fff3cbc 100644 --- a/src/script.js +++ b/src/script.js @@ -423,6 +423,12 @@ loginModal utils.log('saving key', key || currentItem.id, currentItem); saveSetting(key || currentItem.id, currentItem); + // If key is `code`, this is a call on unloadbefore to save the last open thing. + // Do not presist that on remote. + if (key === 'code') { + // No deferred required here as this gets called on unloadbefore + return; + } return itemService.setItem(key || currentItem.id, currentItem).then(() => { alertsService.add('Item saved.'); unsavedEditCount = 0;