From 60beb0090533dc4fbade3f6fa14933ef363931ca Mon Sep 17 00:00:00 2001 From: Artyom Date: Thu, 21 Jul 2016 21:00:46 +0300 Subject: [PATCH] Rename 'empty' to 'wasEmpty' --- src/JS.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/JS.hs b/src/JS.hs index 20a109b..2da696a 100644 --- a/src/JS.hs +++ b/src/JS.hs @@ -412,14 +412,14 @@ makeTraitEditor = {- Note [blurb diffing] ~~~~~~~~~~~~~~~~~~~~~~~ -A note on why we need 'empty' in 'makeItemNotesEditor'. +A note on why we need the 'wasEmpty' parameter in 'makeItemNotesEditor'. Assume that the notes are empty. The text in the area, therefore, will be some default blurb (“# Links, #Imports, #Usage”, etc). Suppose the user edits it. What will be sent to the server? * original: blurb * our version: modified blurb -What will happen next? The server will compare it to the value currently at the server (i.e. an empty string), and think that the blurb *was* on the server but got deleted while the client was doing editing. This is wrong, and will result in a diff popup comparing an edited blurb to an empty string. To prevent this, we pass 'empty' to 'makeItemNotesEditor' – if we're using a blurb, we'll pass an empty string as the original. +What will happen next? The server will compare it to the value currently at the server (i.e. an empty string), and think that the blurb *was* on the server but got deleted while the client was doing editing. This is wrong, and will result in a diff popup comparing an edited blurb to an empty string. To prevent this, we pass 'wasEmpty' to 'makeItemNotesEditor' – if we're using a blurb, we'll pass an empty string as the original. -} @@ -430,7 +430,7 @@ makeItemNotesEditor = -- See Note [blurb diffing] makeJSFunction "makeItemNotesEditor" ["notesNode", "sectionNode", "textareaUid", - "empty", "content", "itemId"] + "wasEmpty", "content", "itemId"] [text| $(sectionNode).html(""); area = $("