diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index b6da82beb..22f0c177e 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -398,6 +398,7 @@ QR = handleUrl: (urlDefault) -> QR.open() + QR.selected.preventAutoPost() url = prompt 'Enter a URL:', urlDefault return if url is null QR.nodes.fileButton.focus() diff --git a/src/Posting/QR.cooldown.coffee b/src/Posting/QR.cooldown.coffee index a0a3e2e96..1b18148b4 100644 --- a/src/Posting/QR.cooldown.coffee +++ b/src/Posting/QR.cooldown.coffee @@ -92,7 +92,9 @@ QR.cooldown = delete data[scope] $.set 'cooldowns', data - count: -> + update: -> + return unless QR.cooldown.isCounting + $.forceSync 'cooldowns' save = [] nCooldowns = 0 @@ -163,4 +165,7 @@ QR.cooldown = update = seconds isnt QR.cooldown.seconds QR.cooldown.seconds = seconds QR.status() if update - QR.submit() if seconds is 0 and QR.cooldown.auto and !QR.req + + count: -> + QR.cooldown.update() + QR.submit() if QR.cooldown.seconds is 0 and QR.cooldown.auto and !QR.req diff --git a/src/Posting/QR.oekaki.coffee b/src/Posting/QR.oekaki.coffee index f1daaf97d..bb152f774 100644 --- a/src/Posting/QR.oekaki.coffee +++ b/src/Posting/QR.oekaki.coffee @@ -97,6 +97,7 @@ QR.oekaki = QR.oekaki.toggle() edit: -> + QR.cooldown.auto = false QR.oekaki.load -> $.global -> {Tegaki, FCX} = window name = document.getElementById('qr-filename').value.replace(/\.\w+$/, '') + '.png' diff --git a/src/Posting/QR.post.coffee b/src/Posting/QR.post.coffee index a719f92a4..7a1caf80b 100644 --- a/src/Posting/QR.post.coffee +++ b/src/Posting/QR.post.coffee @@ -16,7 +16,8 @@ QR.post = class $.on @nodes.rm, 'click', (e) => e.stopPropagation(); @rm() $.on @nodes.spoiler, 'change', (e) => @spoiler = e.target.checked - (QR.nodes.spoiler.checked = @spoiler if @ is QR.selected) + QR.nodes.spoiler.checked = @spoiler if @ is QR.selected + @preventAutoPost() for label in $$ 'label', el $.on label, 'click', (e) -> e.stopPropagation() $.add QR.nodes.dumpList, el @@ -112,7 +113,7 @@ QR.post = class @showFileData() QR.characterCount() - save: (input) -> + save: (input, forced) -> if input.type is 'checkbox' @spoiler = input.checked return @@ -125,10 +126,6 @@ QR.post = class QR.status() when 'com' @updateComment() - # Disable auto-posting if you're typing in the first post - # during the last 5 seconds of the cooldown. - if QR.cooldown.auto and @ is QR.posts[0] and 0 < QR.cooldown.seconds <= 5 - QR.cooldown.auto = false when 'filename' return unless @file @saveFilename() @@ -136,6 +133,7 @@ QR.post = class when 'name' if @name isnt prev # only save manual changes, not values filled in by persona settings QR.persona.set @ + @preventAutoPost() unless forced forceSave: -> return unless @ is QR.selected @@ -143,9 +141,16 @@ QR.post = class # that do not trigger the `input` event. for name in ['thread', 'name', 'email', 'sub', 'com', 'filename', 'spoiler'] continue if not (node = QR.nodes[name]) - @save node + @save node, true return + preventAutoPost: -> + # Disable auto-posting if you're editing the first post + # during the last 5 seconds of the cooldown. + if QR.cooldown.auto and @ is QR.posts[0] + QR.cooldown.update() # adding/removing file can change cooldown + QR.cooldown.auto = false if QR.cooldown.seconds <= 5 + setComment: (com) -> @com = com or null if @ is QR.selected @@ -210,6 +215,7 @@ QR.post = class @fileError 'Unsupported file type.' else if /^(image|video)\//.test @file.type @readFile() + @preventAutoPost() checkSize: -> max = QR.max_size @@ -306,6 +312,7 @@ QR.post = class @showFileData() URL.revokeObjectURL @URL @dismissErrors (error) -> $.hasClass error, 'file-error' + @preventAutoPost() saveFilename: -> @file.newName = (@filename or '').replace /[/\\]/g, '-' @@ -336,6 +343,7 @@ QR.post = class pasteText: (file) -> @pasting = true + @preventAutoPost() reader = new FileReader() reader.onload = (e) => {result} = e.target