diff --git a/4chan_x.user.js b/4chan_x.user.js index d6f9784c8..8988dbf16 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -5558,6 +5558,8 @@ if (g.VIEW === 'catalog' || !Conf['Quick Reply']) { return; } + Misc.clearThreads("yourPosts." + g.BOARD); + this.syncYourPosts(); if (Conf['Hide Original Post Form']) { $.addClass(doc, 'hide-original-post-form'); } @@ -5663,6 +5665,16 @@ return QR.unhide(); } }, + syncYourPosts: function(yourPosts) { + if (yourPosts) { + QR.yourPosts = yourPosts; + return; + } + QR.yourPosts = $.get("yourPosts." + g.BOARD, { + threads: {} + }); + return $.sync("yourPosts." + g.BOARD, QR.syncYourPosts); + }, error: function(err) { var el; QR.open(); @@ -6448,7 +6460,7 @@ return QR.ajax = $.ajax($.id('postForm').parentNode.action, callbacks, opts); }, response: function(req) { - var ban, board, err, h1, persona, postID, reply, threadID, tmpDoc, _, _ref, _ref1; + var ban, board, err, h1, persona, postID, reply, threadID, tmpDoc, _, _base, _ref, _ref1; delete QR.ajax; tmpDoc = d.implementation.createHTMLDocument(''); tmpDoc.documentElement.innerHTML = req.response; @@ -6496,6 +6508,8 @@ _ref1 = h1.nextSibling.textContent.match(/thread:(\d+),no:(\d+)/), _ = _ref1[0], threadID = _ref1[1], postID = _ref1[2]; threadID = +threadID; postID = +postID; + ((_base = QR.yourPosts.threads)[threadID] || (_base[threadID] = [])).push(postID); + $.set("yourPosts." + g.BOARD, QR.yourPosts); $.event('QRPostSuccessful', { board: g.BOARD, threadID: threadID || postID, diff --git a/src/qr.coffee b/src/qr.coffee index 89f455e8a..b8a63795a 100644 --- a/src/qr.coffee +++ b/src/qr.coffee @@ -2,6 +2,9 @@ QR = init: -> return if g.VIEW is 'catalog' or !Conf['Quick Reply'] + Misc.clearThreads "yourPosts.#{g.BOARD}" + @syncYourPosts() + if Conf['Hide Original Post Form'] $.addClass doc, 'hide-original-post-form' @@ -83,6 +86,13 @@ QR = else QR.unhide() + syncYourPosts: (yourPosts) -> + if yourPosts + QR.yourPosts = yourPosts + return + QR.yourPosts = $.get "yourPosts.#{g.BOARD}", threads: {} + $.sync "yourPosts.#{g.BOARD}", QR.syncYourPosts + error: (err) -> QR.open() if typeof err is 'string' @@ -805,6 +815,9 @@ QR = threadID = +threadID postID = +postID + (QR.yourPosts.threads[threadID] or= []).push postID + $.set "yourPosts.#{g.BOARD}", QR.yourPosts + # Post/upload confirmed as successful. $.event 'QRPostSuccessful', { board: g.BOARD