Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

profile & expose: fix integration with contacts #4217

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 39 additions & 12 deletions desk/app/expose.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
:: then visit in the browser:
:: /expose/that/reference/as/copied/123456789
::
/- c=cite, d=channels, co=contacts
/- c=cite, d=channels, co=contacts-0
/+ u=channel-utils, hutils=http-utils,
dbug, verb
::
/= page /app/expose/page
/= widget /app/expose/widget
::
|%
+$ state-0
$: %0
+$ state-1
$: %1
open=(set cite:c)
==
::
Expand Down Expand Up @@ -79,7 +79,7 @@
%+ verb |
^- agent:gall
::
=| state-0
=| state-1
=* state -
|_ =bowl:gall
+* this .
Expand All @@ -88,18 +88,43 @@
:_ this
:~ [%pass /eyre/connect %arvo %e %connect [~ /expose] dap.bowl]
[%pass /channels %agent [our.bowl %channels] %watch /v1]
[%pass /contacts %agent [our.bowl %contacts] %watch /contact]
[%pass /contacts/news %agent [our.bowl %contacts] %watch /news]
==
::
++ on-save !>(state)
++ on-load
|= ole=vase
|^ |= ole=vase
^- (quip card _this)
=. state !<(state-0 ole)
:_ this
:: we must defer refreshing the cache because rendering scries
=+ !<(old=versioned-state ole)
=+ ver=-.old
=? old ?=(%0 -.old) old(- %1)
?> ?=(%1 -.old)
=. state old
=/ caz=(list card)
:: we must defer refreshing the cache because rendering scries
::
[%pass /refresh %arvo %b %wait now.bowl]~
:: leave obsolete %contacts endpoint and connect
::
=? caz ?=(%0 ver)
%+ weld caz
^- (list card)
:~ [%pass /contacts %agent [our.bowl %contacts] %leave ~]
:: leave %conacts (sic) agent sub
[%pass /contacts %agent [our.bowl %conacts] %leave ~]
[%pass /contacts/news %agent [our.bowl %contacts] %watch /news]
==
[caz this]
::
[%pass /refresh %arvo %b %wait now.bowl]~
+$ versioned-state
$% state-1
state-0
==
+$ state-0
$: %0
open=(set cite:c)
==
--
::
++ on-poke
|= [=mark =vase]
Expand Down Expand Up @@ -254,10 +279,10 @@
==
==
::
[%contacts ~]
[%contacts %news ~]
?- -.sign
%poke-ack !!
%kick [[%pass /contacts %agent [our.bowl %conacts] %watch /contact]~ this]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, oops, good catch

