Fix false detection of posts added by updater on Tinyboard as own posts.

This commit is contained in:
ccd0 2019-01-22 20:26:39 -08:00
parent b7cd785559
commit 5e0e4c0337

View File

@ -6,8 +6,10 @@ Tinyboard =
$.global -> $.global ->
{boardID, threadID} = document.currentScript.dataset {boardID, threadID} = document.currentScript.dataset
threadID = +threadID threadID = +threadID
window.$(document).on 'new_post', (e, post) -> form = document.querySelector 'form[name="post"]'
postID = +post.id.match(/\d*$/)[0] window.$(document).ajaxComplete (event, request, settings) ->
return unless settings.url is form.action
return unless (postID = +request.responseJSON?.id)
detail = {boardID, threadID, postID} detail = {boardID, threadID, postID}
event = new CustomEvent 'QRPostSuccessful', {bubbles: true, detail: detail} event = new CustomEvent 'QRPostSuccessful', {bubbles: true, detail: detail}
document.dispatchEvent event document.dispatchEvent event