Replace rm in DataBoard.extend with properties of val set to undefined.

This commit is contained in:
ccd0 2019-04-03 23:35:33 -07:00
parent cc02b152ff
commit 9ab1c94e31
2 changed files with 9 additions and 6 deletions

View File

@ -350,11 +350,11 @@ ThreadWatcher =
else if @status is 404
if SW[software].mayLackJSON and !data.last?
ThreadWatcher.db.extend {siteID, boardID, threadID, val: {last: -1}, rm: ['unread', 'quotingYou']}
ThreadWatcher.db.extend {siteID, boardID, threadID, val: {last: -1, unread: undefined, quotingYou: undefined}}
else if Conf['Auto Prune']
ThreadWatcher.db.delete {siteID, boardID, threadID}
else
ThreadWatcher.db.extend {siteID, boardID, threadID, val: {isDead: true}, rm: ['unread', 'quotingYou']}
ThreadWatcher.db.extend {siteID, boardID, threadID, val: {isDead: true, unread: undefined, quotingYou: undefined}}
ThreadWatcher.refresh()
@ -493,7 +493,7 @@ ThreadWatcher =
ThreadWatcher.db.delete {boardID, threadID}
return cb()
return cb() if data.isDead and not (data.unread? or data.quotingYou?)
ThreadWatcher.db.extend {boardID, threadID, val: {isDead: true}, rm: ['unread', 'quotingYou']}, cb
ThreadWatcher.db.extend {boardID, threadID, val: {isDead: true, unread: undefined, quotingYou: undefined}}, cb
toggle: (thread) ->
siteID = Site.hostname

View File

@ -85,11 +85,14 @@ class DataBoard
else
@data[siteID].boards[boardID] = val
extend: ({siteID, boardID, threadID, postID, val, rm}, cb) ->
extend: ({siteID, boardID, threadID, postID, val}, cb) ->
@save =>
oldVal = @get {siteID, boardID, threadID, postID, defaultValue: {}}
delete oldVal[key] for key in rm or []
$.extend oldVal, val
for key, subVal of val
if subVal is undefined
delete oldVal[key]
else
oldVal[key] = subVal
@setUnsafe {siteID, boardID, threadID, postID, val: oldVal}
, cb