From 058ec8aa2c340c253deff882d28dad4150351bac Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Wed, 12 Aug 2020 14:02:15 -0700 Subject: [PATCH 1/2] chat: serialize %keys to JSON for chat update --- pkg/arvo/lib/chat-store.hoon | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/arvo/lib/chat-store.hoon b/pkg/arvo/lib/chat-store.hoon index 1ef7138795..df5d982646 100644 --- a/pkg/arvo/lib/chat-store.hoon +++ b/pkg/arvo/lib/chat-store.hoon @@ -93,7 +93,11 @@ [%create (pairs [%path (path path.upd)]~)] ?: ?=(%delete -.upd) [%delete (pairs [%path (path path.upd)]~)] - [*@t *json] + ?> ?=(%keys -.upd) + :- %keys + :- %a + %+ turn ~(tap by keys.upd) + |= pax=^path (path pax) == -- ++ dejs From 04326ad04d2c1d150a5e76a5da04e9e12cef5368 Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Thu, 13 Aug 2020 01:05:05 -0700 Subject: [PATCH 2/2] chat: Refactor to use ?- in chat update JSON serialization --- pkg/arvo/lib/chat-store.hoon | 61 ++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/pkg/arvo/lib/chat-store.hoon b/pkg/arvo/lib/chat-store.hoon index df5d982646..3b40c6c054 100644 --- a/pkg/arvo/lib/chat-store.hoon +++ b/pkg/arvo/lib/chat-store.hoon @@ -61,8 +61,9 @@ ^- json %+ frond %chat-update %- pairs - :~ - ?: ?=(%initial -.upd) + :_ ~ + ?- -.upd + %initial :- %initial %- pairs %+ turn ~(tap by inbox.upd) @@ -73,31 +74,37 @@ :~ [%envelopes [%a (turn envelopes.mailbox envelope)]] [%config (config config.mailbox)] == - ?: ?=(%message -.upd) - :- %message - %- pairs - :~ [%path (path path.upd)] - [%envelope (envelope envelope.upd)] - == - ?: ?=(%messages -.upd) - :- %messages - %- pairs - :~ [%path (path path.upd)] - [%start (numb start.upd)] - [%end (numb end.upd)] - [%envelopes [%a (turn envelopes.upd envelope)]] - == - ?: ?=(%read -.upd) - [%read (pairs [%path (path path.upd)]~)] - ?: ?=(%create -.upd) - [%create (pairs [%path (path path.upd)]~)] - ?: ?=(%delete -.upd) - [%delete (pairs [%path (path path.upd)]~)] - ?> ?=(%keys -.upd) - :- %keys - :- %a - %+ turn ~(tap by keys.upd) - |= pax=^path (path pax) + :: + %message + :- %message + %- pairs + :~ [%path (path path.upd)] + [%envelope (envelope envelope.upd)] + == + :: + %messages + :- %messages + %- pairs + :~ [%path (path path.upd)] + [%start (numb start.upd)] + [%end (numb end.upd)] + [%envelopes [%a (turn envelopes.upd envelope)]] + == + :: + %read + [%read (pairs [%path (path path.upd)]~)] + :: + %create + [%create (pairs [%path (path path.upd)]~)] + :: + %delete + [%delete (pairs [%path (path path.upd)]~)] + :: + %keys + :- %keys + :- %a + %+ turn ~(tap by keys.upd) + |= pax=^path (path pax) == -- ++ dejs