hark-store: fix caching of merged notifications

If a notification came in that merged with a notification that had
already been read, then it would not be added to the cache properly and
therefore would not correctly send %read updates when %read-index was
called.

Fixes #3977
This commit is contained in:
Liam Fitzgerald 2020-11-25 10:51:05 +10:00
parent 6bb62d802b
commit 8a299eadc0
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB

View File

@ -166,11 +166,16 @@
?~ existing-notif
notification
(merge-notification:ha u.existing-notif notification)
=/ new-read=?
?~ existing-notif
%.y
read.u.existing-notif
=. read.new %.n
=/ new-timebox=timebox:store
(~(put by timebox) index new)
:- (give:ha [/updates]~ %added last-seen index new)
%_ state
+ ?~(existing-notif (upd-unreads:ha index last-seen %.n) +.state)
+ ?.(new-read +.state (upd-unreads:ha index last-seen %.n))
notifications (put:orm notifications last-seen new-timebox)
==
++ read-index