2020-09-01 04:54:39 +03:00
|
|
|
:: contact-store [landscape]:
|
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
:: data store that holds individual contact data
|
2019-11-19 01:41:08 +03:00
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
/- store=contact-store
|
|
|
|
/+ default-agent, dbug, *migrate
|
2019-12-10 02:13:52 +03:00
|
|
|
|%
|
|
|
|
+$ card card:agent:gall
|
2021-01-08 01:49:24 +03:00
|
|
|
+$ state-4 [%4 =rolodex:store]
|
2019-12-10 02:13:52 +03:00
|
|
|
+$ versioned-state
|
2021-01-08 01:49:24 +03:00
|
|
|
$% [%0 *]
|
|
|
|
[%1 *]
|
|
|
|
[%2 *]
|
|
|
|
[%3 *]
|
|
|
|
state-4
|
2020-07-23 10:54:45 +03:00
|
|
|
==
|
2019-12-10 02:13:52 +03:00
|
|
|
--
|
2019-11-19 01:41:08 +03:00
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
=| state-4
|
2019-12-10 02:13:52 +03:00
|
|
|
=* state -
|
2020-03-12 03:33:48 +03:00
|
|
|
%- agent:dbug
|
2019-12-10 02:13:52 +03:00
|
|
|
^- agent:gall
|
2021-01-08 01:49:24 +03:00
|
|
|
|_ =bowl:gall
|
|
|
|
+* this .
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
|
|
|
::
|
|
|
|
++ on-init on-init:def
|
|
|
|
++ on-save !>(state)
|
|
|
|
++ on-load
|
|
|
|
|= old-vase=vase
|
|
|
|
^- (quip card _this)
|
|
|
|
=/ old !<(versioned-state old-vase)
|
2021-01-11 22:39:36 +03:00
|
|
|
?+ -.old [~ this]
|
|
|
|
%4 [~ this(state old)]
|
2021-01-08 01:49:24 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ on-watch
|
|
|
|
|= =path
|
|
|
|
^- (quip card _this)
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
|^
|
|
|
|
=/ cards=(list card)
|
|
|
|
?+ path (on-watch:def path)
|
|
|
|
[%updates ~] ~
|
|
|
|
==
|
|
|
|
[cards this]
|
2019-12-10 02:13:52 +03:00
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
++ give
|
|
|
|
|= =cage
|
|
|
|
^- (list card)
|
|
|
|
[%give %fact ~ cage]~
|
|
|
|
--
|
|
|
|
::
|
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
|^
|
|
|
|
=^ cards state
|
|
|
|
?+ mark (on-poke:def mark vase)
|
|
|
|
%contact-update (update !<(update:store vase))
|
|
|
|
%import (import q.vase)
|
|
|
|
==
|
|
|
|
[cards this]
|
2019-12-10 02:13:52 +03:00
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
++ update
|
|
|
|
|= =update:store
|
|
|
|
^- (quip card _state)
|
2019-12-10 02:13:52 +03:00
|
|
|
|^
|
2021-01-08 01:49:24 +03:00
|
|
|
?- -.update
|
|
|
|
%initial (handle-initial +.update)
|
|
|
|
%add (handle-add +.update)
|
|
|
|
%remove (handle-remove +.update)
|
|
|
|
%edit (handle-edit +.update)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ handle-initial
|
|
|
|
|= rolo=rolodex:store
|
|
|
|
^- (quip card _state)
|
|
|
|
=. rolodex (~(uni by rolodex) rolo)
|
|
|
|
:_ state(rolodex rolodex)
|
|
|
|
(send-diff [%initial rolodex])
|
|
|
|
::
|
|
|
|
++ handle-add
|
|
|
|
|= [=ship =contact:store]
|
|
|
|
^- (quip card _state)
|
|
|
|
?< (~(has by rolodex) ship)
|
|
|
|
:- (send-diff [%add ship contact])
|
|
|
|
state(rolodex (~(put by rolodex) ship contact))
|
|
|
|
::
|
|
|
|
++ handle-remove
|
|
|
|
|= =ship
|
|
|
|
^- (quip card _state)
|
|
|
|
?> (~(has by rolodex) ship)
|
|
|
|
:- (send-diff [%remove ship])
|
|
|
|
state(rolodex (~(del by rolodex) ship))
|
|
|
|
::
|
|
|
|
++ handle-edit
|
|
|
|
|= [=ship =edit-field:store]
|
|
|
|
^- (quip card _state)
|
|
|
|
=/ contact (~(got by rolodex) ship)
|
|
|
|
=. contact (edit-contact contact edit-field)
|
|
|
|
:- (send-diff [%edit ship edit-field])
|
|
|
|
state(rolodex (~(put by rolodex) ship contact))
|
|
|
|
::
|
|
|
|
++ edit-contact
|
|
|
|
|= [=contact:store edit=edit-field:store]
|
|
|
|
^- contact:store
|
|
|
|
?- -.edit
|
|
|
|
%nickname contact(nickname nickname.edit)
|
|
|
|
%email contact(email email.edit)
|
|
|
|
%phone contact(phone phone.edit)
|
|
|
|
%website contact(website website.edit)
|
|
|
|
%color contact(color color.edit)
|
|
|
|
%avatar contact(avatar avatar.edit)
|
2019-12-10 02:13:52 +03:00
|
|
|
==
|
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
++ send-diff
|
|
|
|
|= =update:store
|
2019-12-10 02:13:52 +03:00
|
|
|
^- (list card)
|
2021-01-08 01:49:24 +03:00
|
|
|
[%give %fact ~[/updates] %contact-update !>(update)]~
|
2019-12-10 02:13:52 +03:00
|
|
|
--
|
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
++ import
|
|
|
|
|= arc=*
|
|
|
|
^- (quip card _state)
|
2021-01-11 22:39:36 +03:00
|
|
|
:: note: we are purposefully wiping all state before state-4
|
2021-01-08 01:49:24 +03:00
|
|
|
[~ *state-4]
|
2019-12-10 02:13:52 +03:00
|
|
|
--
|
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
++ on-peek
|
2019-12-10 02:13:52 +03:00
|
|
|
|= =path
|
2021-01-08 01:49:24 +03:00
|
|
|
^- (unit (unit cage))
|
|
|
|
?+ path (on-peek:def path)
|
|
|
|
[%x %all ~] ``noun+!>(rolodex)
|
|
|
|
[%x %export ~] ``noun+!>(state)
|
|
|
|
::
|
|
|
|
[%x %contact @ ~]
|
|
|
|
=/ =ship (slav %p i.t.t.path)
|
|
|
|
=/ contact=(unit contact:store) (~(get by rolodex) ship)
|
|
|
|
?~ contact ~
|
|
|
|
:- ~ :- ~ :- %contact-update
|
|
|
|
!> ^- update:store
|
|
|
|
[%add ship u.contact]
|
2019-11-19 01:41:08 +03:00
|
|
|
==
|
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-agent on-agent:def
|
|
|
|
++ on-arvo on-arvo:def
|
|
|
|
++ on-fail on-fail:def
|
2019-11-19 01:41:08 +03:00
|
|
|
--
|