Unread.postsQuotingYou -> ECMAScript 6 Set
This commit is contained in:
parent
b618b760b8
commit
748258f59b
@ -8,3 +8,4 @@
|
|||||||
<%= grunt.file.read('src/General/lib/notice.class') %>
|
<%= grunt.file.read('src/General/lib/notice.class') %>
|
||||||
<%= grunt.file.read('src/General/lib/randomaccesslist.class') %>
|
<%= grunt.file.read('src/General/lib/randomaccesslist.class') %>
|
||||||
<%= grunt.file.read('src/General/lib/simpledict.class') %>
|
<%= grunt.file.read('src/General/lib/simpledict.class') %>
|
||||||
|
<%= grunt.file.read('src/General/lib/set.class') %>
|
||||||
|
|||||||
16
src/General/lib/set.class
Normal file
16
src/General/lib/set.class
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
class ShimSet
|
||||||
|
constructor: ->
|
||||||
|
@elements = {}
|
||||||
|
@size = 0
|
||||||
|
has: (value) ->
|
||||||
|
value of @elements
|
||||||
|
add: (value) ->
|
||||||
|
return if @elements[value]
|
||||||
|
@elements[value] = true
|
||||||
|
@size++
|
||||||
|
delete: (value) ->
|
||||||
|
return unless @elements[value]
|
||||||
|
delete @elements[value]
|
||||||
|
@size--
|
||||||
|
|
||||||
|
window.Set = ShimSet unless 'Set' of window
|
||||||
@ -13,7 +13,7 @@ Unread =
|
|||||||
@hr = $.el 'hr',
|
@hr = $.el 'hr',
|
||||||
id: 'unread-line'
|
id: 'unread-line'
|
||||||
@posts = new RandomAccessList
|
@posts = new RandomAccessList
|
||||||
@postsQuotingYou = {}
|
@postsQuotingYou = new Set
|
||||||
|
|
||||||
Thread.callbacks.push
|
Thread.callbacks.push
|
||||||
name: 'Unread'
|
name: 'Unread'
|
||||||
@ -74,7 +74,7 @@ Unread =
|
|||||||
ID = postIDs[i]
|
ID = postIDs[i]
|
||||||
break if +ID > Unread.lastReadPost
|
break if +ID > Unread.lastReadPost
|
||||||
Unread.posts.rm ID
|
Unread.posts.rm ID
|
||||||
delete Unread.postsQuotingYou[ID]
|
Unread.postsQuotingYou.delete ID
|
||||||
Unread.readCount++
|
Unread.readCount++
|
||||||
|
|
||||||
Unread.setLine() if Conf['Unread Line'] and not Conf['Quote Threading']
|
Unread.setLine() if Conf['Unread Line'] and not Conf['Quote Threading']
|
||||||
@ -91,7 +91,7 @@ Unread =
|
|||||||
|
|
||||||
addPostQuotingYou: (post) ->
|
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[post.ID] = post
|
Unread.postsQuotingYou.add post.ID
|
||||||
Unread.openNotification post
|
Unread.openNotification post
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ Unread =
|
|||||||
{posts} = Unread
|
{posts} = Unread
|
||||||
return unless posts[ID]
|
return unless posts[ID]
|
||||||
posts.rm ID
|
posts.rm ID
|
||||||
delete Unread.postsQuotingYou[ID]
|
Unread.postsQuotingYou.delete ID
|
||||||
Unread.saveLastReadPost()
|
Unread.saveLastReadPost()
|
||||||
Unread.update()
|
Unread.update()
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ Unread =
|
|||||||
{ID, data} = post
|
{ID, data} = post
|
||||||
count++
|
count++
|
||||||
posts.rm ID
|
posts.rm ID
|
||||||
delete Unread.postsQuotingYou[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
|
boardID: data.board.ID
|
||||||
@ -172,7 +172,7 @@ Unread =
|
|||||||
|
|
||||||
update: ->
|
update: ->
|
||||||
count = Unread.posts.length
|
count = Unread.posts.length
|
||||||
countQuotingYou = Object.keys(Unread.postsQuotingYou).length
|
countQuotingYou = Unread.postsQuotingYou.size
|
||||||
|
|
||||||
if Conf['Unread Count']
|
if Conf['Unread Count']
|
||||||
titleQuotingYou = if Conf['Quoted Title'] and countQuotingYou then '(!) ' else ''
|
titleQuotingYou = if Conf['Quoted Title'] and countQuotingYou then '(!) ' else ''
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user