%kick [[%pass /contacts/news %agent [our.bowl %contacts] %watch /news]~ this]
::
%watch-ack
?~ p.sign [~ this]
Expand All @@ -274,6 +299,8 @@
:: fresh(er), we should just set an hourly timer that re-render the
:: entire cache.
::
=+ !<(=news-0:co q.cage.sign)
?. =(our.bowl who.news-0) `this
:_ this
%+ weld
(refresh-widget:e bowl open)
Expand Down
4 changes: 2 additions & 2 deletions desk/app/expose/page.hoon
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:: expose page: rendering for content pages
::
/- c=cite, d=channels, co=contacts
/- c=cite, d=channels, co=contacts-0
/+ u=channel-utils
::
/= r /app/expose/render
Expand All @@ -10,7 +10,7 @@
++ render
|= [=bowl:gall =nest:g:c msg=post:d]
^- (unit manx)
=/ aco=(unit contact:co)
=/ aco=(unit contact-0:co)
(get-contact:co bowl author.msg)
::
::TODO if we render replies then we can "unroll" whole chat threads too (:
Expand Down
4 changes: 2 additions & 2 deletions desk/app/expose/render.hoon
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
:: expose render: rendering utilities for pages & the widget
::
/- co=contacts
/- co=contacts-0
/+ sigil
::
|%
++ author
=/ link=(unit @t) ~
|= [=bowl:gall author=ship]
^- manx
=/ aco=(unit contact:co)
=/ aco=(unit contact-0:co)
(get-contact:co bowl author)
|^ ::TODO we should just have a bunch of manx construction helpers
:: for stuff like this
Expand Down
59 changes: 45 additions & 14 deletions desk/app/profile.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
:: other apps can poke this agent with widgets of their own, and the user
:: can choose which widgets to display on their public page.
::
/- contacts-0
/- co=contacts-0
/+ dbug, verb, sigil, hutils=http-utils
/= stock-widgets /app/profile/widgets
::
/* style-shared %css /app/profile/style/shared/css
/* style-page %css /app/profile/style/page/css
::
|%
+$ state-0
$: %0
+$ state-1
$: %1
bound=_|
::
widgets=(map desk (map term widget))
Expand Down Expand Up @@ -44,7 +44,7 @@
+$ card $+(card card:agent:gall)
--
::
|_ [=bowl:gall state-0]
|_ [=bowl:gall state-1]
+* this .
state +<+
++ bind
Expand Down Expand Up @@ -175,8 +175,8 @@
::
++ render-page
^- manx
=/ ours=(unit contact-0:contacts-0)
(get-contact:contacts-0 bowl our.bowl)
=/ ours=(unit contact-0:co)
(get-contact:co bowl our.bowl)
|^ ;html
;+ head
;+ body
Expand Down Expand Up @@ -255,7 +255,7 @@
%- agent:dbug
%+ verb |
::
=| state-0
=| state-1
=* state -
^- agent:gall
|_ =bowl:gall
Expand All @@ -266,15 +266,15 @@
::NOTE we special-case the "internal" widgets
=. layout [[%groups %profile] [%groups %join-button] [%groups %profile-bio] ~]
:_ this
:~ [%pass /contacts/ours %agent [our.bowl %contacts] %watch /contact]
:~ [%pass /contacts/news %agent [our.bowl %contacts] %watch /news]
[%pass /refresh %arvo %b %wait now.bowl]
==
::
++ on-save
!>(state)
::
++ on-load
|= ole=vase
|^ |= ole=vase
^- (quip card _this)
:: a different %profile agent has been spotted in the wild. it was not
:: compatible with the kelvin at which this agent was first released, made
Expand All @@ -287,10 +287,38 @@
?=(^ ((soft ,[%0 (map path mime) (set @p) (unit @t)]) q.ole))
==
on-init
=. state !<(state-0 ole)
:: delay, so we don't end up scrying during load
=+ !<(old=versioned-state ole)
=+ ver=-.old
=? old ?=(%0 -.old) old(- %1)
?> ?=(%1 -.old)
=. state old
::
=/ caz=(list card)
:: delay, so we don't end up scrying during load
[%pass /refresh %arvo %b %wait now.bowl]~
:: leave obsolete %contacts endpoint and connect
::
=? caz ?=(%0 ver)
%+ weld caz
^- (list card)
:~ [%pass /contacts/ours %agent [our.bowl %contacts] %leave ~]
[%pass /contacts/news %agent [our.bowl %contacts] %watch /news]
==
[caz this]
::
[[%pass /refresh %arvo %b %wait now.bowl]~ this]
+$ versioned-state
$% state-1
state-0
==
+$ state-0
$: %0
bound=_|
::
widgets=(map desk (map term widget))
layout=(list [=desk =term])
tlon-cta=?
==
--
::
++ on-poke
|= [=mark =vase]
Expand Down Expand Up @@ -328,7 +356,7 @@
?. ?=(%live +<.egg-any)
~& [dap.bowl %egg-any-not-live]
[~ this]
(on-load -:!>(*state-0) +>.old-state.egg-any)
(on-load -:!>(*state-1) +>.old-state.egg-any)
==
==
::
Expand All @@ -343,7 +371,10 @@
|= [=wire =sign:agent:gall]
~| wire=wire
?+ wire ~|(%strange-wire !!)
[%contacts %ours ~]
[%contacts %news ~]
?. ?=(%fact -.sign) `this
=+ !<(=news-0:co q.cage.sign)
?. =(our.bowl who.news-0) `this
=^ caz state update-group-widgets:do
[caz this]
==
Expand Down
10 changes: 5 additions & 5 deletions desk/app/profile/widgets.hoon
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
:: profile: construct stock widgets
::
/- contacts-0
/- co=contacts-0
/+ sigil
::
|= =bowl:gall
=/ ours=(unit contact-0:contacts-0)
=, contacts-0
=/ ours=(unit contact-0:co)
=, co
::NOTE we scry for the full rolodex, because we are not guaranteed to
:: have an entry for ourselves, and contacts doesn't expose a "safe"
:: (as in crashless) endpoint for checking
Expand Down Expand Up @@ -160,7 +160,7 @@
=src "{(trip u.avatar.u.ours)}"
=alt "Avatar";
=/ value=@ux ?~(ours 0x0 color.u.ours)
=/ color=tape ((x-co:co 6) value)
=/ color=tape ((x-co:^co 6) value)
;div.profile-headline-avatar-sigil(style "background-color: #{color}")
;+ %. our.bowl
%_ sigil
Expand Down Expand Up @@ -192,7 +192,7 @@
=src "{(trip u.avatar.u.ours)}"
=alt "Avatar";
=/ value=@ux ?~(ours 0x0 color.u.ours)
=/ color=tape ((x-co:co 6) value)
=/ color=tape ((x-co:^co 6) value)
;div.profile-headline-avatar-sigil(style "background-color: #{color}")
;+ %. our.bowl
%_ sigil
Expand Down