From b8d1dbd8c6d9e27bdc27c4a355ce94c3bb31abe0 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 4 Mar 2021 12:54:37 +1000 Subject: [PATCH] group-view: add hidden field --- pkg/arvo/app/group-view.hoon | 68 ++++++++++++++++++++++++++---------- pkg/arvo/lib/group-view.hoon | 16 +++++++-- pkg/arvo/sur/group-view.hoon | 12 ++++++- 3 files changed, 74 insertions(+), 22 deletions(-) diff --git a/pkg/arvo/app/group-view.hoon b/pkg/arvo/app/group-view.hoon index 51ad9b09f..47e252836 100644 --- a/pkg/arvo/app/group-view.hoon +++ b/pkg/arvo/app/group-view.hoon @@ -4,23 +4,30 @@ |% ++ card card:agent:gall :: -+$ base-state ++$ base-state-0 joining=(map rid=resource [=ship =progress:view]) :: ++$ base-state-1 + joining=(map rid=resource request:view) +:: +$ state-zero - [%0 base-state] + [%0 base-state-0] :: +$ state-one - [%1 base-state] + [%1 base-state-0] +:: ++$ state-two + [%2 base-state-1] :: +$ versioned-state $% state-zero state-one + state-two == :: ++ view view-sur -- -=| state-one +=| state-two =* state - :: %- agent:dbug @@ -41,10 +48,29 @@ |= =vase =+ !<(old=versioned-state vase) =| cards=(list card) - |- - ?: ?=(%1 -.old) - `this(state old) - $(-.old %1, cards :_(cards (poke-self:pass:io noun+!>(%cleanup)))) + |^ + ?- -.old + %2 [cards this(state old)] + %1 $(-.old %2, +.old (base-state-to-1 +.old)) + %0 $(-.old %1, cards :_(cards (poke-self:pass:io noun+!>(%cleanup)))) + == + :: + ++ base-state-to-1 + |= base-state-0 + %- ~(gas by *(map resource request:view)) + (turn ~(tap by joining) request-to-1) + :: + ++ request-to-1 + |= [rid=resource =ship =progress:view] + ^- [resource request:view] + :- rid + %* . *request:view + started now.bowl + hidden %.n + ship ship + progress progress + == + -- :: ++ on-poke |= [=mark =vase] @@ -56,9 +82,11 @@ ?. ?=(%group-view-action mark) (on-poke:def mark vase) =+ !<(=action:view vase) - ?> ?=(%join -.action) =^ cards state - jn-abet:(jn-start:join:gc +.action) + ?+ -.action !! + %join jn-abet:(jn-start:join:gc +.action) + %hide (hide:gc +.action) + == [cards this] :: ++ on-watch @@ -69,8 +97,7 @@ :_ ~ %+ fact:io :- %group-view-update - !> ^- update:view - [%initial (~(run by joining) |=([=ship =progress:view] progress))] + !>(`update:view`[%initial joining]) ~ == :: @@ -97,6 +124,11 @@ ++ grp ~(. grpl bowl) ++ io ~(. agentio bowl) ++ con ~(. conl bowl) +++ hide + |= rid=resource + ^- (quip card _state) + :- (fact:io group-view-update+!>([%hide rid]) /all ~)^~ + state(joining (~(jab by joining) rid |=(request:view +<(hidden %.y)))) :: ++ has-joined |= rid=resource @@ -107,10 +139,10 @@ :: ++ poke-noun ^- (quip card _state) - =; new-joining=(map resource [ship progress:view]) + =; new-joining=(map resource request:view) `state(joining new-joining) %+ roll ~(tap by joining) - |= [[rid=resource =ship =progress:view] out=_joining] + |= [[rid=resource =request:view] out=_joining] ?. (has-joined rid) out (~(del by out) rid) :: @@ -128,7 +160,7 @@ ++ tx-progress |= =progress:view =. joining - (~(put by joining) rid [ship progress]) + (~(jab by joining) rid |=(request:view +<(progress progress))) =; =cage (emit (fact:io cage /all tx+(en-path:resource rid) ~)) group-view-update+!>([%progress rid progress]) @@ -145,9 +177,9 @@ :: ++ jn-abed |= r=resource - =/ [s=^ship =progress:view] + =/ =request:view (~(got by joining) r) - jn-core(rid r, ship s) + jn-core(rid r, ship ship.request) :: ++ jn-abet ^- (quip card _state) @@ -158,7 +190,7 @@ ^+ jn-core ?< (~(has by joining) rid) =. joining - (~(put by joining) rid [ship %start]) + (~(put by joining) rid [%.n now.bowl ship %start]) =. jn-core (jn-abed rid) ?< ~|("already joined {}" (has-joined rid)) diff --git a/pkg/arvo/lib/group-view.hoon b/pkg/arvo/lib/group-view.hoon index f3919891a..3a593d975 100644 --- a/pkg/arvo/lib/group-view.hoon +++ b/pkg/arvo/lib/group-view.hoon @@ -15,6 +15,7 @@ join+join leave+leave invite+invite + hide+dejs-path:resource == :: ++ create @@ -53,6 +54,7 @@ ?- -.upd %initial (initial +.upd) %progress (progress +.upd) + %hide s+(enjs-path:resource +.upd) == :: ++ progress @@ -61,13 +63,21 @@ :~ resource+s+(enjs-path:resource rid) progress+s+prog == + ++ request + |= req=^request + %- pairs + :~ hidden+b+hidden.req + started+(time started.req) + ship+(ship ship.req) + progress+s+progress.req + == :: ++ initial - |= init=(map resource ^progress) + |= init=(map resource ^request) %- pairs %+ turn ~(tap by init) - |= [rid=resource prog=^progress] - :_ s+prog + |= [rid=resource req=^request] + :_ (request req) (enjs-path:resource rid) -- ++ cleanup-md diff --git a/pkg/arvo/sur/group-view.hoon b/pkg/arvo/sur/group-view.hoon index 549ae5430..86b2ee689 100644 --- a/pkg/arvo/sur/group-view.hoon +++ b/pkg/arvo/sur/group-view.hoon @@ -2,6 +2,13 @@ ^? |% :: ++$ request + $: hidden=? + started=time + =ship + =progress + == +:: +$ action $% :: host side [%create name=term =policy title=@t description=@t] @@ -11,6 +18,8 @@ [%leave =resource] :: [%invite =resource ships=(set ship) description=@t] + :: pending ops + [%hide =resource] == :: @@ -21,7 +30,8 @@ ?(%no-perms %strange %done) :: +$ update - $% [%initial initial=(map resource progress)] + $% [%initial initial=(map resource request)] [%progress =resource =progress] + [%hide =resource] == --