contacts: ported to static gall

This commit is contained in:
Logan Allen 2019-12-09 15:13:52 -08:00
parent c8020691f8
commit ad64763a8c
4 changed files with 228 additions and 240 deletions

View File

@ -1,13 +1,9 @@
/+ *contact-json :: contact-store: data store that holds group-based contact data
::
/+ *contact-json, default-agent
|% |%
+$ move [bone card] +$ card card:agent:gall
:: +$ versioned-state
+$ card
$% [%diff [%contact-update contact-update]]
[%quit ~]
==
::
+$ state
$% state-zero $% state-zero
== ==
:: ::
@ -15,70 +11,90 @@
$: %0 $: %0
=rolodex =rolodex
== ==
+$ diff
$% [%contact-update contact-update]
==
-- --
:: ::
|_ [bol=bowl:gall state-zero] =| state-zero
=* state -
^- agent:gall
=<
|_ =bowl:gall
+* this .
contact-core +>
cc ~(. contact-core bowl)
def ~(. (default-agent this %|) bowl)
::
++ on-init on-init:def
++ on-save !>(state)
++ on-load
|= old=vase
`this(state !<(state-zero old))
::
++ on-poke
|= [=mark =vase]
^- (quip card _this)
?> (team:title our.bowl src.bowl)
=^ cards state
?+ mark (on-poke:def mark vase)
::%json (poke-json:cc !<(json vase))
%contact-action (poke-contact-action:cc !<(contact-action vase))
==
[cards this]
::
++ on-watch
|= =path
^- (quip card _this)
?> (team:title our.bowl src.bowl)
|^
=/ cards=(list card)
?+ path (on-watch:def path)
[%all ~] (give %contact-update !>([%rolodex rolodex]))
[%updates ~] ~
[%contacts @ *]
%+ give %contact-update
!>([%contacts t.path (~(got by rolodex) t.path)])
==
[cards this]
::
++ give
|= =cage
^- (list card)
[%give %fact ~ cage]~
--
::
++ on-leave on-leave:def
++ on-peek
|= =path
^- (unit (unit cage))
?+ path (on-peek:def path)
[%x %all ~] ``noun+!>(rolodex)
[%x %contacts *]
?~ t.t.path
~
``noun+!>((~(get by rolodex) t.t.path))
::
[%x %contacts *]
:: /:path/:ship
=/ pax `^path`(flop t.t.path)
?~ pax ~
=/ =ship (slav %p i.pax)
?~ t.pax ~
=> .(pax `(list @ta)`(flop t.pax))
=/ contacts=(unit contacts) (~(get by rolodex) pax)
?~ contacts
~
``noun+!>((~(get by u.contacts) ship))
==
::
++ on-agent on-agent:def
++ on-arvo on-arvo:def
++ on-fail on-fail:def
--
:: ::
++ this .
:: ::
++ prep |_ bol=bowl:gall
|= old=(unit state)
^- (quip move _this)
:- ~
?~ old this
?- -.old
%0 this(+<+ u.old)
==
::
++ peek-x-all
|= pax=path
^- (unit (unit [%noun (map path contacts)]))
[~ ~ %noun rolodex]
::
++ peek-x-contacts
|= pax=path
^- (unit (unit [%noun (unit contacts)]))
?~ pax
~
=/ contacts=(unit contacts) (~(get by rolodex) pax)
[~ ~ %noun contacts]
::
++ peek-x-contact
|= pax=path
^- (unit (unit [%noun (unit contact)]))
:: /:path/:ship
=/ pas (flop pax)
?~ pas
~
=/ =ship (slav %p i.pas)
=. pax (scag (dec (lent pax)) `(list @ta)`pax)
=/ contacts=(unit contacts) (~(get by rolodex) pax)
?~ contacts
~
=/ contact=(unit contact) (~(get by u.contacts) ship)
[~ ~ %noun contact]
::
++ peer-all
|= pax=path
^- (quip move _this)
?> (team:title our.bol src.bol)
:: send all updates from now on
:_ this
[ost.bol %diff %contact-update [%rolodex rolodex]]~
::
++ peer-updates
|= pax=path
^- (quip move _this)
?> (team:title our.bol src.bol)
:: send all updates from now on
[~ this]
::
++ peer-contacts
|= pax=path
^- (quip move _this)
?> (team:title our.bol src.bol)
:_ this
[ost.bol %diff %contact-update [%contacts pax (~(got by rolodex) pax)]]~
:: ::
::++ poke-json ::++ poke-json
:: |= =json :: |= =json
@ -88,62 +104,57 @@
:: ::
++ poke-contact-action ++ poke-contact-action
|= action=contact-action |= action=contact-action
^- (quip move _this) ^- (quip card _state)
?> (team:title our.bol src.bol) ?> (team:title our.bol src.bol)
?- -.action ?- -.action
%create (handle-create action) %create (handle-create +.action)
%delete (handle-delete action) %delete (handle-delete +.action)
%add (handle-add action) %add (handle-add +.action)
%remove (handle-remove action) %remove (handle-remove +.action)
%edit (handle-edit action) %edit (handle-edit +.action)
== ==
:: ::
++ handle-create ++ handle-create
|= act=contact-action |= =path
^- (quip move _this) ^- (quip card _state)
?> ?=(%create -.act) ?< (~(has by rolodex) path)
?< (~(has by rolodex) path.act) :- (send-diff path [%create path])
:- (send-diff path.act act) state(rolodex (~(put by rolodex) path *contacts))
this(rolodex (~(put by rolodex) path.act *contacts))
:: ::
++ handle-delete ++ handle-delete
|= act=contact-action |= =path
^- (quip move _this) ^- (quip card _state)
?> ?=(%delete -.act) ?> (~(has by rolodex) path)
?> (~(has by rolodex) path.act) :- (send-diff path [%delete path])
:- (send-diff path.act act) state(rolodex (~(del by rolodex) path))
this(rolodex (~(del by rolodex) path.act))
:: ::
++ handle-add ++ handle-add
|= act=contact-action |= [=path =ship =contact]
^- (quip move _this) ^- (quip card _state)
?> ?=(%add -.act) =/ contacts (~(got by rolodex) path)
=/ contacts (~(got by rolodex) path.act) ?< (~(has by contacts) ship)
?< (~(has by contacts) ship.act) =. contacts (~(put by contacts) ship contact)
=. contacts (~(put by contacts) ship.act contact.act) :- (send-diff path [%add path ship contact])
:- (send-diff path.act act) state(rolodex (~(put by rolodex) path contacts))
this(rolodex (~(put by rolodex) path.act contacts))
:: ::
++ handle-remove ++ handle-remove
|= act=contact-action |= [=path =ship]
^- (quip move _this) ^- (quip card _state)
?> ?=(%remove -.act) =/ contacts (~(got by rolodex) path)
=/ contacts (~(got by rolodex) path.act) ?> (~(has by contacts) ship)
?> (~(has by contacts) ship.act) =. contacts (~(del by contacts) ship)
=. contacts (~(del by contacts) ship.act) :- (send-diff path [%remove path ship])
:- (send-diff path.act act) state(rolodex (~(put by rolodex) path contacts))
this(rolodex (~(put by rolodex) path.act contacts))
:: ::
++ handle-edit ++ handle-edit
|= act=contact-action |= [=path =ship =edit-field]
^- (quip move _this) ^- (quip card _state)
?> ?=(%edit -.act) =/ contacts (~(got by rolodex) path)
=/ contacts (~(got by rolodex) path.act) =/ contact (~(got by contacts) ship)
=/ contact (~(got by contacts) ship.act) =. contact (edit-contact contact edit-field)
=. contact (edit-contact contact edit-field.act) =. contacts (~(put by contacts) ship contact)
=. contacts (~(put by contacts) ship.act contact) :- (send-diff path [%edit path ship edit-field])
:- (send-diff path.act act) state(rolodex (~(put by rolodex) path contacts))
this(rolodex (~(put by rolodex) path.act contacts))
:: ::
++ edit-contact ++ edit-contact
|= [con=contact edit=edit-field] |= [con=contact edit=edit-field]
@ -159,15 +170,13 @@
== ==
:: ::
++ update-subscribers ++ update-subscribers
|= [pax=path upd=contact-update] |= [pax=path update=contact-update]
^- (list move) ^- (list card)
%+ turn (prey:pubsub:userlib pax bol) [%give %fact `pax %contact-update !>(update)]~
|= [=bone *]
[bone %diff %contact-update upd]
:: ::
++ send-diff ++ send-diff
|= [pax=path upd=contact-update] |= [pax=path upd=contact-update]
^- (list move) ^- (list card)
%- zing %- zing
:~ (update-subscribers /all upd) :~ (update-subscribers /all upd)
(update-subscribers /updates upd) (update-subscribers /updates upd)

