From f0a86b2de36ad3cc5714af91f1298f4209dac085 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Thu, 11 Feb 2021 18:42:46 -0600 Subject: [PATCH 1/4] contact-store: add timestamp to %edit --- pkg/arvo/app/contact-store.hoon | 4 +++- pkg/arvo/lib/contact-store.hoon | 2 ++ pkg/arvo/sur/contact-store.hoon | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/app/contact-store.hoon b/pkg/arvo/app/contact-store.hoon index 04909bf99..3ff7c3039 100644 --- a/pkg/arvo/app/contact-store.hoon +++ b/pkg/arvo/app/contact-store.hoon @@ -132,10 +132,12 @@ state(rolodex (~(del by rolodex) ship)) :: ++ handle-edit - |= [=ship =edit-field:store] + |= [=ship =edit-field:store timestamp=date] |^ ^- (quip card _state) =/ old (~(got by rolodex) ship) + ?: (lth timestamp last-updated.old) + [~ state] =/ contact (edit-contact old edit-field) ?: =(old contact) [~ state] diff --git a/pkg/arvo/lib/contact-store.hoon b/pkg/arvo/lib/contact-store.hoon index b1c643b9e..5f546d11f 100644 --- a/pkg/arvo/lib/contact-store.hoon +++ b/pkg/arvo/lib/contact-store.hoon @@ -42,6 +42,7 @@ %- pairs :~ [%ship (ship ship.upd)] [%edit-field (edit edit-field.upd)] + [%timestamp (time timestamp.upd)] == :: %allow @@ -140,6 +141,7 @@ %- ot :~ [%ship (su ;~(pfix sig fed:ag))] [%edit-field edit] + [%timestamp di] == :: ++ beings diff --git a/pkg/arvo/sur/contact-store.hoon b/pkg/arvo/sur/contact-store.hoon index fb6e85330..5acfd823e 100644 --- a/pkg/arvo/sur/contact-store.hoon +++ b/pkg/arvo/sur/contact-store.hoon @@ -32,7 +32,7 @@ $% [%initial =rolodex is-public=?] [%add =ship =contact] [%remove =ship] - [%edit =ship =edit-field] + [%edit =ship =edit-field timestamp=@da] [%allow =beings] [%disallow =beings] [%set-public public=?] From 1ddf9f5b84290fb5c93961ea6b05414962ff4c56 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Thu, 11 Feb 2021 18:47:36 -0600 Subject: [PATCH 2/4] contact-store: set last-updated appropriately and send last-updated in JS --- pkg/arvo/app/contact-store.hoon | 3 +-- pkg/interface/src/logic/api/contacts.ts | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/arvo/app/contact-store.hoon b/pkg/arvo/app/contact-store.hoon index 3ff7c3039..8f26d409e 100644 --- a/pkg/arvo/app/contact-store.hoon +++ b/pkg/arvo/app/contact-store.hoon @@ -117,7 +117,6 @@ !=(contact(last-updated *@da) u.old(last-updated *@da)) == [~ state] - =. last-updated.contact now.bowl :- (send-diff [%add ship contact] =(ship our.bowl)) state(rolodex (~(put by rolodex) ship contact)) :: @@ -141,7 +140,7 @@ =/ contact (edit-contact old edit-field) ?: =(old contact) [~ state] - =. last-updated.contact now.bowl + =. last-updated.contact timestamp :- (send-diff [%edit ship edit-field] =(ship our.bowl)) state(rolodex (~(put by rolodex) ship contact)) :: diff --git a/pkg/interface/src/logic/api/contacts.ts b/pkg/interface/src/logic/api/contacts.ts index 5bf0a659f..ca1f0a338 100644 --- a/pkg/interface/src/logic/api/contacts.ts +++ b/pkg/interface/src/logic/api/contacts.ts @@ -6,6 +6,7 @@ import { GroupPolicy, Resource } from '~/types/group-update'; export default class ContactsApi extends BaseApi { add(ship: Patp, contact: any) { + contact['last-updated'] = Date.now(); return this.storeAction({ add: { ship, contact } }); } @@ -25,11 +26,11 @@ export default class ContactsApi extends BaseApi { {add-group: {ship, name}} {remove-group: {ship, name}} */ - console.log(ship, editField); return this.storeAction({ edit: { ship, 'edit-field': editField, + timestamp: Date.now() }, }); } From 2d81eb5fdcf5c3eaa87a92865499ce33285e17b4 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Thu, 11 Feb 2021 18:52:26 -0600 Subject: [PATCH 3/4] contact-store: compiles --- pkg/arvo/app/contact-store.hoon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/app/contact-store.hoon b/pkg/arvo/app/contact-store.hoon index 8f26d409e..0d564af1d 100644 --- a/pkg/arvo/app/contact-store.hoon +++ b/pkg/arvo/app/contact-store.hoon @@ -131,7 +131,7 @@ state(rolodex (~(del by rolodex) ship)) :: ++ handle-edit - |= [=ship =edit-field:store timestamp=date] + |= [=ship =edit-field:store timestamp=@da] |^ ^- (quip card _state) =/ old (~(got by rolodex) ship) @@ -141,7 +141,7 @@ ?: =(old contact) [~ state] =. last-updated.contact timestamp - :- (send-diff [%edit ship edit-field] =(ship our.bowl)) + :- (send-diff [%edit ship edit-field timestamp] =(ship our.bowl)) state(rolodex (~(put by rolodex) ship contact)) :: ++ edit-contact From 7bfa30bd75ebd4d47199909f0518f593fc7d640c Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Thu, 11 Feb 2021 18:56:52 -0600 Subject: [PATCH 4/4] contact-store: lte rather than lth --- pkg/arvo/app/contact-store.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/app/contact-store.hoon b/pkg/arvo/app/contact-store.hoon index 0d564af1d..27a3c6cc3 100644 --- a/pkg/arvo/app/contact-store.hoon +++ b/pkg/arvo/app/contact-store.hoon @@ -135,7 +135,7 @@ |^ ^- (quip card _state) =/ old (~(got by rolodex) ship) - ?: (lth timestamp last-updated.old) + ?: (lte timestamp last-updated.old) [~ state] =/ contact (edit-contact old edit-field) ?: =(old contact)