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: read contacts fields safely #4281

Merged
merged 1 commit into from
Dec 13, 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
profile: read contacts fields safely
types. It checked for the tags on values found in the map. However, it's
possible for values to be null, in which case trying to grab the head
would crash at runtime.

Here, we update the typecheck to check on the full value as opposed to
just the head.

Since this crashing code might have run in response to a contacts
subscription update, killing the subscription, we add a bit of logic to
+on-load to ensure that the contacts subscription gets set up again if
needed.
  • Loading branch information
Fang- committed Dec 13, 2024
commit 5859eca6a1304af50a6bb8392178b729f8ad836a
5 changes: 5 additions & 0 deletions desk/app/profile.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@
:~ [%pass /contacts/ours %agent [our.bowl %contacts] %leave ~]
[%pass /contacts/news %agent [our.bowl %contacts] %watch /news]
==
:: ensure contacts subscription is in place
::
=? caz &(!?=(%0 ver) !(~(has by wex.bowl) /contacts/news our.bowl %contacts))
%+ snoc caz
[%pass /contacts/news %agent [our.bowl %contacts] %watch /news]
[caz this]
::
+$ versioned-state
Expand Down
10 changes: 5 additions & 5 deletions desk/app/profile/widgets.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
==
::NOTE can't quite make a nice helper for this, wetness not wet enough...
=/ nickname=(unit @t) =+ a=(~(gut by contact) %nickname %text '')
?:(&(?=(%text -.a) !=('' +.a)) `+.a ~)
?:(&(?=([%text *] a) !=('' +.a)) `+.a ~)
=/ bio=(unit @t) =+ a=(~(gut by contact) %bio %text '')
?:(&(?=(%text -.a) !=('' +.a)) `+.a ~)
?:(&(?=([%text *] a) !=('' +.a)) `+.a ~)
=/ color=@ux =+ a=(~(gut by contact) %color %tint 0x0)
?:(?=(%tint -.a) +.a 0x0)
?:(?=([%tint *] a) +.a 0x0)
=/ avatar=(unit @ta) =+ a=(~(gut by contact) %avatar %look '')
?:(&(?=(%look -.a) !=('' +.a)) `+.a ~)
?:(&(?=([%look *] a) !=('' +.a)) `+.a ~)
=/ cover=(unit @ta) =+ a=(~(gut by contact) %cover %look '')
?:(&(?=(%look -.a) !=('' +.a)) `+.a ~)
?:(&(?=([%look *] a) !=('' +.a)) `+.a ~)
|^ %- ~(gas by *(map term [%0 @t %marl marl]))
:~ [%profile %0 'Profile Header' %marl profile-widget]
[%profile-bio %0 'Profile Bio' %marl profile-bio]
Expand Down
Loading