View File

@ -2,7 +2,7 @@
:: into semantic actions for the UI :: into semantic actions for the UI
:: ::
/- *group-store /- *group-store
/+ *server, *contact-json /+ *server, *contact-json, default-agent
/= index /= index
/^ octs /^ octs
/; as-octs:mimes:html /; as-octs:mimes:html
@ -36,55 +36,90 @@
/: /===/app/contacts/img /_ /png/ /: /===/app/contacts/img /_ /png/
:: ::
|% |%
:: +$ card card:agent:gall
+$ move [bone card]
::
+$ card
$% [%http-response =http-event:http]
[%connect wire binding:eyre term]
[%quit ~]
[%peer wire dock path]
[%poke wire dock poke]
[%diff %json json]
==
::
+$ poke
$% [%launch-action [@tas path @t]]
[%contact-action contact-action]
[%group-action group-action]
==
-- --
:: ::
|_ [bol=bowl:gall ?] ^- agent:gall
:: =<
++ this . |_ =bowl:gall
:: +* this .
++ prep contact-core +>
|= old=(unit ?) cc ~(. contact-core bowl)
^- (quip move _this) def ~(. (default-agent this %|) bowl)
?~ old ::
++ on-init
^- (quip card _this)
:_ this :_ this
:~ [ost.bol %peer / [our.bol %contact-store] /updates] :~ [%pass /updates %agent [our.bowl %contact-store] %watch /updates]
[ost.bol %connect / [~ /'~contacts'] %contact-view] [%pass / %arvo %e %connect [~ /'~contacts'] %contact-view]
(launch-poke [/configs '/~contacts/js/tile.js']) (launch-poke:cc [%contact-view /primary '/~contacts/js/tile.js'])
(contact-poke [%create /~/default]) (contact-poke:cc [%create /~/default])
(group-poke [%bundle /~/default]) (group-poke:cc [%bundle /~/default])
(contact-poke [%add /~/default our.bol *contact]) (contact-poke:cc [%add /~/default our.bowl *contact])
(group-poke [%add [our.bol ~ ~] /~/default]) (group-poke:cc [%add [our.bowl ~ ~] /~/default])
== ==
[~ this(+<+ u.old)] ::
++ on-save on-save:def
++ on-load on-load:def
++ on-poke
|= [=mark =vase]
^- (quip card _this)
?> (team:title our.bowl src.bowl)
?+ mark (on-poke:def mark vase)
%json [(poke-json:cc !<(json vase)) this]
%handle-http-request
=+ !<([eyre-id=@ta =inbound-request:eyre] vase)
:_ this
%+ give-simple-payload:app eyre-id
%+ require-authorization:app inbound-request
poke-handle-http-request:cc
==
::
++ on-watch
|= =path
^- (quip card _this)
?> (team:title our.bowl src.bowl)
?: ?=([%http-response *] path) [~ this]
?. =(/primary path) (on-watch:def path)
[[%give %fact ~ %json !>((rolodex-to-json all-scry:cc))]~ this]
::
++ on-agent
|= [=wire =sign:agent:gall]
^- (quip card _this)
?+ -.sign (on-agent:def wire sign)
%kick
[[%pass / %agent [our.bol %contact-store] %watch /updates]~ this]
::
%fact
?+ p.cage.sign (on-agent:def wire sign)
%contact-update
=/ update=json (update-to-json !<(contact-update q.cage.sign))
[[%give %fact `/primary %json !>(update)]~ this]
==
==
::
++ on-arvo
|= [=wire =sign-arvo]
^- (quip card _this)
?. ?=(%bound +<.sign-arvo)
(on-arvo:def wire sign-arvo)
[~ this]
::
++ on-leave on-leave:def
++ on-peek on-peek:def
++ on-fail on-fail:def
--
:: ::
|_ bol=bowl:gall
++ poke-json ++ poke-json
|= jon=json |= jon=json
^- (quip move _this) ^- (list card)
?> (team:title our.bol src.bol) ?> (team:title our.bol src.bol)
(poke-contact-view-action (json-to-view-action jon)) (poke-contact-view-action (json-to-view-action jon))
:: ::
++ poke-contact-view-action ++ poke-contact-view-action
|= act=contact-view-action |= act=contact-view-action
^- (quip move _this) ^- (list card)
?> (team:title our.bol src.bol)
:_ this
?- -.act ?- -.act
%create %create
:~ (group-poke [%bundle path.act]) :~ (group-poke [%bundle path.act])
@ -106,95 +141,41 @@
(contact-poke [%remove path.act ship.act]) (contact-poke [%remove path.act ship.act])
== ==
== ==
::
++ peer-primary
|= pax=path
^- (quip move _this)
?> (team:title our.bol src.bol)
:: create inbox with 100 messages max per mailbox and send that along
:: then quit the subscription
:_ this
[ost.bol %diff %json (rolodex-to-json all-scry)]~
::
++ diff-contact-update
|= [wir=wire upd=contact-update]
^- (quip move _this)
=/ updates-json (update-to-json upd)
:_ this
%+ turn (prey:pubsub:userlib /primary bol)
|= [=bone *]
[bone %diff %json updates-json]
::
++ quit
|= wir=wire
^- (quip move _this)
:_ this
[ost.bol %peer / [our.bol %contact-store] /updates]~
::
++ poke-handle-http-request ++ poke-handle-http-request
%- (require-authorization:app ost.bol move this)
|= =inbound-request:eyre |= =inbound-request:eyre
^- (quip move _this) ^- simple-payload:http
::
=+ url=(parse-request-line url.request.inbound-request) =+ url=(parse-request-line url.request.inbound-request)
=/ name=@t =/ name=@t
=+ back-path=(flop site.url) =+ back-path=(flop site.url)
?~ back-path ?~ back-path
'' ''
i.back-path i.back-path
?: =(name 'tile') ?+ site.url not-found:gen
[[ost.bol %http-response (js-response:app tile-js)]~ this] [%'~contacts' %css %index ~] (css-response:gen style)
?+ site.url [%'~contacts' %js %index ~] (js-response:gen script)
:_ this [%'~contacts' %js %tile ~] (js-response:gen tile-js)
[ost.bol %http-response not-found:app]~
::
:: styling
::
[%'~contacts' %css %index ~]
:_ this
[ost.bol %http-response (css-response:app style)]~
::
:: javascript
::
[%'~contacts' %js %index ~]
:_ this
[ost.bol %http-response (js-response:app script)]~
::
:: images
::
[%'~contacts' %img *] [%'~contacts' %img *]
=/ img (as-octs:mimes:html (~(got by contact-png) `@ta`name)) (png-response:gen (as-octs:mimes:html (~(got by contact-png) `@ta`name)))
:_ this
[ost.bol %http-response (png-response:app img)]~
:: ::
:: main page [%'~contacts' *] (html-response:gen index)
::
[%'~contacts' *]
:_ this
[ost.bol %http-response (html-response:app index)]~
== ==
:: ::
++ bound
|= [wir=wire success=? binding=binding:eyre]
^- (quip move _this)
[~ this]
::
:: +utilities :: +utilities
:: ::
++ contact-poke ++ contact-poke
|= act=contact-action |= act=contact-action
^- move ^- card
[ost.bol %poke / [our.bol %contact-store] [%contact-action act]] [%pass / %agent [our.bol %contact-store] %poke %contact-action !>(act)]
:: ::
++ launch-poke ++ launch-poke
|= [pax=path =cord] |= act=[@tas path @t]
^- move ^- card
[ost.bol %poke / [our.bol %launch] [%launch-action [%contact-view pax cord]]] [%pass / %agent [our.bol %launch] %poke %launch-action !>(act)]
:: ::
++ group-poke ++ group-poke
|= act=group-action |= act=group-action
^- move ^- card
[ost.bol %poke / [our.bol %group-store] [%group-action act]] [%pass / %agent [our.bol %group-store] %poke %group-action !>(act)]
:: ::
++ all-scry ++ all-scry
^- rolodex ^- rolodex

View File

@ -32308,7 +32308,6 @@
global$2[key$1] = "esm"; global$2[key$1] = "esm";
} }
} }
//# sourceMappingURL=react-router.js.map
/** /**
* The public API for a <Router> that uses HTML5 history. * The public API for a <Router> that uses HTML5 history.
@ -32608,7 +32607,6 @@
style: propTypes.object style: propTypes.object
}); });
} }
//# sourceMappingURL=react-router-dom.js.map
var classnames = createCommonjsModule(function (module) { var classnames = createCommonjsModule(function (module) {
/*! /*!
@ -58761,7 +58759,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
let subscription = new Subscription(); let subscription = new Subscription();
const _jsxFileName = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/lib/icons/icon-home.js"; const _jsxFileName = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/lib/icons/icon-home.js";
class IconHome extends react_1 { class IconHome extends react_1 {
render() { render() {
return ( return (
@ -58770,7 +58768,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
} }
} }
const _jsxFileName$1 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/lib/icons/icon-spinner.js"; const _jsxFileName$1 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/lib/icons/icon-spinner.js";
class IconSpinner extends react_1 { class IconSpinner extends react_1 {
render() { render() {
return ( return (
@ -58779,7 +58777,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
} }
} }
const _jsxFileName$2 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/lib/header-bar.js"; const _jsxFileName$2 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/lib/header-bar.js";
class HeaderBar extends react_1 { class HeaderBar extends react_1 {
render() { render() {
let spin = (this.props.spinner) let spin = (this.props.spinner)
@ -58807,7 +58805,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
} }
} }
const _jsxFileName$3 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/lib/groups-item.js"; const _jsxFileName$3 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/lib/groups-item.js";
class GroupsItem extends react_1 { class GroupsItem extends react_1 {
render() { render() {
const { props } = this; const { props } = this;
@ -62693,7 +62691,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
var dist_2 = dist.sigil; var dist_2 = dist.sigil;
var dist_3 = dist.stringRenderer; var dist_3 = dist.stringRenderer;
const _jsxFileName$4 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/lib/icons/sigil.js"; const _jsxFileName$4 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/lib/icons/sigil.js";
class Sigil extends react_1 { class Sigil extends react_1 {
render() { render() {
@ -62719,7 +62717,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
} }
} }
const _jsxFileName$5 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/groups.js"; const _jsxFileName$5 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/groups.js";
class Groups extends react_1 { class Groups extends react_1 {
// drawer to the left // drawer to the left
@ -62790,7 +62788,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
} }
} }
const _jsxFileName$6 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/skeleton.js"; const _jsxFileName$6 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/skeleton.js";
class Skeleton extends react_1 { class Skeleton extends react_1 {
render() { render() {
let rightPanelClasses = let rightPanelClasses =
@ -62820,7 +62818,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
} }
} }
const _jsxFileName$7 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/lib/new.js"; const _jsxFileName$7 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/lib/new.js";
class NewScreen extends react_1 { class NewScreen extends react_1 {
constructor(props) { constructor(props) {
super(props); super(props);
@ -62919,7 +62917,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
} }
} }
const _jsxFileName$8 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/lib/contact-item.js"; const _jsxFileName$8 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/lib/contact-item.js";
class ContactItem extends react_1 { class ContactItem extends react_1 {
render() { render() {
@ -62942,7 +62940,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
} }
} }
const _jsxFileName$9 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/contacts.js"; const _jsxFileName$9 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/contacts.js";
class Contacts extends react_1 { class Contacts extends react_1 {
render() { render() {
const { props } = this; const { props } = this;
@ -62979,7 +62977,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
} }
} }
const _jsxFileName$a = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/lib/card.js"; const _jsxFileName$a = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/lib/card.js";
class ContactCard extends react_1 { class ContactCard extends react_1 {
render() { render() {
return ( return (
@ -62992,7 +62990,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
} }
} }
const _jsxFileName$b = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/root.js"; const _jsxFileName$b = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/root.js";
class Root extends react_1 { class Root extends react_1 {
constructor(props) { constructor(props) {
@ -63109,7 +63107,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
} }
} }
const _jsxFileName$c = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/index.js"; const _jsxFileName$c = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/index.js";
api.setAuthTokens({ api.setAuthTokens({
ship: window.ship ship: window.ship
}); });

View File

@ -19377,7 +19377,7 @@
}.call(commonjsGlobal)); }.call(commonjsGlobal));
}); });
const _jsxFileName = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/tile/tile.js"; const _jsxFileName = "/Users/logan/Dev/urbit/pkg/interface/contacts/tile/tile.js";
class ContactTile extends react_1 { class ContactTile extends react_1 {