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