Implement a shitty cache for QuoteMarkers
This commit is contained in:
parent
a4ead91d65
commit
473b8e879e
@ -5389,18 +5389,23 @@
|
||||
});
|
||||
},
|
||||
node: function() {
|
||||
var quotelink, _i, _len, _ref;
|
||||
var parseQuotelink, quotelink, _i, _len, _ref;
|
||||
parseQuotelink = QuoteMarkers.parseQuotelink;
|
||||
_ref = this.nodes.quotelinks;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
quotelink = _ref[_i];
|
||||
QuoteMarkers.parseQuotelink(this, quotelink, !!this.isClone);
|
||||
parseQuotelink(this, quotelink, !!this.isClone);
|
||||
}
|
||||
},
|
||||
cache: {},
|
||||
parseQuotelink: function(post, quotelink, mayReset, customText) {
|
||||
var board, boardID, markers, postID, text, thread, threadID, _ref, _ref1, _ref2;
|
||||
var board, boardID, cache, markers, postID, text, thread, threadID, _ref, _ref1, _ref2;
|
||||
_ref = post.isClone ? post.context : post, board = _ref.board, thread = _ref.thread;
|
||||
markers = [];
|
||||
_ref1 = Get.postDataFromLink(quotelink), boardID = _ref1.boardID, threadID = _ref1.threadID, postID = _ref1.postID;
|
||||
if (cache = QuoteMarkers.cache[postID]) {
|
||||
quotelink.textContent = cache;
|
||||
}
|
||||
if ((_ref2 = QR.db) != null ? _ref2.get({
|
||||
boardID: boardID,
|
||||
threadID: threadID,
|
||||
@ -5421,7 +5426,7 @@
|
||||
}
|
||||
text = customText ? customText : boardID === post.board.ID ? ">>" + postID : ">>>/" + boardID + "/" + postID;
|
||||
if (markers.length) {
|
||||
return quotelink.textContent = "" + text + "\u00A0(" + (markers.join('/')) + ")";
|
||||
return quotelink.textContent = "" + text + "\u00A0(" + (markers.join('|')) + ")";
|
||||
} else if (mayReset) {
|
||||
return quotelink.textContent = text;
|
||||
}
|
||||
|
||||
@ -5441,18 +5441,23 @@
|
||||
});
|
||||
},
|
||||
node: function() {
|
||||
var quotelink, _i, _len, _ref;
|
||||
var parseQuotelink, quotelink, _i, _len, _ref;
|
||||
parseQuotelink = QuoteMarkers.parseQuotelink;
|
||||
_ref = this.nodes.quotelinks;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
quotelink = _ref[_i];
|
||||
QuoteMarkers.parseQuotelink(this, quotelink, !!this.isClone);
|
||||
parseQuotelink(this, quotelink, !!this.isClone);
|
||||
}
|
||||
},
|
||||
cache: {},
|
||||
parseQuotelink: function(post, quotelink, mayReset, customText) {
|
||||
var board, boardID, markers, postID, text, thread, threadID, _ref, _ref1, _ref2;
|
||||
var board, boardID, cache, markers, postID, text, thread, threadID, _ref, _ref1, _ref2;
|
||||
_ref = post.isClone ? post.context : post, board = _ref.board, thread = _ref.thread;
|
||||
markers = [];
|
||||
_ref1 = Get.postDataFromLink(quotelink), boardID = _ref1.boardID, threadID = _ref1.threadID, postID = _ref1.postID;
|
||||
if (cache = QuoteMarkers.cache[postID]) {
|
||||
quotelink.textContent = cache;
|
||||
}
|
||||
if ((_ref2 = QR.db) != null ? _ref2.get({
|
||||
boardID: boardID,
|
||||
threadID: threadID,
|
||||
@ -5473,7 +5478,7 @@
|
||||
}
|
||||
text = customText ? customText : boardID === post.board.ID ? ">>" + postID : ">>>/" + boardID + "/" + postID;
|
||||
if (markers.length) {
|
||||
return quotelink.textContent = "" + text + "\u00A0(" + (markers.join('/')) + ")";
|
||||
return quotelink.textContent = "" + text + "\u00A0(" + (markers.join('|')) + ")";
|
||||
} else if (mayReset) {
|
||||
return quotelink.textContent = text;
|
||||
}
|
||||
|
||||
@ -5,14 +5,22 @@ QuoteMarkers =
|
||||
Post.callbacks.push
|
||||
name: 'Quote Markers'
|
||||
cb: @node
|
||||
|
||||
node: ->
|
||||
{parseQuotelink} = QuoteMarkers
|
||||
for quotelink in @nodes.quotelinks
|
||||
QuoteMarkers.parseQuotelink @, quotelink, !!@isClone
|
||||
parseQuotelink @, quotelink, !!@isClone
|
||||
return
|
||||
|
||||
cache: {}
|
||||
|
||||
parseQuotelink: (post, quotelink, mayReset, customText) ->
|
||||
{board, thread} = if post.isClone then post.context else post
|
||||
markers = []
|
||||
{boardID, threadID, postID} = Get.postDataFromLink quotelink
|
||||
|
||||
if cache = QuoteMarkers.cache[postID]
|
||||
quotelink.textContent = cache
|
||||
|
||||
if QR.db?.get {boardID, threadID, postID}
|
||||
markers.push 'You'
|
||||
@ -34,6 +42,6 @@ QuoteMarkers =
|
||||
else
|
||||
">>>/#{boardID}/#{postID}"
|
||||
if markers.length
|
||||
quotelink.textContent = "#{text}\u00A0(#{markers.join '/'})"
|
||||
quotelink.textContent = "#{text}\u00A0(#{markers.join '|'})"
|
||||
else if mayReset
|
||||
quotelink.textContent = text
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user