Reduce unnecessary calls to GM_getValue.

This commit is contained in:
ccd0 2014-11-16 17:19:30 -08:00
parent d61f5350ed
commit 8bcec61542
3 changed files with 7 additions and 1 deletions

View File

@ -49,7 +49,6 @@ class DataBoard
@save()
get: ({boardID, threadID, postID, defaultValue}) ->
$.forceSync @key
if board = @data.boards[boardID]
unless threadID
if postID
@ -66,6 +65,9 @@ class DataBoard
thread
val or defaultValue
forceSync: ->
$.forceSync @key
clean: ->
$.forceSync @key
for boardID, val of @data.boards

View File

@ -97,6 +97,7 @@ ThreadWatcher =
onIndexRefresh: ->
{db} = ThreadWatcher
boardID = g.BOARD.ID
db.forceSync()
for threadID, data of db.data.boards[boardID] when not data.isDead and threadID not of g.BOARD.threads
if Conf['Auto Prune']
ThreadWatcher.db.delete {boardID, threadID}
@ -114,6 +115,7 @@ ThreadWatcher =
fetched: 0
fetching: 0
fetchAllStatus: ->
ThreadWatcher.db.forceSync()
return unless (threads = ThreadWatcher.getAll()).length
for thread in threads
ThreadWatcher.fetchStatus thread

View File

@ -20,6 +20,7 @@ Unread =
node: ->
Unread.thread = @
Unread.title = d.title
Unread.db.forceSync()
Unread.lastReadPost = Unread.db.get
boardID: @board.ID
threadID: @ID
@ -57,6 +58,7 @@ Unread =
Header.scrollTo root, down if Header.getBottomOf(root) < 0
sync: ->
return unless Unread.lastReadPost?
lastReadPost = Unread.db.get
boardID: Unread.thread.board.ID
threadID: Unread.thread.ID