diff --git a/pkg/arvo/app/contact-store.hoon b/pkg/arvo/app/contact-store.hoon index 398ef15b0..d0ee582c9 100644 --- a/pkg/arvo/app/contact-store.hoon +++ b/pkg/arvo/app/contact-store.hoon @@ -5,18 +5,33 @@ +$ card card:agent:gall +$ versioned-state $% state-zero + state-one + == +:: ++$ rolodex-0 (map path contacts-0) ++$ contacts-0 (map ship contact-0) ++$ avatar-0 [content-type=@t octs=[p=@ud q=@t]] ++$ contact-0 + $: nickname=@t + email=@t + phone=@t + website=@t + notes=@t + color=@ux + avatar=(unit avatar-0) == :: +$ state-zero $: %0 - =rolodex + rolodex=rolodex-0 == -+$ diff - $% [%contact-update contact-update] ++$ state-one + $: %1 + =rolodex == -- :: -=| state-zero +=| state-one =* state - %- agent:dbug ^- agent:gall @@ -30,8 +45,26 @@ ++ on-init on-init:def ++ on-save !>(state) ++ on-load - |= old=vase - `this(state !<(state-zero old)) + |= old-vase=vase + =/ old !<(versioned-state old-vase) + ?: ?=(%1 -.old) + [~ this(state old)] + =/ new-rolodex=^rolodex + %- ~(run by rolodex.old) + |= cons=contacts-0 + ^- contacts + %- ~(run by cons) + |= con=contact-0 + ^- contact + :* nickname.con + email.con + phone.con + website.con + notes.con + color.con + ~ + == + [~ this(state [%1 new-rolodex])] :: ++ on-poke |= [=mark =vase] diff --git a/pkg/arvo/app/contact-view.hoon b/pkg/arvo/app/contact-view.hoon index 1bfd5a69a..97aa15729 100644 --- a/pkg/arvo/app/contact-view.hoon +++ b/pkg/arvo/app/contact-view.hoon @@ -181,21 +181,19 @@ :: :: avatar images :: -:: [%'~groups' %avatar @ *] -:: =/ pax=path `path`t.t.site.url -:: ?~ pax not-found:gen -:: =/ pas `path`(flop pax) -:: ?~ pas not-found:gen -:: =/ pav `path`(flop t.pas) -:: ~& pav+pav -:: ~& name+name -:: =/ contact (contact-scry `path`(weld pav [name]~)) -:: ?~ contact not-found:gen -:: ?~ avatar.u.contact not-found:gen -:: =* avatar u.avatar.u.contact -:: =/ decoded (de:base64 q.octs.avatar) -:: ?~ decoded not-found:gen -:: [[200 ['content-type' content-type.avatar]~] `u.decoded] + [%'~groups' %avatar @ *] + =/ =path (flop t.t.site.url) + ?~ path not-found:gen + =/ contact (contact-scry `^path`(snoc (flop t.path) name)) + ?~ contact not-found:gen + ?~ avatar.u.contact not-found:gen + ?- -.u.avatar.u.contact + %url [[307 ['location' url.u.avatar.u.contact]~] ~] + %octt + =/ max-3-days ['cache-control' 'max-age=259200'] + =/ content-type ['content-type' content-type.u.avatar.u.contact] + [[200 [content-type max-3-days ~]] `octs.u.avatar.u.contact] + == :: [%'~groups' *] (html-response:gen index) == diff --git a/pkg/arvo/lib/contact-json.hoon b/pkg/arvo/lib/contact-json.hoon index cca3aa70e..67e8172fb 100644 --- a/pkg/arvo/lib/contact-json.hoon +++ b/pkg/arvo/lib/contact-json.hoon @@ -1,4 +1,5 @@ /- *contact-view, *contact-hook +/+ base64 |% ++ nu :: parse number as hex |= jon/json @@ -26,38 +27,34 @@ |= [pax=^path =contacts] ^- [cord json] :- (spat pax) - (contacts-to-json contacts) + (contacts-to-json pax contacts) :: ++ contacts-to-json - |= con=contacts + |= [=path con=contacts] ^- json - =, enjs:format - %- pairs + %- pairs:enjs:format %+ turn ~(tap by con) - |= [shp=^ship =contact] + |= [=ship =contact] ^- [cord json] - :- (crip (slag 1 (scow %p shp))) - (contact-to-json contact) + [(crip (slag 1 (scow %p ship))) (contact-to-json path ship contact)] :: ++ contact-to-json - |= con=contact + |= [=path =ship con=contact] ^- json - =, enjs:format - %- pairs + %- pairs:enjs:format :~ [%nickname s+nickname.con] [%email s+email.con] [%phone s+phone.con] [%website s+website.con] [%notes s+notes.con] [%color s+(scot %ux color.con)] - [%avatar s+'TODO'] + [%avatar (avatar-to-json path ship avatar.con)] == :: ++ edit-to-json - |= edit=edit-field + |= [=path =ship edit=edit-field] ^- json - =, enjs:format - %+ frond -.edit + %+ frond:enjs:format -.edit ?- -.edit %nickname s+nickname.edit %email s+email.edit @@ -65,7 +62,25 @@ %website s+website.edit %notes s+notes.edit %color s+(scot %ux color.edit) - %avatar s+'TODO' + %avatar (avatar-to-json path ship avatar.edit) + == +:: +++ avatar-to-json + |= [=path =ship avat=(unit avatar)] + ^- json + ?~ avat ~ + ?- -.u.avat + %octt + :- %s + %- crip + %- zing + :~ "/~groups/avatar" + (trip (spat path)) + "/" + (trip (scot %p ship)) + == + :: + %url s+url.u.avat == :: ++ update-to-json @@ -84,7 +99,7 @@ %- pairs :~ [%path (path path.upd)] [%ship (ship ship.upd)] - [%contact (contact-to-json contact.upd)] + [%contact (contact-to-json path.upd ship.upd contact.upd)] == ?: ?=(%remove -.upd) :- %remove @@ -97,7 +112,7 @@ %- pairs :~ [%path (path path.upd)] [%ship (ship ship.upd)] - [%edit-field (edit-to-json edit-field.upd)] + [%edit-field (edit-to-json path.upd ship.upd edit-field.upd)] == [*@t *^json] == @@ -190,10 +205,31 @@ == :: ++ avat - %- ot:dejs:format - :~ [%content-type so:dejs:format] - [%octs octet] + |= jon=json + ^- avatar + |^ + =/ =avatar (parse-json jon) + ?- -.avatar + %url avatar + %octt + =. octs.avatar (need (de:base64 q.octs.avatar)) + avatar == + :: + ++ parse-json + %- of:dejs:format + :~ [%octt octt] + [%url url] + == + :: + ++ octt + %- ot:dejs:format + :~ [%content-type so:dejs:format] + [%octs octet] + == + :: + ++ url so:dejs:format + -- :: ++ cont %- ot:dejs:format diff --git a/pkg/arvo/sur/contact-store.hoon b/pkg/arvo/sur/contact-store.hoon index 7c5bae968..d7f93d9a3 100644 --- a/pkg/arvo/sur/contact-store.hoon +++ b/pkg/arvo/sur/contact-store.hoon @@ -1,10 +1,11 @@ /- *identity |% -+$ rolodex (map path contacts) -:: -+$ contacts (map ship contact) -:: -+$ avatar [content-type=@t octs=[p=@ud q=@t]] ++$ rolodex (map path contacts) ++$ contacts (map ship contact) ++$ avatar + $% [%octt content-type=@t octs=[p=@ud q=@t]] + [%url url=@t] + == :: +$ contact $: nickname=@t diff --git a/pkg/interface/groups/src/js/components/lib/contact-card.js b/pkg/interface/groups/src/js/components/lib/contact-card.js index de3189918..6ee155c34 100644 --- a/pkg/interface/groups/src/js/components/lib/contact-card.js +++ b/pkg/interface/groups/src/js/components/lib/contact-card.js @@ -379,15 +379,6 @@ export class ContactCard extends Component { ); } - let removeImage = hasAvatar ? ( -
Ship Name
~{props.ship}