Fix Tinyboard/vichan post form redirecting before your posts can be recorded as yours. #2171
This commit is contained in:
parent
d77bacd6e0
commit
a6ab951170
@ -11,6 +11,12 @@ Tinyboard =
|
|||||||
return unless settings.url is form.action
|
return unless settings.url is form.action
|
||||||
return unless (postID = +request.responseJSON?.id)
|
return unless (postID = +request.responseJSON?.id)
|
||||||
detail = {boardID, threadID, postID}
|
detail = {boardID, threadID, postID}
|
||||||
|
try
|
||||||
|
{redirect, noko} = request.responseJSON
|
||||||
|
if redirect and originalNoko? and !originalNoko and !noko
|
||||||
|
detail.redirect = redirect
|
||||||
event = new CustomEvent 'QRPostSuccessful', {bubbles: true, detail: detail}
|
event = new CustomEvent 'QRPostSuccessful', {bubbles: true, detail: detail}
|
||||||
document.dispatchEvent event
|
document.dispatchEvent event
|
||||||
|
originalNoko = window.tb_settings?.ajax?.always_noko_replies
|
||||||
|
((window.tb_settings or= {}).ajax or= {}).always_noko_replies = true
|
||||||
, {boardID: g.BOARD.ID, threadID: g.THREADID}
|
, {boardID: g.BOARD.ID, threadID: g.THREADID}
|
||||||
|
|||||||
@ -141,11 +141,12 @@ ThreadWatcher =
|
|||||||
ThreadWatcher.rm siteID, boardID, +threadID
|
ThreadWatcher.rm siteID, boardID, +threadID
|
||||||
post: (e) ->
|
post: (e) ->
|
||||||
{boardID, threadID, postID} = e.detail
|
{boardID, threadID, postID} = e.detail
|
||||||
|
cb = PostRedirect.delay()
|
||||||
if postID is threadID
|
if postID is threadID
|
||||||
if Conf['Auto Watch']
|
if Conf['Auto Watch']
|
||||||
ThreadWatcher.addRaw boardID, threadID, {}
|
ThreadWatcher.addRaw boardID, threadID, {}, cb
|
||||||
else if Conf['Auto Watch Reply']
|
else if Conf['Auto Watch Reply']
|
||||||
ThreadWatcher.add g.threads[boardID + '.' + threadID] or new Thread(threadID, g.boards[boardID] or new Board(boardID))
|
ThreadWatcher.add (g.threads[boardID + '.' + threadID] or new Thread(threadID, g.boards[boardID] or new Board(boardID))), cb
|
||||||
onIndexUpdate: (e) ->
|
onIndexUpdate: (e) ->
|
||||||
{db} = ThreadWatcher
|
{db} = ThreadWatcher
|
||||||
siteID = g.SITE.ID
|
siteID = g.SITE.ID
|
||||||
@ -528,21 +529,21 @@ ThreadWatcher =
|
|||||||
else
|
else
|
||||||
ThreadWatcher.add thread
|
ThreadWatcher.add thread
|
||||||
|
|
||||||
add: (thread) ->
|
add: (thread, cb) ->
|
||||||
data = {}
|
data = {}
|
||||||
siteID = g.SITE.ID
|
siteID = g.SITE.ID
|
||||||
boardID = thread.board.ID
|
boardID = thread.board.ID
|
||||||
threadID = thread.ID
|
threadID = thread.ID
|
||||||
if thread.isDead
|
if thread.isDead
|
||||||
if Conf['Auto Prune'] and ThreadWatcher.db.get {boardID, threadID}
|
if Conf['Auto Prune'] and ThreadWatcher.db.get {boardID, threadID}
|
||||||
ThreadWatcher.rm siteID, boardID, threadID
|
ThreadWatcher.rm siteID, boardID, threadID, cb
|
||||||
return
|
return
|
||||||
data.isDead = true
|
data.isDead = true
|
||||||
data.excerpt = Get.threadExcerpt thread if thread.OP
|
data.excerpt = Get.threadExcerpt thread if thread.OP
|
||||||
ThreadWatcher.addRaw boardID, threadID, data
|
ThreadWatcher.addRaw boardID, threadID, data, cb
|
||||||
|
|
||||||
addRaw: (boardID, threadID, data) ->
|
addRaw: (boardID, threadID, data, cb) ->
|
||||||
ThreadWatcher.db.set {boardID, threadID, val: data}
|
ThreadWatcher.db.set {boardID, threadID, val: data}, cb
|
||||||
ThreadWatcher.refresh()
|
ThreadWatcher.refresh()
|
||||||
thread = {siteID: g.SITE.ID, boardID, threadID, data, force: true}
|
thread = {siteID: g.SITE.ID, boardID, threadID, data, force: true}
|
||||||
if Conf['Show Page'] and !data.isDead
|
if Conf['Show Page'] and !data.isDead
|
||||||
@ -550,8 +551,8 @@ ThreadWatcher =
|
|||||||
else if ThreadWatcher.unreadEnabled and Conf['Show Unread Count']
|
else if ThreadWatcher.unreadEnabled and Conf['Show Unread Count']
|
||||||
ThreadWatcher.fetchStatus thread
|
ThreadWatcher.fetchStatus thread
|
||||||
|
|
||||||
rm: (siteID, boardID, threadID) ->
|
rm: (siteID, boardID, threadID, cb) ->
|
||||||
ThreadWatcher.db.delete {siteID, boardID, threadID}
|
ThreadWatcher.db.delete {siteID, boardID, threadID}, cb
|
||||||
ThreadWatcher.refresh()
|
ThreadWatcher.refresh()
|
||||||
|
|
||||||
menu:
|
menu:
|
||||||
|
|||||||
21
src/Posting/PostRedirect.coffee
Normal file
21
src/Posting/PostRedirect.coffee
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
PostRedirect =
|
||||||
|
init: ->
|
||||||
|
$.on d, 'QRPostSuccessful', (e) =>
|
||||||
|
return unless e.detail.redirect
|
||||||
|
@event = e
|
||||||
|
@delays = 0
|
||||||
|
$.queueTask =>
|
||||||
|
if e is @event and @delays is 0
|
||||||
|
location.href = e.detail.redirect
|
||||||
|
|
||||||
|
delays: 0
|
||||||
|
|
||||||
|
delay: ->
|
||||||
|
return null unless @event
|
||||||
|
e = @event
|
||||||
|
@delays++
|
||||||
|
() =>
|
||||||
|
return unless e is @event
|
||||||
|
@delays--
|
||||||
|
if @delays is 0
|
||||||
|
location.href = e.detail.redirect
|
||||||
@ -5,10 +5,11 @@ QuoteYou =
|
|||||||
@db = new DataBoard 'yourPosts'
|
@db = new DataBoard 'yourPosts'
|
||||||
$.sync 'Remember Your Posts', (enabled) -> Conf['Remember Your Posts'] = enabled
|
$.sync 'Remember Your Posts', (enabled) -> Conf['Remember Your Posts'] = enabled
|
||||||
$.on d, 'QRPostSuccessful', (e) ->
|
$.on d, 'QRPostSuccessful', (e) ->
|
||||||
|
cb = PostRedirect.delay()
|
||||||
$.get 'Remember Your Posts', Conf['Remember Your Posts'], (items) ->
|
$.get 'Remember Your Posts', Conf['Remember Your Posts'], (items) ->
|
||||||
return unless items['Remember Your Posts']
|
return unless items['Remember Your Posts']
|
||||||
{boardID, threadID, postID} = e.detail
|
{boardID, threadID, postID} = e.detail
|
||||||
(QuoteYou.db.set {boardID, threadID, postID, val: true})
|
QuoteYou.db.set {boardID, threadID, postID, val: true}, cb
|
||||||
|
|
||||||
return unless g.VIEW in ['index', 'thread', 'archive']
|
return unless g.VIEW in ['index', 'thread', 'archive']
|
||||||
|
|
||||||
|
|||||||
@ -46,7 +46,7 @@ class DataBoard
|
|||||||
@sync?()
|
@sync?()
|
||||||
cb?()
|
cb?()
|
||||||
|
|
||||||
delete: ({siteID, boardID, threadID, postID}) ->
|
delete: ({siteID, boardID, threadID, postID}, cb) ->
|
||||||
siteID or= g.SITE.ID
|
siteID or= g.SITE.ID
|
||||||
return unless @data[siteID]
|
return unless @data[siteID]
|
||||||
@save =>
|
@save =>
|
||||||
@ -60,6 +60,7 @@ class DataBoard
|
|||||||
@deleteIfEmpty {siteID, boardID}
|
@deleteIfEmpty {siteID, boardID}
|
||||||
else
|
else
|
||||||
delete @data[siteID].boards[boardID]
|
delete @data[siteID].boards[boardID]
|
||||||
|
, cb
|
||||||
|
|
||||||
deleteIfEmpty: ({siteID, boardID, threadID}) ->
|
deleteIfEmpty: ({siteID, boardID, threadID}) ->
|
||||||
return unless @data[siteID]
|
return unless @data[siteID]
|
||||||
|
|||||||
@ -536,6 +536,7 @@ Main =
|
|||||||
['Polyfill', Polyfill]
|
['Polyfill', Polyfill]
|
||||||
['Board Configuration', BoardConfig]
|
['Board Configuration', BoardConfig]
|
||||||
['Normalize URL', NormalizeURL]
|
['Normalize URL', NormalizeURL]
|
||||||
|
['Delay Redirect on Post', PostRedirect]
|
||||||
['Captcha Configuration', Captcha.replace]
|
['Captcha Configuration', Captcha.replace]
|
||||||
['Image Host Rewriting', ImageHost]
|
['Image Host Rewriting', ImageHost]
|
||||||
['Redirect', Redirect]
|
['Redirect', Redirect]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user