From 95ea42d1046574871931b69e05f452aa9f48ae8b Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Wed, 14 Jan 2015 11:44:58 -0700 Subject: [PATCH] Get rid of some null checks for QR.db QR is _always_ enabled in Appchan. --- builds/appchan-x.user.js | 15 +++++++-------- builds/crx/script.js | 15 +++++++-------- src/Monitoring/Unread.coffee | 6 +++--- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index 17ae90ddd..bc91ef960 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -15111,16 +15111,15 @@ return Unread.update(); }, addPost: function() { - var _ref; if (this.isFetchedQuote || this.isClone) { return; } Unread.order.push(this); - if (this.ID <= Unread.lastReadPost || this.isHidden || ((_ref = QR.db) != null ? _ref.get({ + if (this.ID <= Unread.lastReadPost || this.isHidden || QR.db.get({ boardID: this.board.ID, threadID: this.thread.ID, postID: this.ID - }) : void 0)) { + })) { return; } Unread.posts.add(this.ID); @@ -15128,11 +15127,11 @@ return Unread.position != null ? Unread.position : Unread.position = Unread.order[this.ID]; }, addPostQuotingYou: function(post) { - var quotelink, _i, _len, _ref, _ref1; + var quotelink, _i, _len, _ref; _ref = post.nodes.quotelinks; for (_i = 0, _len = _ref.length; _i < _len; _i++) { quotelink = _ref[_i]; - if (!((_ref1 = QR.db) != null ? _ref1.get(Get.postDataFromLink(quotelink)) : void 0)) { + if (!(QR.db.get(Get.postDataFromLink(quotelink)))) { continue; } Unread.postsQuotingYou.add(post.ID); @@ -15179,7 +15178,7 @@ return Unread.update(); }, read: $.debounce(100, function(e) { - var ID, count, data, height, root, _ref, _ref1; + var ID, count, data, height, root, _ref; if (d.hidden || !Unread.posts.size) { return; } @@ -15194,11 +15193,11 @@ count++; Unread.posts["delete"](ID); Unread.postsQuotingYou["delete"](ID); - if (Conf['Mark Quotes of You'] && ((_ref1 = QR.db) != null ? _ref1.get({ + if (Conf['Mark Quotes of You'] && QR.db.get({ boardID: data.board.ID, threadID: data.thread.ID, postID: ID - }) : void 0)) { + })) { QuoteYou.lastRead = root; } Unread.position = Unread.position.next; diff --git a/builds/crx/script.js b/builds/crx/script.js index 36b6c787f..dba73d183 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -15127,16 +15127,15 @@ return Unread.update(); }, addPost: function() { - var _ref; if (this.isFetchedQuote || this.isClone) { return; } Unread.order.push(this); - if (this.ID <= Unread.lastReadPost || this.isHidden || ((_ref = QR.db) != null ? _ref.get({ + if (this.ID <= Unread.lastReadPost || this.isHidden || QR.db.get({ boardID: this.board.ID, threadID: this.thread.ID, postID: this.ID - }) : void 0)) { + })) { return; } Unread.posts.add(this.ID); @@ -15144,11 +15143,11 @@ return Unread.position != null ? Unread.position : Unread.position = Unread.order[this.ID]; }, addPostQuotingYou: function(post) { - var quotelink, _i, _len, _ref, _ref1; + var quotelink, _i, _len, _ref; _ref = post.nodes.quotelinks; for (_i = 0, _len = _ref.length; _i < _len; _i++) { quotelink = _ref[_i]; - if (!((_ref1 = QR.db) != null ? _ref1.get(Get.postDataFromLink(quotelink)) : void 0)) { + if (!(QR.db.get(Get.postDataFromLink(quotelink)))) { continue; } Unread.postsQuotingYou.add(post.ID); @@ -15195,7 +15194,7 @@ return Unread.update(); }, read: $.debounce(100, function(e) { - var ID, count, data, height, root, _ref, _ref1; + var ID, count, data, height, root, _ref; if (d.hidden || !Unread.posts.size) { return; } @@ -15210,11 +15209,11 @@ count++; Unread.posts["delete"](ID); Unread.postsQuotingYou["delete"](ID); - if (Conf['Mark Quotes of You'] && ((_ref1 = QR.db) != null ? _ref1.get({ + if (Conf['Mark Quotes of You'] && QR.db.get({ boardID: data.board.ID, threadID: data.thread.ID, postID: ID - }) : void 0)) { + })) { QuoteYou.lastRead = root; } Unread.position = Unread.position.next; diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index e3e2bf5b2..219308184 100755 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -135,7 +135,7 @@ Unread = addPost: -> return if @isFetchedQuote or @isClone Unread.order.push @ - return if @ID <= Unread.lastReadPost or @isHidden or QR.db?.get { + return if @ID <= Unread.lastReadPost or @isHidden or QR.db.get { boardID: @board.ID threadID: @thread.ID postID: @ID @@ -145,7 +145,7 @@ Unread = Unread.position ?= Unread.order[@ID] addPostQuotingYou: (post) -> - for quotelink in post.nodes.quotelinks when QR.db?.get Get.postDataFromLink quotelink + for quotelink in post.nodes.quotelinks when QR.db.get Get.postDataFromLink quotelink Unread.postsQuotingYou.add post.ID Unread.openNotification post return @@ -192,7 +192,7 @@ Unread = Unread.posts.delete ID Unread.postsQuotingYou.delete ID - if Conf['Mark Quotes of You'] and QR.db?.get { + if Conf['Mark Quotes of You'] and QR.db.get { boardID: data.board.ID threadID: data.thread.ID postID: ID