hark: cleanup edges

This commit is contained in:
Liam Fitzgerald 2021-09-24 11:10:02 +10:00
parent b532e629f3
commit 4267f69e3c
4 changed files with 39 additions and 4 deletions

View File

@ -50,7 +50,7 @@
::
%commit
?. |(=(desk.diff %base) ~(has-docket de:cc desk.diff)) `this
=/ =action:hark ~(updated de:cc desk.diff)
=/ =action:hark ~(commit de:cc desk.diff)
:_ this
~[(poke:ha:cc action)]
::
@ -118,6 +118,8 @@
++ docket .^(docket:^docket %cx scry-path)
++ hash .^(@uv %cz (scry:io desk ~))
++ place `place:hark`[q.byk.bowl /desk/[desk]]
++ vat
.^(vat:hood %gx (scry:io %hood /kiln/vat/[desk]/noun))
++ body
|= [=path title=cord content=(unit cord)]
^- body:hark
@ -137,6 +139,15 @@
(rap 3 'version: ' (ver version:docket) ~)
(rap 3 'hash: ' (scot %uv hash) ~)
::
++ commit
^- action:hark
?:(=(1 ud.cass:vat) created updated)
::
++ created
^- action:hark
:+ %add-note [/created place]
(body /desk/[desk] (title-prefix ' has been installed') ~)
::
++ updated
^- action:hark
:+ %add-note [/update place]

View File

@ -23,6 +23,7 @@
%unread-count (unread-count +.upd)
%saw-place (saw-place +.upd)
%all-stats (all-stats +.upd)
%del-place (place +.upd)
::%read-note (index +.upd)
::%note-read (note-read +.upd)
%archived (archived +.upd)

View File

@ -71,9 +71,11 @@ export const BasicNotification = ({ notification, lid }: BasicNotificationProps)
<h2 id={`${id}-title`} className="note-grid-head font-semibold text-gray-600">
<NotificationText contents={first.title} />
</h2>
<div className="note-grid-actions hidden justify-center self-center group-hover:flex">
<Button onClick={archiveNoFollow}>Archive</Button>
</div>
{!('time' in lid) ? (
<div className="note-grid-actions hidden justify-center self-center group-hover:flex">
<Button onClick={archiveNoFollow}>Archive</Button>
</div>
) : null}
</header>
{contents.length > 0 ? (
<div className="note-grid-body space-y-2">

View File

@ -81,6 +81,10 @@ export const useHarkStore = createState<HarkState>(
set(newState);
},
archiveAll: async () => {
get().set((draft) => {
draft.unseen = {};
draft.seen = {};
});
await api.poke(archiveAll);
},
archiveNote: async (bin, lid) => {
@ -189,6 +193,23 @@ function reduceHark(u: any) {
delete draft.unseen[bin];
});
});
} else if ('del-place' in u) {
const { path, desk } = u['del-place'];
const pathId = `${desk}${path}`;
const wipeBox = (t: Timebox) => {
Object.keys(t).forEach((bin) => {
if (bin.startsWith(pathId)) {
delete t[bin];
}
});
};
set((draft) => {
wipeBox(draft.unseen);
wipeBox(draft.seen);
draft.archive.keys().forEach((key) => {
wipeBox(draft.archive.get(key)!);
});
});
}
}