urbit/pkg/arvo/lib/launch-store.hoon

128 lines
2.6 KiB
Plaintext
Raw Normal View History

2020-05-20 22:12:53 +03:00
/- sur=launch-store
^?
=< [sur .]
=, sur
|%
++ enjs
=, enjs:format
|%
++ update
|= upd=^update
^- json
|^ (frond %launch-update (pairs ~[(encode upd)]))
::
++ encode
|= upd=^update
^- [cord json]
?- -.upd
%add
:- %add
%- pairs
:~ [%name s+name.upd]
[%tile (tile tile.upd)]
==
::
%remove [%remove s+name.upd]
%change-order [%'changeOrder' (terms tile-ordering.upd)]
%change-first-time [%'changeFirstTime' b+first-time.upd]
%change-is-shown
:- %'changeIsShown'
2020-05-20 22:12:53 +03:00
%- pairs
:~ [%name s+name.upd]
[%'isShown' b+is-shown.upd]
2020-05-20 22:12:53 +03:00
==
::
%initial
:- %initial
%- pairs
:~ [%tiles (tiles tiles.upd)]
[%'tileOrdering' (terms tile-ordering.upd)]
[%'firstTime' b+first-time.upd]
==
::
%keys [%keys (terms ~(tap in keys.upd))]
==
::
++ tile
|= =^tile
^- json
%- pairs
:~ [%type (tile-type type.tile)]
[%'isShown' b+is-shown.tile]
==
::
++ tiles
|= =^tiles
^- json
%- pairs
%+ turn ~(tap by tiles)
|= [=term til=^tile]
[term (tile til)]
::
++ tile-type
|= type=^tile-type
^- json
?- -.type
%basic
%+ frond %basic
%- pairs
:~ [%title s+title.type]
[%'iconUrl' s+icon-url.type]
[%'linkedUrl' s+linked-url.type]
==
::
2021-04-26 23:12:11 +03:00
%custom
%+ frond %custom
%- pairs
:~ [%'linkedUrl' ?~(linked-url.type ~ s+u.linked-url.type)]
[%'image' ?~(image.type ~ s+u.image.type)]
==
2020-05-20 22:12:53 +03:00
==
::
++ terms
|= terms=(list term)
^- json
[%a (turn terms |=(=term s+term))]
--
--
::
++ dejs
=, dejs:format
|%
++ action
|= =json
^- ^action
|^ (decode json)
++ decode
%- of
:~ [%add (ot [[%name (su sym)] [%tile tile] ~])]
[%remove (su sym)]
[%change-order (ar (su sym))]
[%change-first-time bo]
[%change-is-shown (ot [[%name (su sym)] [%'isShown' bo] ~])]
==
--
::
++ tile
|^
%- ot
:~ [%type tile-type]
[%'isShown' bo]
==
::
2021-04-26 23:12:11 +03:00
++ tile-type
2020-05-20 22:12:53 +03:00
%- of
:~ [%basic basic]
2021-04-26 23:12:11 +03:00
[%custom (ot [%'linkedUrl' (mu so)] [%'image' (mu so)] ~)]
2020-05-20 22:12:53 +03:00
==
::
++ basic
%- ot
:~ [%title so]
[%'iconUrl' so]
[%'linkedUrl' so]
==
--
--
--