mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-21 05:41:43 +03:00
Merge branch 'master' into release/next-vere
* master: (151 commits) build: check subdirs on tsc meta: auto-deploy release/next-userspace glob: update to 0v4.vrvkt.4gcnm.dgg5o.e73d6.kqnaq OmniboxResult: fix arg order glob: update to 0v3.p4se6.4k5i0.8v0le.v5vn4.mdotq hooks: reset diplomacy interface: package audit interface: stringify number prop graph: added comments links: remove stray semicolon graph-push-hook: only cache marks, do not cache metadata for a graph graph-push-hook: code style cleaning push-hook: clean-up code style graph-store: internally cache all scried daises graph-push-hook: rename mark for cache action demo-push-hook: update for new push-hook interface hover permalinks: add group peer space notifications: key notifications correctly DeleteGroup: fix copy ...
This commit is contained in:
commit
68a19287ab
2
.github/workflows/glob.yml
vendored
2
.github/workflows/glob.yml
vendored
@ -2,7 +2,7 @@ name: glob
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'release/next-js'
|
||||
- 'release/next-userspace'
|
||||
jobs:
|
||||
glob:
|
||||
runs-on: ubuntu-latest
|
||||
|
4
.github/workflows/merge-master.yml
vendored
4
.github/workflows/merge-master.yml
vendored
@ -6,13 +6,13 @@ on:
|
||||
jobs:
|
||||
merge-to-next-js:
|
||||
runs-on: ubuntu-latest
|
||||
name: "Merge master to release/next-js"
|
||||
name: "Merge master to release/next-userspace"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: devmasx/merge-branch@v1.3.1
|
||||
with:
|
||||
type: now
|
||||
target_branch: release/next-js
|
||||
target_branch: release/next-userspace
|
||||
github_token: ${{ secrets.JANEWAY_BOT_TOKEN }}
|
||||
|
||||
merge-to-group-timer:
|
||||
|
14
.github/workflows/typescript-check.yml
vendored
Normal file
14
.github/workflows/typescript-check.yml
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
name: typescript-check
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'pkg/interface/**'
|
||||
|
||||
jobs:
|
||||
typescript-check:
|
||||
runs-on: ubuntu-latest
|
||||
name: "Check pkg/interface types"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: cd 'pkg/interface' && npm i && npm run tsc
|
@ -309,9 +309,9 @@ the new binary, and restarting the pier with it.
|
||||
#### Continuous deployment
|
||||
|
||||
A subset of release branches are deployed continuously to the network. Thus far
|
||||
this only includes `release/next-js`, which deploys livenet-compatible
|
||||
JavaScript changes to select QA ships. Any push to master will automatically
|
||||
merge master into `release/next-js` to keep the streams at parity.
|
||||
this only includes `release/next-userspace`, which deploys livenet-compatible
|
||||
changes to select QA ships. Any push to master will automatically
|
||||
merge master into `release/next-userspace` to keep the streams at parity.
|
||||
|
||||
### Announce the update
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e1656cbfd472430c463db4e968c1dd4c8894a5219a27cd301a70ad262f5999f1
|
||||
size 10610939
|
||||
oid sha256:d7b7cf24e56ab078cf1dcb82e4e7744f188c5221c08772d6cfb15f59ce81aaa5
|
||||
size 11198219
|
||||
|
@ -1394,8 +1394,6 @@
|
||||
^+ this
|
||||
?: =(~ dom)
|
||||
~|(%acme-empty-certificate-order !!)
|
||||
?: ?=(?(%earl %pawn) (clan:title our.bow))
|
||||
this
|
||||
=. ..emit (queue-next-order 1 | dom)
|
||||
=. ..emit cancel-current-order
|
||||
:: notify %dill
|
||||
|
@ -738,6 +738,7 @@
|
||||
::
|
||||
?. (is-chat-graph target)
|
||||
[[(note:sh-out "no such chat")]~ put-ses]
|
||||
=. audience target
|
||||
=. viewing (~(put in viewing) target)
|
||||
=^ cards state
|
||||
?: (~(has by bound) target)
|
||||
|
@ -70,10 +70,11 @@
|
||||
::
|
||||
++ transform-proxy-update
|
||||
|= vas=vase
|
||||
^- (unit vase)
|
||||
^- (quip card (unit vase))
|
||||
:: TODO: should check if user is allowed to %add, %remove, %edit
|
||||
:: contact
|
||||
=/ =update:store !<(update:store vas)
|
||||
:- ~
|
||||
?- -.update
|
||||
%initial ~
|
||||
%add `vas
|
||||
|
@ -43,8 +43,8 @@
|
||||
::
|
||||
++ transform-proxy-update
|
||||
|= vas=vase
|
||||
^- (unit vase)
|
||||
`vas
|
||||
^- (quip card (unit vase))
|
||||
``vas
|
||||
::
|
||||
++ resource-for-update
|
||||
|= =vase
|
||||
|
@ -188,8 +188,11 @@
|
||||
?: ?=([%'~landscape' %js %session ~] site.req-line)
|
||||
%+ require-authorization-simple:app
|
||||
inbound-request
|
||||
%- js-response:gen
|
||||
(as-octt:mimes:html "window.ship = '{+:(scow %p our.bowl)}';")
|
||||
%. %- as-octs:mimes:html
|
||||
(rap 3 'window.ship = "' (rsh 3 (scot %p our.bowl)) '";' ~)
|
||||
%* . js-response:gen
|
||||
cache %.n
|
||||
==
|
||||
::
|
||||
=/ [payload=simple-payload:http public=?] (get-file req-line is-file)
|
||||
?: public payload
|
||||
@ -222,6 +225,7 @@
|
||||
[~ %js] (js-response:gen file)
|
||||
[~ %css] (css-response:gen file)
|
||||
[~ %png] (png-response:gen file)
|
||||
[~ %ico] (ico-response:gen file)
|
||||
::
|
||||
[~ %html]
|
||||
%. file
|
||||
@ -238,11 +242,9 @@
|
||||
[not-found:gen %.n]
|
||||
:_ public.u.content
|
||||
=/ mime-type=@t (rsh 3 (crip <p.u.data>))
|
||||
:: Should maybe inspect to see how long cache should hold
|
||||
::
|
||||
=/ headers
|
||||
:~ content-type+mime-type
|
||||
max-1-da:gen
|
||||
max-1-wk:gen
|
||||
'service-worker-allowed'^'/'
|
||||
==
|
||||
[[200 headers] `q.u.data]
|
||||
|
@ -5,7 +5,7 @@
|
||||
/- glob
|
||||
/+ default-agent, verb, dbug
|
||||
|%
|
||||
++ hash 0v7.dmf2h.884m6.b2p1b.l1and.uv1lv
|
||||
++ hash 0v4.vrvkt.4gcnm.dgg5o.e73d6.kqnaq
|
||||
+$ state-0 [%0 hash=@uv glob=(unit (each glob:glob tid=@ta))]
|
||||
+$ all-states
|
||||
$% state-0
|
||||
|
@ -1,6 +1,6 @@
|
||||
/- *group, metadata=metadata-store
|
||||
/+ store=graph-store, mdl=metadata, res=resource, graph, group, default-agent,
|
||||
dbug, verb, push-hook
|
||||
dbug, verb, push-hook, agentio
|
||||
::
|
||||
~% %graph-push-hook-top ..part ~
|
||||
|%
|
||||
@ -25,6 +25,25 @@
|
||||
$% state-zero
|
||||
state-one
|
||||
==
|
||||
::
|
||||
:: TODO: come back to this and potentially use send a %t
|
||||
:: to be notified of validator changes
|
||||
+$ cache
|
||||
$: graph-to-mark=(map resource:res (unit mark))
|
||||
perm-marks=(map [mark @tas] tube:clay)
|
||||
transform-marks=(map mark tube:clay)
|
||||
==
|
||||
::
|
||||
+$ inflated-state
|
||||
$: state-one
|
||||
cache
|
||||
==
|
||||
::
|
||||
+$ cache-action
|
||||
$% [%graph-to-mark (pair resource:res (unit mark))]
|
||||
[%perm-marks (pair (pair mark @tas) tube:clay)]
|
||||
[%transform-marks (pair mark tube:clay)]
|
||||
==
|
||||
--
|
||||
::
|
||||
%- agent:dbug
|
||||
@ -33,7 +52,8 @@
|
||||
%- (agent:push-hook config)
|
||||
^- agent
|
||||
=-
|
||||
=| state-one
|
||||
~% %graph-push-hook-agent ..scry.hook-core ~
|
||||
=| inflated-state
|
||||
=* state -
|
||||
|_ =bowl:gall
|
||||
+* this .
|
||||
@ -41,10 +61,11 @@
|
||||
grp ~(. group bowl)
|
||||
gra ~(. graph bowl)
|
||||
met ~(. mdl bowl)
|
||||
hc ~(. hook-core bowl)
|
||||
hc ~(. hook-core bowl +.state)
|
||||
io ~(. agentio bowl)
|
||||
::
|
||||
++ on-init on-init:def
|
||||
++ on-save !>(state)
|
||||
++ on-save !>(-.state)
|
||||
++ on-load
|
||||
|= =vase
|
||||
=+ !<(old=versioned-state vase)
|
||||
@ -53,9 +74,26 @@
|
||||
=? old ?=(%0 -.old)
|
||||
[%1 ~]
|
||||
?> ?=(%1 -.old)
|
||||
`this(state old)
|
||||
`this(-.state old, +.state *cache)
|
||||
::
|
||||
++ on-poke
|
||||
|= [=mark =vase]
|
||||
^- (quip card _this)
|
||||
?. =(mark %graph-cache-hook)
|
||||
[~ this]
|
||||
=/ a=cache-action !<(cache-action vase)
|
||||
=* c +.state
|
||||
=* graph-to-mark graph-to-mark.c
|
||||
=* perm-marks perm-marks.c
|
||||
=* transform-marks transform-marks.c
|
||||
=. c
|
||||
?- -.a
|
||||
%graph-to-mark c(graph-to-mark (~(put by graph-to-mark) p.a q.a))
|
||||
%perm-marks c(perm-marks (~(put by perm-marks) p.a q.a))
|
||||
%transform-marks c(transform-marks (~(put by transform-marks) p.a q.a))
|
||||
==
|
||||
[~ this(+.state c)]
|
||||
::
|
||||
++ on-poke on-poke:def
|
||||
++ on-agent on-agent:def
|
||||
++ on-watch on-watch:def
|
||||
++ on-leave on-leave:def
|
||||
@ -72,22 +110,39 @@
|
||||
::
|
||||
++ on-fail on-fail:def
|
||||
++ transform-proxy-update
|
||||
~/ %transform-proxy-update
|
||||
|= vas=vase
|
||||
^- (unit vase)
|
||||
^- (quip card (unit vase))
|
||||
=/ =update:store !<(update:store vas)
|
||||
=* rid resource.q.update
|
||||
=. p.update now.bowl
|
||||
?- -.q.update
|
||||
%add-nodes
|
||||
?. (is-allowed-add:hc rid nodes.q.update)
|
||||
~
|
||||
=/ mark (get-mark:gra rid)
|
||||
?~ mark `vas
|
||||
|^
|
||||
=| cards=(list card)
|
||||
=^ allowed cards (is-allowed-add:hc rid nodes.q.update)
|
||||
?. allowed
|
||||
[cards ~]
|
||||
=/ mark-cached (~(has by graph-to-mark) rid)
|
||||
=/ mark
|
||||
?: mark-cached
|
||||
(~(got by graph-to-mark) rid)
|
||||
(get-mark:gra rid)
|
||||
?~ mark
|
||||
[cards `vas]
|
||||
=< $
|
||||
~% %transform-add-nodes ..transform-proxy-update ~
|
||||
|%
|
||||
++ $
|
||||
^- (quip card (unit vase))
|
||||
=/ transform-cached (~(has by transform-marks) u.mark)
|
||||
=/ =tube:clay
|
||||
?: transform-cached
|
||||
(~(got by transform-marks) u.mark)
|
||||
.^(tube:clay (scry:hc %cc %home /[u.mark]/transform-add-nodes))
|
||||
=/ transform
|
||||
!< $-([index:store post:store atom ?] [index:store post:store])
|
||||
%. !>(*indexed-post:store)
|
||||
.^(tube:clay (scry:hc %cc %home /[u.mark]/transform-add-nodes))
|
||||
tube
|
||||
=/ [* result=(list [index:store node:store])]
|
||||
%+ roll
|
||||
(flatten-node-map ~(tap by nodes.q.update))
|
||||
@ -95,9 +150,24 @@
|
||||
=. nodes.q.update
|
||||
%- ~(gas by *(map index:store node:store))
|
||||
result
|
||||
[~ !>(update)]
|
||||
:_ [~ !>(update)]
|
||||
%+ weld cards
|
||||
%- zing
|
||||
:~ ?: mark-cached ~
|
||||
:_ ~
|
||||
%+ poke-self:pass:io %graph-cache-hook
|
||||
!> ^- cache-action
|
||||
[%graph-to-mark rid mark]
|
||||
::
|
||||
?: transform-cached ~
|
||||
:_ ~
|
||||
%+ poke-self:pass:io %graph-cache-hook
|
||||
!> ^- cache-action
|
||||
[%transform-marks u.mark tube]
|
||||
==
|
||||
::
|
||||
++ flatten-node-map
|
||||
~/ %flatten-node-map
|
||||
|= lis=(list [index:store node:store])
|
||||
^- (list [index:store node:store])
|
||||
|^
|
||||
@ -129,6 +199,7 @@
|
||||
--
|
||||
::
|
||||
++ transform-list
|
||||
~/ %transform-list
|
||||
|= transform=$-([index:store post:store atom ?] [index:store post:store])
|
||||
|= $: [=index:store =node:store]
|
||||
[indices=(set index:store) lis=(list [index:store node:store])]
|
||||
@ -151,27 +222,32 @@
|
||||
--
|
||||
::
|
||||
%remove-posts
|
||||
?. (is-allowed-remove:hc resource.q.update indices.q.update)
|
||||
=| cards=(list card)
|
||||
=^ allowed cards
|
||||
(is-allowed-remove:hc rid indices.q.update)
|
||||
:- cards
|
||||
?. allowed
|
||||
~
|
||||
`vas
|
||||
::
|
||||
%add-graph ~
|
||||
%remove-graph ~
|
||||
%add-signatures ~
|
||||
%remove-signatures ~
|
||||
%archive-graph ~
|
||||
%unarchive-graph ~
|
||||
%add-tag ~
|
||||
%remove-tag ~
|
||||
%keys ~
|
||||
%tags ~
|
||||
%tag-queries ~
|
||||
%run-updates ~
|
||||
%add-graph [~ ~]
|
||||
%remove-graph [~ ~]
|
||||
%add-signatures [~ ~]
|
||||
%remove-signatures [~ ~]
|
||||
%archive-graph [~ ~]
|
||||
%unarchive-graph [~ ~]
|
||||
%add-tag [~ ~]
|
||||
%remove-tag [~ ~]
|
||||
%keys [~ ~]
|
||||
%tags [~ ~]
|
||||
%tag-queries [~ ~]
|
||||
%run-updates [~ ~]
|
||||
==
|
||||
::
|
||||
++ resource-for-update resource-for-update:gra
|
||||
::
|
||||
++ initial-watch
|
||||
~/ %initial-watch
|
||||
|= [=path =resource:res]
|
||||
^- vase
|
||||
|^
|
||||
@ -211,11 +287,13 @@
|
||||
==
|
||||
--
|
||||
::
|
||||
^| ^= hook-core
|
||||
|_ =bowl:gall
|
||||
~% %graph-push-hook-helper ..card.hook-core ~
|
||||
^= hook-core
|
||||
|_ [=bowl:gall =cache]
|
||||
+* grp ~(. group bowl)
|
||||
met ~(. mdl bowl)
|
||||
gra ~(. graph bowl)
|
||||
io ~(. agentio bowl)
|
||||
::
|
||||
++ scry
|
||||
|= [care=@t desk=@t =path]
|
||||
@ -225,14 +303,38 @@
|
||||
::
|
||||
++ perm-mark
|
||||
|= [=resource:res perm=@t vip=vip-metadata:metadata =indexed-post:store]
|
||||
^- permissions:store
|
||||
^- [permissions:store (list card)]
|
||||
|^
|
||||
=- (check vip)
|
||||
!< check=$-(vip-metadata:metadata permissions:store)
|
||||
%. !>(indexed-post)
|
||||
=/ mark (get-mark:gra resource)
|
||||
?~ mark |=(=vase !>([%no %no %no]))
|
||||
=/ mark-cached (~(has by graph-to-mark.cache) resource)
|
||||
=/ mark
|
||||
?: mark-cached
|
||||
(~(got by graph-to-mark.cache) resource)
|
||||
(get-mark:gra resource)
|
||||
?~ mark
|
||||
[[%no %no %no] ~]
|
||||
=/ key [u.mark (perm-mark-name perm)]
|
||||
=/ perms-cached (~(has by perm-marks.cache) key)
|
||||
=/ =tube:clay
|
||||
?: perms-cached
|
||||
(~(got by perm-marks.cache) key)
|
||||
.^(tube:clay (scry %cc %home /[u.mark]/(perm-mark-name perm)))
|
||||
=/ check
|
||||
!< $-(vip-metadata:metadata permissions:store)
|
||||
(tube !>(indexed-post))
|
||||
:- (check vip)
|
||||
%- zing
|
||||
:~ ?: mark-cached ~
|
||||
:_ ~
|
||||
%+ poke-self:pass:io %graph-cache-hook
|
||||
!> ^- cache-action
|
||||
[%graph-to-mark resource mark]
|
||||
::
|
||||
?: perms-cached ~
|
||||
:_ ~
|
||||
%+ poke-self:pass:io %graph-cache-hook
|
||||
!> ^- cache-action
|
||||
[%perm-marks [u.mark (perm-mark-name perm)] tube]
|
||||
==
|
||||
::
|
||||
++ perm-mark-name
|
||||
|= perm=@t
|
||||
@ -252,15 +354,22 @@
|
||||
reader.permissions
|
||||
::
|
||||
++ get-roles-writers-variation
|
||||
~/ %get-roles-writers-variation
|
||||
|= =resource:res
|
||||
^- (unit [is-admin=? writers=(set ship) vip=vip-metadata:metadata])
|
||||
=/ assoc=(unit association:metadata)
|
||||
(peek-association:met %graph resource)
|
||||
?~ assoc ~
|
||||
=/ group=(unit group:grp)
|
||||
(scry-group:grp group.u.assoc)
|
||||
?~ group ~
|
||||
=/ role=(unit (unit role-tag))
|
||||
(role-for-ship:grp group.u.assoc src.bowl)
|
||||
(role-for-ship-with-group:grp u.group group.u.assoc src.bowl)
|
||||
=/ writers=(set ship)
|
||||
(get-tagged-ships:grp group.u.assoc [%graph resource %writers])
|
||||
%^ get-tagged-ships-with-group:grp
|
||||
u.group
|
||||
group.u.assoc
|
||||
[%graph resource %writers]
|
||||
?~ role ~
|
||||
=/ is-admin=?
|
||||
?=(?([~ %admin] [~ %moderator]) u.role)
|
||||
@ -274,28 +383,47 @@
|
||||
[(snag (dec (lent index)) index) p.post.node]
|
||||
::
|
||||
++ is-allowed-add
|
||||
~/ %is-allowed-add
|
||||
|= [=resource:res nodes=(map index:store node:store)]
|
||||
^- ?
|
||||
^- [? (list card)]
|
||||
|^
|
||||
%- (bond |.(%.n))
|
||||
%- (bond |.([%.n ~]))
|
||||
%+ biff (get-roles-writers-variation resource)
|
||||
|= [is-admin=? writers=(set ship) vip=vip-metadata:metadata]
|
||||
^- (unit ?)
|
||||
^- (unit [? (list card)])
|
||||
%- some
|
||||
%+ levy ~(tap by nodes)
|
||||
|= [=index:store =node:store]
|
||||
=/ a ~(tap by nodes)
|
||||
=| cards=(list card)
|
||||
|- ^- [? (list card)]
|
||||
?~ a [& cards]
|
||||
=/ c (check i.a is-admin writers vip)
|
||||
?. -.c
|
||||
[| (weld cards +.c)]
|
||||
$(a t.a, cards (weld cards +.c))
|
||||
::
|
||||
++ check
|
||||
|= $: [=index:store =node:store]
|
||||
is-admin=?
|
||||
writers=(set ship)
|
||||
vip=vip-metadata:metadata
|
||||
==
|
||||
^- [? (list card)]
|
||||
=/ parent-index=index:store
|
||||
(scag (dec (lent index)) index)
|
||||
?: (~(has by nodes) parent-index) %.y
|
||||
?: (~(has by nodes) parent-index)
|
||||
[%.y ~]
|
||||
?: ?=(%| -.post.node)
|
||||
%.n
|
||||
[%.n ~]
|
||||
?. =(author.p.post.node src.bowl)
|
||||
%.n
|
||||
=/ =permissions:store
|
||||
[%.n ~]
|
||||
=/ added
|
||||
%^ add-mark resource vip
|
||||
(node-to-indexed-post node)
|
||||
=* permissions -.added
|
||||
=* cards +.added
|
||||
=/ =permission-level:store
|
||||
(get-permission permissions is-admin writers)
|
||||
:_ cards
|
||||
?- permission-level
|
||||
%yes %.y
|
||||
%no %.n
|
||||
@ -314,24 +442,38 @@
|
||||
--
|
||||
::
|
||||
++ is-allowed-remove
|
||||
~/ %is-allowed-remove
|
||||
|= [=resource:res indices=(set index:store)]
|
||||
^- ?
|
||||
^- [? (list card)]
|
||||
|^
|
||||
%- (bond |.(%.n))
|
||||
%- (bond |.([%.n ~]))
|
||||
%+ biff (get-roles-writers-variation resource)
|
||||
|= [is-admin=? writers=(set ship) vip=vip-metadata:metadata]
|
||||
%- some
|
||||
%+ levy ~(tap by indices)
|
||||
|= =index:store
|
||||
^- ?
|
||||
=/ a ~(tap by indices)
|
||||
=| cards=(list card)
|
||||
|- ^- [? (list card)]
|
||||
?~ a [& cards]
|
||||
=/ c (check i.a is-admin writers vip)
|
||||
?. -.c
|
||||
[| (weld cards +.c)]
|
||||
$(a t.a, cards (weld cards +.c))
|
||||
::
|
||||
++ check
|
||||
|= [=index:store is-admin=? writers=(set ship) vip=vip-metadata:metadata]
|
||||
^- [? (list card)]
|
||||
=/ =node:store
|
||||
(got-node:gra resource index)
|
||||
?: ?=(%| -.post.node) %.n
|
||||
=/ =permissions:store
|
||||
?: ?=(%| -.post.node)
|
||||
[%.n ~]
|
||||
=/ removed
|
||||
%^ remove-mark resource vip
|
||||
(node-to-indexed-post node)
|
||||
=* permissions -.removed
|
||||
=* cards +.removed
|
||||
=/ =permission-level:store
|
||||
(get-permission permissions is-admin writers)
|
||||
:_ cards
|
||||
?- permission-level
|
||||
%yes %.y
|
||||
%no %.n
|
||||
|
@ -10,16 +10,28 @@
|
||||
[%1 network:zero:store]
|
||||
[%2 network:zero:store]
|
||||
[%3 network:one:store]
|
||||
state-4
|
||||
[%4 network:store]
|
||||
state-5
|
||||
==
|
||||
::
|
||||
+$ state-4 [%4 network:store]
|
||||
+$ state-5 [%5 network:store]
|
||||
++ orm orm:store
|
||||
++ orm-log orm-log:store
|
||||
+$ debug-input [%validate-graph =resource:store]
|
||||
::
|
||||
+$ cache
|
||||
$: validators=(map mark dais:clay)
|
||||
==
|
||||
::
|
||||
:: TODO: come back to this and potentially use ford runes or otherwise
|
||||
:: send a %t to be notified of validator changes
|
||||
+$ inflated-state
|
||||
$: state-5
|
||||
cache
|
||||
==
|
||||
--
|
||||
::
|
||||
=| state-4
|
||||
=| inflated-state
|
||||
=* state -
|
||||
::
|
||||
%- agent:dbug
|
||||
@ -31,7 +43,7 @@
|
||||
def ~(. (default-agent this %|) bowl)
|
||||
::
|
||||
++ on-init [~ this]
|
||||
++ on-save !>(state)
|
||||
++ on-save !>(-.state)
|
||||
++ on-load
|
||||
|= =old=vase
|
||||
^- (quip card _this)
|
||||
@ -91,7 +103,23 @@
|
||||
|=(a=* *update-log:store)
|
||||
==
|
||||
::
|
||||
%4 [cards this(state old)]
|
||||
%4
|
||||
%_ $
|
||||
-.old %5
|
||||
::
|
||||
update-logs.old
|
||||
%- ~(gas by *update-logs:store)
|
||||
%+ turn ~(tap by graphs.old)
|
||||
|= [=resource:store =graph:store mar=(unit mark)]
|
||||
:- resource
|
||||
=/ log (~(got by update-logs.old) resource)
|
||||
?. =(~ log) log
|
||||
=/ =logged-update:store
|
||||
[now.bowl %add-graph resource graph mar %.y]
|
||||
(gas:orm-log ~ [now.bowl logged-update] ~)
|
||||
==
|
||||
::
|
||||
%5 [cards this(-.state old, +.state *cache)]
|
||||
==
|
||||
::
|
||||
++ on-watch
|
||||
@ -163,7 +191,9 @@
|
||||
!(~(has by graphs) resource)
|
||||
== ==
|
||||
~| "validation of graph {<resource>} failed using mark {<mark>}"
|
||||
?> (validate-graph graph mark)
|
||||
=^ is-valid state
|
||||
(validate-graph graph mark)
|
||||
?> is-valid
|
||||
=/ =logged-update:store
|
||||
[time %add-graph resource graph mark overwrite]
|
||||
=/ =update-log:store
|
||||
@ -200,6 +230,10 @@
|
||||
(~(got by graphs) resource)
|
||||
~| "cannot add duplicate nodes to {<resource>}"
|
||||
?< (check-for-duplicates graph ~(key by nodes))
|
||||
~| "validation of nodes failed using mark {<mark>}"
|
||||
=^ is-valid state
|
||||
(check-validity ~(tap by nodes) mark)
|
||||
?> is-valid
|
||||
=/ =update-log:store (~(got by update-logs) resource)
|
||||
=. update-log
|
||||
(put:orm-log update-log time [time [%add-nodes resource nodes]])
|
||||
@ -214,6 +248,17 @@
|
||||
(add-node-list resource graph mark (sort-nodes nodes))
|
||||
==
|
||||
::
|
||||
++ check-validity
|
||||
|= [lis=(list (pair index:store node:store)) mark=(unit ^mark)]
|
||||
^- [? _state]
|
||||
|-
|
||||
?~ lis [& state]
|
||||
=^ is-valid state
|
||||
(validate-graph (gas:orm ~ [(rear p.i.lis) q.i.lis]~) mark)
|
||||
?. is-valid
|
||||
[| state]
|
||||
$(lis t.lis)
|
||||
::
|
||||
++ check-for-duplicates
|
||||
|= [=graph:store nodes=(set index:store)]
|
||||
^- ?
|
||||
@ -271,8 +316,6 @@
|
||||
==
|
||||
^- graph:store
|
||||
?< ?=(~ index)
|
||||
~| "validation of node failed using mark {<mark>}"
|
||||
?> (validate-graph (gas:orm ~ [i.index node]~) mark)
|
||||
=* atom i.index
|
||||
%^ put:orm
|
||||
graph
|
||||
@ -571,18 +614,24 @@
|
||||
^- (quip card _state)
|
||||
=/ [=graph:store mark=(unit mark:store)]
|
||||
(~(got by graphs) resource.debug-input)
|
||||
?> (validate-graph graph mark)
|
||||
=^ is-valid state
|
||||
(validate-graph graph mark)
|
||||
?> is-valid
|
||||
[~ state]
|
||||
::
|
||||
++ validate-graph
|
||||
|= [=graph:store mark=(unit mark:store)]
|
||||
^- ?
|
||||
?~ mark %.y
|
||||
^- [? _state]
|
||||
?~ mark [%.y state]
|
||||
=/ has-dais (~(has by validators) u.mark)
|
||||
=/ =dais:clay
|
||||
?: has-dais
|
||||
(~(got by validators) u.mark)
|
||||
.^ =dais:clay
|
||||
%cb
|
||||
/(scot %p our.bowl)/[q.byk.bowl]/(scot %da now.bowl)/[u.mark]
|
||||
==
|
||||
:_ state(validators (~(put by validators) u.mark dais))
|
||||
|- ^- ?
|
||||
?~ graph %.y
|
||||
%+ roll (tap:orm graph)
|
||||
@ -600,7 +649,9 @@
|
||||
++ poke-import
|
||||
|= arc=*
|
||||
^- (quip card _state)
|
||||
=^ cards -.state
|
||||
(import:store arc our.bowl)
|
||||
[cards state]
|
||||
--
|
||||
::
|
||||
++ on-peek
|
||||
|
@ -47,8 +47,9 @@
|
||||
::
|
||||
++ transform-proxy-update
|
||||
|= vas=vase
|
||||
^- (unit vase)
|
||||
^- (quip card (unit vase))
|
||||
=/ =update:store !<(update:store vas)
|
||||
:- ~
|
||||
?: ?=(%initial -.update)
|
||||
~
|
||||
|^
|
||||
|
@ -124,15 +124,15 @@
|
||||
::
|
||||
++ poke-noun
|
||||
|= non=*
|
||||
?> ?=(%rewatch-dms non)
|
||||
=/ graphs=(list resource)
|
||||
~(tap in get-keys:gra)
|
||||
:- ~
|
||||
%_ state
|
||||
watching
|
||||
%- ~(gas in watching)
|
||||
(murn graphs |=(rid=resource ?:((should-watch:ha rid) `[rid ~] ~)))
|
||||
==
|
||||
[~ state]
|
||||
:: ?> ?=(%rewatch-dms non)
|
||||
:: =/ graphs=(list resource)
|
||||
:: ~(tap in get-keys:gra)
|
||||
:: %_ state
|
||||
:: watching
|
||||
:: %- ~(gas in watching)
|
||||
:: (murn graphs |=(rid=resource ?:((should-watch:ha rid) `[rid ~] ~)))
|
||||
:: ==
|
||||
::
|
||||
++ hark-graph-hook-action
|
||||
|= =action:hook
|
||||
@ -201,7 +201,9 @@
|
||||
::
|
||||
%add-nodes
|
||||
=* rid resource.q.update
|
||||
(check-nodes ~(val by nodes.q.update) rid)
|
||||
=/ assoc=(unit association:metadata)
|
||||
(peek-association:met %graph rid)
|
||||
(check-nodes ~(val by nodes.q.update) rid assoc)
|
||||
==
|
||||
:: this is awful, but notification kind should always switch
|
||||
:: on the index, so hopefully doesn't matter
|
||||
@ -255,9 +257,11 @@
|
||||
(get-graph-mop:gra rid)
|
||||
=/ node=(unit node:graph-store)
|
||||
(bind (peek:orm:graph-store graph) |=([@ =node:graph-store] node))
|
||||
=/ assoc=(unit association:metadata)
|
||||
(peek-association:met %graph rid)
|
||||
=^ cards state
|
||||
(check-nodes (drop node) rid)
|
||||
?. (should-watch:ha rid)
|
||||
(check-nodes (drop node) rid assoc)
|
||||
?. (should-watch:ha rid assoc)
|
||||
[cards state]
|
||||
:_ state(watching (~(put in watching) [rid ~]))
|
||||
(weld cards (give:ha ~[/updates] %listen [rid ~]))
|
||||
@ -265,20 +269,18 @@
|
||||
++ check-nodes
|
||||
|= $: nodes=(list node:graph-store)
|
||||
rid=resource
|
||||
assoc=(unit association:metadata)
|
||||
==
|
||||
=/ group=(unit resource)
|
||||
(peek-group:met %graph rid)
|
||||
?~ group
|
||||
~& no-group+rid
|
||||
?~ assoc
|
||||
~& no-assoc+rid
|
||||
`state
|
||||
=/ metadatum=(unit metadatum:metadata)
|
||||
(peek-metadatum:met %graph rid)
|
||||
?~ metadatum `state
|
||||
=* group group.u.assoc
|
||||
=* metadatum metadatum.u.assoc
|
||||
=/ module=term
|
||||
?: ?=(%empty -.config.u.metadatum) %$
|
||||
?: ?=(%group -.config.u.metadatum) %$
|
||||
module.config.u.metadatum
|
||||
abet:check:(abed:handle-update:ha rid nodes u.group module)
|
||||
?: ?=(%empty -.config.metadatum) %$
|
||||
?: ?=(%group -.config.metadatum) %$
|
||||
module.config.metadatum
|
||||
abet:check:(abed:handle-update:ha rid nodes group module)
|
||||
--
|
||||
::
|
||||
++ on-peek on-peek:def
|
||||
@ -340,12 +342,11 @@
|
||||
$(contents t.contents)
|
||||
::
|
||||
++ should-watch
|
||||
|= rid=resource
|
||||
|= [rid=resource assoc=(unit association:metadata)]
|
||||
^- ?
|
||||
=/ group-rid=(unit resource)
|
||||
(peek-group:met %graph rid)
|
||||
?~ group-rid %.n
|
||||
?| !(is-managed:grp u.group-rid)
|
||||
?~ assoc
|
||||
%.n
|
||||
?| !(is-managed:grp group.u.assoc)
|
||||
&(watch-on-self =(our.bowl entity.rid))
|
||||
==
|
||||
::
|
||||
@ -364,7 +365,9 @@
|
||||
update-core(rid r, updates upds, group grp, module mod)
|
||||
::
|
||||
++ get-conversion
|
||||
(^get-conversion rid)
|
||||
:: LA: this tube should be cached in %hark-graph-hook state
|
||||
:: instead of just trying to keep it warm, as the scry overhead is large
|
||||
~+ (^get-conversion rid)
|
||||
::
|
||||
++ abet
|
||||
^- (quip card _state)
|
||||
@ -418,7 +421,8 @@
|
||||
update-core
|
||||
=* pos p.post.node
|
||||
=+ !< notif-kind=(unit notif-kind:hook)
|
||||
(get-conversion !>([0 pos]))
|
||||
%- get-conversion
|
||||
!>(`indexed-post:graph-store`[0 pos])
|
||||
?~ notif-kind
|
||||
update-core
|
||||
=/ desc=@t
|
||||
|
@ -24,6 +24,6 @@
|
||||
<div id="portal-root"></div>
|
||||
<script src="/~landscape/js/channel.js"></script>
|
||||
<script src="/~landscape/js/session.js"></script>
|
||||
<script src="/~landscape/js/bundle/index.eb051d816171fb1d0caf.js"></script>
|
||||
<script src="/~landscape/js/bundle/index.f252a9afb6e952de19c9.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -194,6 +194,11 @@
|
||||
[%x %tiles ~] ``noun+!>([tiles tile-ordering])
|
||||
[%x %first-time ~] ``noun+!>(first-time)
|
||||
[%x %keys ~] ``noun+!>(~(key by tiles))
|
||||
::
|
||||
[%x %runtime-lag ~]
|
||||
:^ ~ ~ %json
|
||||
!> ^- json
|
||||
b+.^(? //(scot %p our.bowl)//(scot %da now.bowl)/zen/lag)
|
||||
==
|
||||
::
|
||||
++ on-arvo
|
||||
|
@ -59,8 +59,9 @@
|
||||
::
|
||||
++ transform-proxy-update
|
||||
|= vas=vase
|
||||
^- (unit vase)
|
||||
^- (quip card (unit vase))
|
||||
=/ =update:store !<(update:store vas)
|
||||
:- ~
|
||||
?. ?=(?(%add %remove) -.update)
|
||||
~
|
||||
=/ role=(unit (unit role-tag))
|
||||
|
@ -3,15 +3,14 @@
|
||||
:::: /hoon/code/hood/gen
|
||||
::
|
||||
/? 310
|
||||
::
|
||||
::::
|
||||
::
|
||||
:- %say
|
||||
/- *sole
|
||||
/+ *generators
|
||||
:- %ask
|
||||
|= $: [now=@da eny=@uvJ bec=beak]
|
||||
[arg=?(~ [%reset ~]) ~]
|
||||
==
|
||||
=* our p.bec
|
||||
:- %helm-code
|
||||
^- (sole-result [%helm-code ?(~ %reset)])
|
||||
?~ arg
|
||||
=/ code=tape
|
||||
%+ slag 1
|
||||
@ -20,11 +19,23 @@
|
||||
=/ step=tape
|
||||
%+ scow %ud
|
||||
.^(@ud %j /(scot %p our)/step/(scot %da now)/(scot %p our))
|
||||
%- %- slog
|
||||
:~ [%leaf code]
|
||||
[%leaf (weld "current step=" step)]
|
||||
[%leaf "use |code %reset to invalidate this and generate a new code"]
|
||||
==
|
||||
~
|
||||
::
|
||||
%+ print 'use |code %reset to invalidate this and generate a new code'
|
||||
%+ print leaf+(weld "current step=" step)
|
||||
%+ print leaf+code
|
||||
(produce [%helm-code ~])
|
||||
::
|
||||
?> =(%reset -.arg)
|
||||
%reset
|
||||
%+ print 'continue?'
|
||||
%+ print 'warning: resetting your code closes all web sessions'
|
||||
%+ prompt
|
||||
[%& %project "y/n: "]
|
||||
%+ parse
|
||||
;~ pose
|
||||
(cold %.y (mask "yY"))
|
||||
(cold %.n (mask "nN"))
|
||||
==
|
||||
|= reset=?
|
||||
?. reset
|
||||
no-product
|
||||
(produce [%helm-code %reset])
|
||||
|
@ -50,18 +50,17 @@
|
||||
==
|
||||
::
|
||||
++ index
|
||||
|= i=^index
|
||||
|= ind=^index
|
||||
^- json
|
||||
?: =(~ i) s+'/'
|
||||
=/ j=^tape ""
|
||||
|-
|
||||
?~ i [%s (crip j)]
|
||||
=/ k=json (numb i.i)
|
||||
?> ?=(%n -.k)
|
||||
%_ $
|
||||
i t.i
|
||||
j (weld j (weld "/" (trip +.k)))
|
||||
==
|
||||
:- %s
|
||||
?: =(~ ind)
|
||||
'/'
|
||||
%+ roll ind
|
||||
|= [cur=@ acc=@t]
|
||||
^- @t
|
||||
=/ num (numb cur)
|
||||
?> ?=(%n -.num)
|
||||
(rap 3 acc '/' p.num ~)
|
||||
::
|
||||
++ uid
|
||||
|= u=^uid
|
||||
@ -721,9 +720,9 @@
|
||||
--
|
||||
++ import
|
||||
|= [arc=* our=ship]
|
||||
^- (quip card:agent:gall [%4 network])
|
||||
^- (quip card:agent:gall [%5 network])
|
||||
|^
|
||||
=/ sty [%4 (remake-network ;;(tree-network +.arc))]
|
||||
=/ sty [%5 (remake-network ;;(tree-network +.arc))]
|
||||
:_ sty
|
||||
%+ turn ~(tap by graphs.sty)
|
||||
|= [rid=resource =marked-graph]
|
||||
|
@ -76,6 +76,7 @@
|
||||
++ get-graph
|
||||
|= res=resource
|
||||
^- update:store
|
||||
=- -(p *time)
|
||||
%+ scry-for update:store
|
||||
/graph/(scot %p entity.res)/[name.res]
|
||||
::
|
||||
|
@ -75,7 +75,12 @@
|
||||
=/ grp=(unit group)
|
||||
(scry-group rid)
|
||||
?~ grp ~
|
||||
=* group u.grp
|
||||
(role-for-ship-with-group u.grp rid ship)
|
||||
::
|
||||
++ role-for-ship-with-group
|
||||
|= [grp=group rid=resource =ship]
|
||||
^- (unit (unit role-tag))
|
||||
=* group grp
|
||||
=* policy policy.group
|
||||
=* tags tags.group
|
||||
=/ admins=(set ^ship)
|
||||
@ -107,7 +112,12 @@
|
||||
=/ grp=(unit group)
|
||||
(scry-group rid)
|
||||
?~ grp ~
|
||||
(~(get ju tags.u.grp) tag)
|
||||
(get-tagged-ships-with-group u.grp rid tag)
|
||||
::
|
||||
++ get-tagged-ships-with-group
|
||||
|= [grp=group rid=resource =tag]
|
||||
^- (set ship)
|
||||
(~(get ju tags.grp) tag)
|
||||
::
|
||||
++ is-managed
|
||||
|= rid=resource
|
||||
|
@ -23,12 +23,12 @@
|
||||
%+ turn ~(tap by associations)
|
||||
|= [=md-resource [group=resource =^metadatum]]
|
||||
^- [cord json]
|
||||
:-
|
||||
%- crip
|
||||
;: weld
|
||||
(trip (spat (en-path:resource group)))
|
||||
(weld "/" (trip app-name.md-resource))
|
||||
(trip (spat (en-path:resource resource.md-resource)))
|
||||
:- %: rap 3
|
||||
(spat (en-path:resource group))
|
||||
'/'
|
||||
app-name.md-resource
|
||||
(spat (en-path:resource resource.md-resource))
|
||||
~
|
||||
==
|
||||
%- pairs
|
||||
:~ [%group s+(enjs-path:resource group)]
|
||||
|
@ -114,6 +114,14 @@
|
||||
state-3
|
||||
state-4
|
||||
==
|
||||
:: +diplomatic: only renegotiate if versions changed
|
||||
::
|
||||
:: If %.n please leave note as to why renegotiation necessary
|
||||
::
|
||||
::
|
||||
++ diplomatic
|
||||
^- ?
|
||||
%.y
|
||||
::
|
||||
++ default
|
||||
|* [pull-hook=* =config]
|
||||
@ -239,6 +247,7 @@
|
||||
=/ kick=(list card)
|
||||
?: ?& =(min-version.config prev-min-version.old)
|
||||
=(version.config prev-version.old)
|
||||
diplomatic
|
||||
==
|
||||
~
|
||||
(poke-self:pass kick+!>(%kick))^~
|
||||
@ -439,6 +448,7 @@
|
||||
?~ tan tr-core
|
||||
?. versioned
|
||||
(tr-ap-og:tr-cleanup |.((on-pull-nack:og rid u.tan)))
|
||||
%- (slog leaf+"versioned nack for {<rid>} in {<dap.bowl>}" u.tan)
|
||||
=/ pax
|
||||
(kick-mule:virt rid |.((on-pull-kick:og rid)))
|
||||
?~ pax tr-failed-kick
|
||||
@ -463,18 +473,18 @@
|
||||
:: subscription
|
||||
tr-core
|
||||
(tr-suspend-pub-ver min-version.config)
|
||||
=/ =vase
|
||||
=/ =^cage
|
||||
(convert-to:ver cage)
|
||||
=/ =wire
|
||||
(make-wire /store)
|
||||
=+ resources=(~(gas in *(set resource)) (resource-for-update:og vase))
|
||||
=+ resources=(~(gas in *(set resource)) (resource-for-update:og q.cage))
|
||||
?> ?| no-validate.config
|
||||
?& (check-src resources)
|
||||
(~(has in resources) rid)
|
||||
== ==
|
||||
=/ =mark
|
||||
(append-version:ver version.config)
|
||||
(tr-emit (~(poke-our pass wire) store-name.config mark vase))
|
||||
(tr-emit (~(poke-our pass wire) store-name.config cage))
|
||||
--
|
||||
::
|
||||
++ tr-kick
|
||||
|
@ -26,6 +26,7 @@
|
||||
::
|
||||
/- *push-hook
|
||||
/+ default-agent, resource, verb, versioning, agentio
|
||||
~% %push-hook-top ..part ~
|
||||
|%
|
||||
+$ card card:agent:gall
|
||||
::
|
||||
@ -73,7 +74,16 @@
|
||||
state-1
|
||||
state-2
|
||||
==
|
||||
:: +diplomatic: only renegotiate if versions changed
|
||||
::
|
||||
:: If %.n please leave note as to why renegotiation necessary
|
||||
::
|
||||
++ diplomatic
|
||||
^- ?
|
||||
%.y
|
||||
::
|
||||
++ push-hook
|
||||
~/ %push-hook
|
||||
|* =config
|
||||
$_ ^|
|
||||
|_ bowl:gall
|
||||
@ -103,7 +113,7 @@
|
||||
::
|
||||
++ transform-proxy-update
|
||||
|~ vase
|
||||
*(unit vase)
|
||||
*[(list card) (unit vase)]
|
||||
:: +initial-watch: produce initial state for a subscription
|
||||
::
|
||||
:: .resource is the resource being subscribed to.
|
||||
@ -165,6 +175,7 @@
|
||||
=* state -
|
||||
^- agent:gall
|
||||
=<
|
||||
~% %push-agent-lib ..poke-hook-action ~
|
||||
|_ =bowl:gall
|
||||
+* this .
|
||||
og ~(. push-hook bowl)
|
||||
@ -221,6 +232,7 @@
|
||||
|= [prev-min-version=@ud prev-version=@ud]
|
||||
?: ?& =(min-version.config prev-min-version)
|
||||
=(prev-version version.config)
|
||||
diplomatic
|
||||
==
|
||||
:: bail on kick if we didn't change versions
|
||||
~
|
||||
@ -256,6 +268,7 @@
|
||||
!>(state)
|
||||
::
|
||||
++ on-poke
|
||||
~/ %on-poke
|
||||
|= [=mark =vase]
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
?: =(mark %push-hook-action)
|
||||
@ -272,6 +285,7 @@
|
||||
[cards this]
|
||||
::
|
||||
++ on-watch
|
||||
~/ %on-watch
|
||||
|= =path
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
?: ?=([%version ~] path)
|
||||
@ -291,26 +305,25 @@
|
||||
?. (supported:ver mark)
|
||||
:_ this
|
||||
(fact-init-kick:io version+!>(min-version.config))
|
||||
=/ =vase
|
||||
(convert-to:ver mark (initial-watch:og t.t.t.t.t.t.path resource))
|
||||
:_ this
|
||||
[%give %fact ~ mark vase]~
|
||||
=- [%give %fact ~ -]~
|
||||
(convert-to:ver mark (initial-watch:og t.t.t.t.t.t.path resource))
|
||||
::
|
||||
++ unversioned
|
||||
?> ?=([%ship @ @ *] t.path)
|
||||
?. =(min-version.config 0)
|
||||
~& >>> "unversioned req from: {<src.bowl>}, nooping"
|
||||
`this
|
||||
=/ =resource
|
||||
(de-path:resource t.path)
|
||||
=/ =vase
|
||||
%+ convert-to:ver update-mark.config
|
||||
(initial-watch:og t.t.t.t.path resource)
|
||||
:_ this
|
||||
[%give %fact ~ update-mark.config vase]~
|
||||
?. =(min-version.config 0)
|
||||
~& >>> "unversioned req from: {<src.bowl>}, nooping"
|
||||
~
|
||||
[%give %fact ~ (convert-to:ver update-mark.config vase)]~
|
||||
--
|
||||
::
|
||||
++ on-agent
|
||||
~/ %on-agent
|
||||
|= [=wire =sign:agent:gall]
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
?. ?=([%helper %push-hook @ *] wire)
|
||||
@ -364,6 +377,7 @@
|
||||
[%x %min-version ~] ``version+!>(version.config)
|
||||
==
|
||||
--
|
||||
~% %push-helper-lib ..card ~
|
||||
|_ =bowl:gall
|
||||
+* og ~(. push-hook bowl)
|
||||
ver ~(. versioning [bowl [update-mark version min-version]:config])
|
||||
@ -371,6 +385,7 @@
|
||||
pass pass:io
|
||||
::
|
||||
++ poke-hook-action
|
||||
~/ %poke-hook-action
|
||||
|= =action
|
||||
^- (quip card:agent:gall _state)
|
||||
|^
|
||||
@ -439,6 +454,7 @@
|
||||
[%pass wire %agent [our.bowl store-name.config] %watch store-path.config]
|
||||
::
|
||||
++ push-updates
|
||||
~/ %push-updates
|
||||
|= =cage
|
||||
^- (list card:agent:gall)
|
||||
%+ roll (resource-for-update q.cage)
|
||||
@ -461,10 +477,7 @@
|
||||
|= [fact-ver=@ud paths=(set path)]
|
||||
=/ =mark
|
||||
(append-version:ver fact-ver)
|
||||
=/ =^cage
|
||||
:- mark
|
||||
(convert-from:ver mark q.cage)
|
||||
(fact:io cage ~(tap in paths))
|
||||
(fact:io (convert-from:ver mark q.cage) ~(tap in paths))
|
||||
:: TODO: deprecate
|
||||
++ unversioned
|
||||
?. =(min-version.config 0) ~
|
||||
@ -474,39 +487,39 @@
|
||||
%- ~(gas in *(set path))
|
||||
(turn (incoming-subscriptions prefix) tail)
|
||||
?: =(0 ~(wyt in unversioned)) ~
|
||||
=/ =^cage
|
||||
:- update-mark.config
|
||||
(convert-from:ver update-mark.config q.cage)
|
||||
(fact:io cage ~(tap in unversioned))^~
|
||||
(fact:io (convert-from:ver update-mark.config q.cage) ~(tap in unversioned))^~
|
||||
--
|
||||
::
|
||||
++ forward-update
|
||||
~/ %forward-update
|
||||
|= =cage
|
||||
^- (list card:agent:gall)
|
||||
=- lis
|
||||
=/ vas
|
||||
(convert-to:ver cage)
|
||||
=/ vas=vase
|
||||
q:(convert-to:ver cage)
|
||||
%+ roll (resource-for-update q.cage)
|
||||
|= [rid=resource [lis=(list card:agent:gall) tf-vas=(unit vase)]]
|
||||
^- [(list card:agent:gall) (unit vase)]
|
||||
=/ =path
|
||||
resource+(en-path:resource rid)
|
||||
=/ =wire (make-wire path)
|
||||
=* ship entity.rid
|
||||
=. tf-vas
|
||||
=/ out=(pair (list card:agent:gall) (unit vase))
|
||||
?. =(our.bowl ship)
|
||||
:: do not transform before forwarding
|
||||
::
|
||||
`vas
|
||||
``vas
|
||||
:: use cached transform
|
||||
::
|
||||
?^ tf-vas tf-vas
|
||||
?^ tf-vas `tf-vas
|
||||
:: transform before poking store
|
||||
::
|
||||
(transform-proxy-update:og vas)
|
||||
~| "forwarding failed during transform. mark: {<p.cage>} resource: {<rid>}"
|
||||
?> ?=(^ tf-vas)
|
||||
=/ =dock
|
||||
~| "forwarding failed during transform. mark: {<p.cage>} rid: {<rid>}"
|
||||
?> ?=(^ q.out)
|
||||
:_ q.out
|
||||
:_ (weld lis p.out)
|
||||
=/ =wire (make-wire path)
|
||||
=- [%pass wire %agent - %poke [current-version:ver u.q.out]]
|
||||
:- ship
|
||||
?. =(our.bowl ship)
|
||||
:: forward to host
|
||||
@ -515,11 +528,6 @@
|
||||
:: poke our store
|
||||
::
|
||||
store-name.config
|
||||
=/ cag=^cage
|
||||
:- current-version:ver
|
||||
u.tf-vas
|
||||
:_ tf-vas
|
||||
[[%pass wire %agent dock %poke cag] lis]
|
||||
::
|
||||
++ ver-from-path
|
||||
|= =path
|
||||
@ -529,6 +537,7 @@
|
||||
(slav %ud i.extra)
|
||||
::
|
||||
++ resource-for-update
|
||||
~/ %resource-for-update
|
||||
|= =vase
|
||||
^- (list resource)
|
||||
%~ tap in
|
||||
|
@ -39,10 +39,10 @@
|
||||
~! +:*handler
|
||||
(handler inbound-request)
|
||||
::
|
||||
=/ redirect=cord
|
||||
%- crip
|
||||
"/~/login?redirect={(trip url.request.inbound-request)}"
|
||||
[[307 ['location' redirect]~] ~]
|
||||
=- [[307 ['location' -]~] ~]
|
||||
%^ cat 3
|
||||
'/~/login?redirect='
|
||||
url.request.inbound-request
|
||||
::
|
||||
:: +require-authorization-simple:
|
||||
:: redirect to the login page when unauthenticated
|
||||
@ -56,10 +56,10 @@
|
||||
~! this
|
||||
simple-payload
|
||||
::
|
||||
=/ redirect=cord
|
||||
%- crip
|
||||
"/~/login?redirect={(trip url.request.inbound-request)}"
|
||||
[[307 ['location' redirect]~] ~]
|
||||
=- [[307 ['location' -]~] ~]
|
||||
%^ cat 3
|
||||
'/~/login?redirect='
|
||||
url.request.inbound-request
|
||||
::
|
||||
++ give-simple-payload
|
||||
|= [eyre-id=@ta =simple-payload:http]
|
||||
@ -86,36 +86,52 @@
|
||||
:_ `octs
|
||||
[200 [['content-type' 'text/html'] ?:(cache [max-1-wk ~] ~)]]
|
||||
::
|
||||
++ js-response
|
||||
|= =octs
|
||||
^- simple-payload:http
|
||||
[[200 [['content-type' 'text/javascript'] max-1-da ~]] `octs]
|
||||
::
|
||||
++ json-response
|
||||
|= =json
|
||||
^- simple-payload:http
|
||||
[[200 ['content-type' 'application/json']~] `(json-to-octs json)]
|
||||
::
|
||||
++ css-response
|
||||
=| cache=?
|
||||
|= =octs
|
||||
^- simple-payload:http
|
||||
[[200 [['content-type' 'text/css'] max-1-da ~]] `octs]
|
||||
:_ `octs
|
||||
[200 [['content-type' 'text/css'] ?:(cache [max-1-wk ~] ~)]]
|
||||
::
|
||||
++ manx-response
|
||||
|= man=manx
|
||||
++ js-response
|
||||
=| cache=?
|
||||
|= =octs
|
||||
^- simple-payload:http
|
||||
[[200 ['content-type' 'text/html']~] `(manx-to-octs man)]
|
||||
:_ `octs
|
||||
[200 [['content-type' 'text/javascript'] ?:(cache [max-1-wk ~] ~)]]
|
||||
::
|
||||
++ png-response
|
||||
=| cache=?
|
||||
|= =octs
|
||||
^- simple-payload:http
|
||||
[[200 [['content-type' 'image/png'] max-1-wk ~]] `octs]
|
||||
:_ `octs
|
||||
[200 [['content-type' 'image/png'] ?:(cache [max-1-wk ~] ~)]]
|
||||
::
|
||||
++ ico-response
|
||||
|= =octs
|
||||
^- simple-payload:http
|
||||
[[200 [['content-type' 'image/x-icon'] max-1-wk ~]] `octs]
|
||||
::
|
||||
++ woff2-response
|
||||
=| cache=?
|
||||
|= =octs
|
||||
^- simple-payload:http
|
||||
[[200 [['content-type' 'font/woff2'] max-1-wk ~]] `octs]
|
||||
::
|
||||
++ json-response
|
||||
=| cache=_|
|
||||
|= =json
|
||||
^- simple-payload:http
|
||||
:_ `(json-to-octs json)
|
||||
[200 [['content-type' 'application/json'] ?:(cache [max-1-da ~] ~)]]
|
||||
::
|
||||
++ manx-response
|
||||
=| cache=_|
|
||||
|= man=manx
|
||||
^- simple-payload:http
|
||||
:_ `(manx-to-octs man)
|
||||
[200 [['content-type' 'text/html'] ?:(cache [max-1-da ~] ~)]]
|
||||
::
|
||||
++ not-found
|
||||
^- simple-payload:http
|
||||
[[404 ~] ~]
|
||||
@ -123,10 +139,10 @@
|
||||
++ login-redirect
|
||||
|= =request:http
|
||||
^- simple-payload:http
|
||||
=/ redirect=cord
|
||||
%- crip
|
||||
"/~/login?redirect={(trip url.request)}"
|
||||
[[307 ['location' redirect]~] ~]
|
||||
=- [[307 ['location' -]~] ~]
|
||||
%^ cat 3
|
||||
'/~/login?redirect='
|
||||
url.request
|
||||
::
|
||||
++ redirect
|
||||
|= redirect=cord
|
||||
|
@ -29,11 +29,12 @@
|
||||
&((gte ver min) (lte ver version))
|
||||
::
|
||||
++ convert-to
|
||||
|= =cage
|
||||
^- vase
|
||||
?: =(p.cage current-version)
|
||||
q.cage
|
||||
((tube-to p.cage) q.cage)
|
||||
|= [=mark =vase]
|
||||
^- cage
|
||||
:- current-version
|
||||
?: =(mark current-version)
|
||||
vase
|
||||
((tube-to mark) vase)
|
||||
::
|
||||
++ tube-to
|
||||
|= =mark
|
||||
@ -44,10 +45,11 @@
|
||||
.^(tube:clay %cc (scry:io %home /[current-version]/[mark]))
|
||||
::
|
||||
++ convert-from
|
||||
|= =cage
|
||||
^- vase
|
||||
?: =(p.cage current-version)
|
||||
q.cage
|
||||
((tube-from p.cage) q.cage)
|
||||
|= [=mark =vase]
|
||||
^- cage
|
||||
:- mark
|
||||
?: =(mark current-version)
|
||||
vase
|
||||
((tube-from mark) vase)
|
||||
--
|
||||
|
||||
|
20
pkg/arvo/mar/graph/cache/hook.hoon
vendored
Normal file
20
pkg/arvo/mar/graph/cache/hook.hoon
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/- metadata=metadata-store, res=resource
|
||||
|%
|
||||
+$ cache-action
|
||||
$% [%graph-to-mark (pair resource:res (unit mark))]
|
||||
[%perm-marks (pair (pair mark @tas) tube:clay)]
|
||||
[%transform-marks (pair mark tube:clay)]
|
||||
==
|
||||
--
|
||||
::
|
||||
|_ act=cache-action
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun act
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun cache-action
|
||||
--
|
||||
--
|
12
pkg/arvo/mar/ico.hoon
Normal file
12
pkg/arvo/mar/ico.hoon
Normal file
@ -0,0 +1,12 @@
|
||||
|_ dat=@
|
||||
++ grow
|
||||
|%
|
||||
++ mime [/image/x-icon (as-octs:mimes:html dat)]
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ mime |=([p=mite q=octs] q.q)
|
||||
++ noun @
|
||||
--
|
||||
++ grad %mime
|
||||
--
|
@ -1,3 +1,3 @@
|
||||
module.exports = {
|
||||
extends: "@urbit"
|
||||
extends: '@urbit'
|
||||
};
|
3627
pkg/interface/package-lock.json
generated
3627
pkg/interface/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -8,9 +8,10 @@
|
||||
"@reach/disclosure": "^0.10.5",
|
||||
"@reach/menu-button": "^0.10.5",
|
||||
"@reach/tabs": "^0.10.5",
|
||||
"@react-spring/web": "^9.1.1",
|
||||
"@tlon/indigo-dark": "^1.0.6",
|
||||
"@tlon/indigo-light": "^1.0.7",
|
||||
"@tlon/indigo-react": "^1.2.21",
|
||||
"@tlon/indigo-react": "^1.2.22",
|
||||
"@tlon/sigil-js": "^1.4.3",
|
||||
"@urbit/api": "file:../npm/api",
|
||||
"any-ascii": "^0.1.7",
|
||||
@ -22,8 +23,7 @@
|
||||
"file-saver": "^2.0.5",
|
||||
"formik": "^2.1.5",
|
||||
"immer": "^8.0.1",
|
||||
"lodash": "^4.17.20",
|
||||
"markdown-to-jsx": "^6.11.4",
|
||||
"lodash": "^4.17.21",
|
||||
"moment": "^2.29.1",
|
||||
"mousetrap": "^1.6.5",
|
||||
"mousetrap-global-bind": "^1.1.0",
|
||||
@ -38,15 +38,18 @@
|
||||
"react-markdown": "^4.3.1",
|
||||
"react-oembed-container": "^1.0.0",
|
||||
"react-router-dom": "^5.2.0",
|
||||
"react-use-gesture": "^9.1.3",
|
||||
"react-virtuoso": "^0.20.3",
|
||||
"react-visibility-sensor": "^5.1.1",
|
||||
"remark-breaks": "^2.0.1",
|
||||
"remark-disable-tokenizers": "^1.0.24",
|
||||
"remark": "^12.0.0",
|
||||
"remark-breaks": "^2.0.2",
|
||||
"remark-disable-tokenizers": "1.1.0",
|
||||
"stacktrace-js": "^2.0.2",
|
||||
"style-loader": "^1.3.0",
|
||||
"styled-components": "^5.1.1",
|
||||
"styled-system": "^5.1.5",
|
||||
"suncalc": "^1.8.0",
|
||||
"unist-util-visit": "^3.0.0",
|
||||
"urbit-ob": "^5.0.1",
|
||||
"workbox-core": "^6.0.2",
|
||||
"workbox-precaching": "^6.0.2",
|
||||
|
@ -1,9 +1,7 @@
|
||||
import './wdyr';
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
|
||||
import './register-sw';
|
||||
|
||||
import App from './views/App';
|
||||
import './wdyr';
|
||||
|
||||
ReactDOM.render(<App />, document.getElementById('root'));
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Path, Patp } from '@urbit/api';
|
||||
import _ from 'lodash';
|
||||
import { Patp, Path } from '@urbit/api';
|
||||
import BaseStore from '../store/base';
|
||||
|
||||
export default class BaseApi<S extends object = {}> {
|
||||
|
@ -1,8 +1,8 @@
|
||||
import BaseApi from './base';
|
||||
import { StoreState } from '../store/type';
|
||||
import { Patp } from '@urbit/api';
|
||||
import { ContactEdit } from '@urbit/api/contacts';
|
||||
import { ContactEditField } from '@urbit/api/contacts';
|
||||
import _ from 'lodash';
|
||||
import { StoreState } from '../store/type';
|
||||
import BaseApi from './base';
|
||||
|
||||
export default class ContactsApi extends BaseApi<StoreState> {
|
||||
add(ship: Patp, contact: any) {
|
||||
@ -14,7 +14,7 @@ export default class ContactsApi extends BaseApi<StoreState> {
|
||||
return this.storeAction({ remove: { ship } });
|
||||
}
|
||||
|
||||
edit(ship: Patp, editField: ContactEdit) {
|
||||
edit(ship: Patp, editField: ContactEditField) {
|
||||
/* editField can be...
|
||||
{nickname: ''}
|
||||
{email: ''}
|
||||
@ -78,17 +78,17 @@ export default class ContactsApi extends BaseApi<StoreState> {
|
||||
return _.compact(
|
||||
await Promise.all(
|
||||
ships.map(
|
||||
async s => {
|
||||
async (s) => {
|
||||
const ship = `~${s}`;
|
||||
if(s === window.ship) {
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
const allowed = await this.fetchIsAllowed(
|
||||
`~${window.ship}`,
|
||||
'personal',
|
||||
ship,
|
||||
true
|
||||
)
|
||||
);
|
||||
return allowed ? null : ship;
|
||||
}
|
||||
)
|
||||
|
@ -1,7 +1,5 @@
|
||||
import BaseApi from './base';
|
||||
import type { StoreState } from '../store/type';
|
||||
import type {GcpToken} from '../../types/gcp-state';
|
||||
|
||||
import BaseApi from './base';
|
||||
|
||||
export default class GcpApi extends BaseApi<StoreState> {
|
||||
// Does not touch the store; use the value manually.
|
||||
@ -18,4 +16,4 @@ export default class GcpApi extends BaseApi<StoreState> {
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
import { Patp } from '@urbit/api';
|
||||
import BaseApi from './base';
|
||||
import { StoreState } from '../store/type';
|
||||
import GlobalStore from '../store/store';
|
||||
import LocalApi from './local';
|
||||
import InviteApi from './invite';
|
||||
import MetadataApi from './metadata';
|
||||
import { StoreState } from '../store/type';
|
||||
import BaseApi from './base';
|
||||
import ContactsApi from './contacts';
|
||||
import GroupsApi from './groups';
|
||||
import LaunchApi from './launch';
|
||||
import GraphApi from './graph';
|
||||
import S3Api from './s3';
|
||||
import GcpApi from './gcp';
|
||||
import GraphApi from './graph';
|
||||
import GroupsApi from './groups';
|
||||
import { HarkApi } from './hark';
|
||||
import InviteApi from './invite';
|
||||
import LaunchApi from './launch';
|
||||
import LocalApi from './local';
|
||||
import MetadataApi from './metadata';
|
||||
import S3Api from './s3';
|
||||
import SettingsApi from './settings';
|
||||
|
||||
export default class GlobalApi extends BaseApi<StoreState> {
|
||||
|
@ -1,16 +1,16 @@
|
||||
import BaseApi from './base';
|
||||
import { StoreState } from '../store/type';
|
||||
import { Patp, Path, Resource } from '@urbit/api';
|
||||
import { Content, Enc, GraphNode, GroupPolicy, Path, Patp, Post, Resource } from '@urbit/api';
|
||||
import BigIntOrderedMap from '@urbit/api/lib/BigIntOrderedMap';
|
||||
import _ from 'lodash';
|
||||
import { decToUd, deSig, resourceAsPath, unixToDa } from '~/logic/lib/util';
|
||||
import { makeResource, resourceFromPath } from '../lib/group';
|
||||
import { GroupPolicy, Enc, Post, Content } from '@urbit/api';
|
||||
import { numToUd, unixToDa, decToUd, deSig, resourceAsPath } from '~/logic/lib/util';
|
||||
import { StoreState } from '../store/type';
|
||||
import BaseApi from './base';
|
||||
|
||||
export const createBlankNodeWithChildPost = (
|
||||
parentIndex = '',
|
||||
childIndex = '',
|
||||
contents: Content[]
|
||||
) => {
|
||||
): GraphNode => {
|
||||
const date = unixToDa(Date.now()).toString();
|
||||
const nodeIndex = parentIndex + '/' + date;
|
||||
|
||||
@ -36,7 +36,7 @@ export const createBlankNodeWithChildPost = (
|
||||
hash: null,
|
||||
signatures: []
|
||||
},
|
||||
children: childGraph
|
||||
children: childGraph as BigIntOrderedMap<GraphNode>
|
||||
};
|
||||
};
|
||||
|
||||
@ -185,13 +185,12 @@ export default class GraphApi extends BaseApi<StoreState> {
|
||||
});
|
||||
}
|
||||
|
||||
eval(cord: string) {
|
||||
eval(cord: string): Promise<string[] | undefined> {
|
||||
return this.spider('graph-view-action', 'tang', 'graph-eval', {
|
||||
eval: cord
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
addGraph(ship: Patp, name: string, graph: any, mark: any) {
|
||||
return this.storeAction({
|
||||
'add-graph': {
|
||||
@ -211,7 +210,7 @@ export default class GraphApi extends BaseApi<StoreState> {
|
||||
return this.addNodes(ship, name, nodes);
|
||||
}
|
||||
|
||||
addNode(ship: Patp, name: string, node: Object) {
|
||||
addNode(ship: Patp, name: string, node: GraphNode) {
|
||||
const nodes = {};
|
||||
nodes[node.post.index] = node;
|
||||
|
||||
@ -265,7 +264,7 @@ export default class GraphApi extends BaseApi<StoreState> {
|
||||
'resource',
|
||||
'graph-create-group-feed',
|
||||
{
|
||||
"create-group-feed": { resource: group, vip }
|
||||
'create-group-feed': { resource: group, vip }
|
||||
}
|
||||
);
|
||||
return resource;
|
||||
@ -277,12 +276,11 @@ export default class GraphApi extends BaseApi<StoreState> {
|
||||
'json',
|
||||
'graph-disable-group-feed',
|
||||
{
|
||||
"disable-group-feed": { resource: group }
|
||||
'disable-group-feed': { resource: group }
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
removePosts(ship: Patp, name: string, indices: string[]) {
|
||||
return this.hookAction(ship, {
|
||||
'remove-posts': {
|
||||
@ -369,7 +367,7 @@ export default class GraphApi extends BaseApi<StoreState> {
|
||||
const node = data['graph-update'];
|
||||
this.store.handleEvent({
|
||||
data: {
|
||||
"graph-update-loose": node
|
||||
'graph-update-loose': node
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
import BaseApi from './base';
|
||||
import { StoreState } from '../store/type';
|
||||
import { Path, Patp, Enc } from '@urbit/api';
|
||||
import { Enc, Patp } from '@urbit/api';
|
||||
import {
|
||||
GroupAction,
|
||||
GroupPolicy,
|
||||
Resource,
|
||||
Tag,
|
||||
GroupPolicyDiff
|
||||
|
||||
GroupPolicyDiff, Resource,
|
||||
Tag
|
||||
} from '@urbit/api/groups';
|
||||
import { makeResource } from '../lib/group';
|
||||
import { StoreState } from '../store/type';
|
||||
import BaseApi from './base';
|
||||
|
||||
export default class GroupsApi extends BaseApi<StoreState> {
|
||||
remove(resource: Resource, ships: Patp[]) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
import BaseApi from './base';
|
||||
import { StoreState } from '../store/type';
|
||||
import { dateToDa, decToUd } from '../lib/util';
|
||||
import { NotifIndex, IndexedNotification, Association, GraphNotifDescription } from '@urbit/api';
|
||||
import { Association, GraphNotifDescription, IndexedNotification, NotifIndex } from '@urbit/api';
|
||||
import { BigInteger } from 'big-integer';
|
||||
import { getParentIndex } from '../lib/notification';
|
||||
import { dateToDa, decToUd } from '../lib/util';
|
||||
import useHarkState from '../state/hark';
|
||||
import { StoreState } from '../store/type';
|
||||
import BaseApi from './base';
|
||||
|
||||
function getHarkSize() {
|
||||
return useHarkState.getState().notifications.size ?? 0;
|
||||
@ -75,7 +75,6 @@ export class HarkApi extends BaseApi<StoreState> {
|
||||
graph: {
|
||||
graph: association.resource,
|
||||
group: association.group,
|
||||
module: association.metadata.module,
|
||||
description,
|
||||
index: parent
|
||||
} }
|
||||
|
@ -1,6 +1,6 @@
|
||||
import BaseApi from './base';
|
||||
import { Serial } from '@urbit/api';
|
||||
import { StoreState } from '../store/type';
|
||||
import { Serial, Path } from '@urbit/api';
|
||||
import BaseApi from './base';
|
||||
|
||||
export default class InviteApi extends BaseApi<StoreState> {
|
||||
accept(app: string, uid: Serial) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import BaseApi from './base';
|
||||
import { StoreState } from '../store/type';
|
||||
import BaseApi from './base';
|
||||
|
||||
export default class LaunchApi extends BaseApi<StoreState> {
|
||||
add(name: string, tile = { basic : { title: '', linkedUrl: '', iconUrl: '' } }) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import BaseApi from './base';
|
||||
import { StoreState } from '../store/type';
|
||||
import BaseApi from './base';
|
||||
|
||||
export default class LocalApi extends BaseApi<StoreState> {
|
||||
getBaseHash() {
|
||||
@ -8,7 +8,9 @@ export default class LocalApi extends BaseApi<StoreState> {
|
||||
});
|
||||
}
|
||||
|
||||
dehydrate() {
|
||||
this.store.dehydrate();
|
||||
getRuntimeLag() {
|
||||
return this.scry<boolean>('launch', '/runtime-lag').then((runtimeLag) => {
|
||||
this.store.handleEvent({ data: { runtimeLag } });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
import BaseApi from './base';
|
||||
import { StoreState } from '../store/type';
|
||||
import { Path, Patp, Association, Metadata, MetadataUpdatePreview } from '@urbit/api';
|
||||
import { Association, Metadata, MetadataUpdatePreview, Path } from '@urbit/api';
|
||||
import { uxToHex } from '../lib/util';
|
||||
import { StoreState } from '../store/type';
|
||||
import BaseApi from './base';
|
||||
|
||||
export default class MetadataApi extends BaseApi<StoreState> {
|
||||
metadataAdd(appName: string, resource: Path, group: Path, title: string, description: string, dateCreated: string, color: string, moduleName: string) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
import BaseApi from './base';
|
||||
import { StoreState } from '../store/type';
|
||||
import { S3Update } from '../../types/s3-update';
|
||||
import BaseApi from './base';
|
||||
|
||||
export default class S3Api extends BaseApi<StoreState> {
|
||||
setCurrentBucket(bucket: string) {
|
||||
|
@ -1,12 +1,13 @@
|
||||
import BaseApi from './base';
|
||||
import { StoreState } from '../store/type';
|
||||
import { Key,
|
||||
Value,
|
||||
Bucket
|
||||
import {
|
||||
Bucket, Key,
|
||||
|
||||
SettingsUpdate, Value
|
||||
} from '@urbit/api/settings';
|
||||
import { StoreState } from '../store/type';
|
||||
import BaseApi from './base';
|
||||
|
||||
export default class SettingsApi extends BaseApi<StoreState> {
|
||||
private storeAction(action: SettingsEvent): Promise<any> {
|
||||
private storeAction(action: SettingsUpdate): Promise<any> {
|
||||
return this.action('settings-store', 'settings-event', action);
|
||||
}
|
||||
|
||||
@ -47,14 +48,14 @@ export default class SettingsApi extends BaseApi<StoreState> {
|
||||
}
|
||||
|
||||
async getAll() {
|
||||
const { all } = await this.scry("settings-store", "/all");
|
||||
const { all } = await this.scry('settings-store', '/all');
|
||||
this.store.handleEvent({ data:
|
||||
{"settings-data": { all } }
|
||||
{ 'settings-data': { all } }
|
||||
});
|
||||
}
|
||||
|
||||
async getBucket(bucket: Key) {
|
||||
const data = await this.scry('settings-store', `/bucket/${bucket}`);
|
||||
const data: Record<string, unknown> = await this.scry('settings-store', `/bucket/${bucket}`);
|
||||
this.store.handleEvent({ data: { 'settings-data': {
|
||||
'bucket-key': bucket,
|
||||
'bucket': data.bucket
|
||||
@ -62,7 +63,7 @@ export default class SettingsApi extends BaseApi<StoreState> {
|
||||
}
|
||||
|
||||
async getEntry(bucket: Key, entry: Key) {
|
||||
const data = await this.scry('settings-store', `/entry/${bucket}/${entry}`);
|
||||
const data: Record<string, unknown> = await this.scry('settings-store', `/entry/${bucket}/${entry}`);
|
||||
this.store.handleEvent({ data: { 'settings-data': {
|
||||
'bucket-key': bucket,
|
||||
'entry-key': entry,
|
||||
|
@ -7,14 +7,12 @@
|
||||
//
|
||||
import querystring from 'querystring';
|
||||
import {
|
||||
StorageAcl,
|
||||
StorageClient,
|
||||
StorageUpload,
|
||||
UploadParams,
|
||||
UploadResult
|
||||
} from './StorageClient';
|
||||
|
||||
|
||||
const ENDPOINT = 'storage.googleapis.com';
|
||||
|
||||
class GcpUpload implements StorageUpload {
|
||||
|
@ -1,14 +1,13 @@
|
||||
// Defines a StorageClient interface interoperable between S3 and GCP Storage.
|
||||
//
|
||||
|
||||
|
||||
// XX kind of gross. S3 needs 'public-read', GCP needs 'publicRead'.
|
||||
// Rather than write a wrapper around S3, we offer this field here, which
|
||||
// should always be passed, and will be replaced by 'publicRead' in the
|
||||
// GCP client.
|
||||
export enum StorageAcl {
|
||||
PublicRead = 'public-read'
|
||||
};
|
||||
}
|
||||
|
||||
export interface UploadParams {
|
||||
Bucket: string; // the bucket to upload the object to
|
||||
@ -16,17 +15,17 @@ export interface UploadParams {
|
||||
ContentType: string; // the object's mime-type
|
||||
ACL: StorageAcl; // ACL, always 'public-read'
|
||||
Body: File; // the object itself
|
||||
};
|
||||
}
|
||||
|
||||
export interface UploadResult {
|
||||
Location: string;
|
||||
};
|
||||
}
|
||||
|
||||
// Extra layer of indirection used by S3 client.
|
||||
export interface StorageUpload {
|
||||
promise(): Promise<UploadResult>;
|
||||
};
|
||||
}
|
||||
|
||||
export interface StorageClient {
|
||||
upload(params: UploadParams): StorageUpload;
|
||||
};
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import bigInt, { BigInteger } from 'big-integer';
|
||||
import { BigInteger } from 'big-integer';
|
||||
|
||||
export function max(a: BigInteger, b: BigInteger) {
|
||||
return a.gt(b) ? a : b;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React from "react";
|
||||
import React from 'react';
|
||||
|
||||
export type SubmitHandler = () => Promise<any>;
|
||||
interface IFormGroupContext {
|
||||
@ -12,7 +12,7 @@ const fallback: IFormGroupContext = {
|
||||
addSubmit: () => {},
|
||||
onDirty: () => {},
|
||||
onErrors: () => {},
|
||||
submitAll: () => Promise.resolve(),
|
||||
submitAll: () => Promise.resolve()
|
||||
};
|
||||
|
||||
export const FormGroupContext = React.createContext(fallback);
|
||||
|
@ -15,7 +15,6 @@
|
||||
import GlobalApi from '../api/global';
|
||||
import useStorageState from '../state/storage';
|
||||
|
||||
|
||||
class GcpManager {
|
||||
#api: GlobalApi | null = null;
|
||||
|
||||
@ -59,15 +58,15 @@ class GcpManager {
|
||||
this.start();
|
||||
}
|
||||
|
||||
#consecutiveFailures: number = 0;
|
||||
#configured: boolean = false;
|
||||
#consecutiveFailures = 0;
|
||||
#configured = false;
|
||||
|
||||
private refreshLoop() {
|
||||
if (!this.#configured) {
|
||||
this.#api!.gcp.isConfigured()
|
||||
.then((configured) => {
|
||||
if (configured === undefined) {
|
||||
throw new Error("can't check whether GCP is configured?");
|
||||
throw new Error('can\'t check whether GCP is configured?');
|
||||
}
|
||||
this.#configured = configured;
|
||||
if (this.#configured) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { Path, PatpNoSig } from '@urbit/api';
|
||||
import { Group, Resource, roleTags, RoleTags } from '@urbit/api/groups';
|
||||
import _ from 'lodash';
|
||||
import { roleTags, RoleTags, Group, Resource } from '@urbit/api/groups';
|
||||
import { PatpNoSig, Path } from '@urbit/api';
|
||||
import { deSig } from './util';
|
||||
|
||||
export function roleForShip(
|
||||
group: Group,
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { IndexedNotification, NotificationGraphConfig, Unreads } from '@urbit/api';
|
||||
import bigInt, { BigInteger } from 'big-integer';
|
||||
import _ from 'lodash';
|
||||
import f from 'lodash/fp';
|
||||
import { Unreads, NotificationGraphConfig } from '@urbit/api';
|
||||
|
||||
export function getLastSeen(
|
||||
unreads: Unreads,
|
||||
@ -31,16 +32,29 @@ export function getNotificationCount(
|
||||
): number {
|
||||
const unread = unreads.graph?.[path] || {};
|
||||
return Object.keys(unread)
|
||||
.map(index => unread[index]?.notifications?.length || 0)
|
||||
.map(index => _.get(unread[index], 'notifications.length', 0))
|
||||
.reduce(f.add, 0);
|
||||
}
|
||||
|
||||
export function isWatching(
|
||||
config: NotificationGraphConfig,
|
||||
graph: string,
|
||||
index = "/"
|
||||
index = '/'
|
||||
) {
|
||||
return !!config.watching.find(
|
||||
return Boolean(config.watching.find(
|
||||
watch => watch.graph === graph && watch.index === index
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
export function getNotificationKey(time: BigInteger, notification: IndexedNotification): string {
|
||||
const base = time.toString();
|
||||
if('graph' in notification.index) {
|
||||
const { graph, index } = notification.index.graph;
|
||||
return `${base}-${graph}-${index}`;
|
||||
} else if('group' in notification.index) {
|
||||
const { group } = notification.index.group;
|
||||
return `${base}-${group}`;
|
||||
}
|
||||
return `${base}-unknown`;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
export function useIdlingState() {
|
||||
const [idling, setIdling] = useState(false);
|
||||
@ -16,7 +16,7 @@ export function useIdlingState() {
|
||||
return () => {
|
||||
window.removeEventListener('blur', blur);
|
||||
window.removeEventListener('focus', focus);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
return idling;
|
||||
|
@ -1,15 +1,15 @@
|
||||
import useLocalState, { LocalState } from "~/logic/state/local";
|
||||
import useSettingsState from "~/logic/state/settings";
|
||||
import GlobalApi from "../api/global";
|
||||
import { BackgroundConfig, RemoteContentPolicy } from "~/types";
|
||||
import useLocalState from '~/logic/state/local';
|
||||
import useSettingsState from '~/logic/state/settings';
|
||||
import { BackgroundConfig, RemoteContentPolicy } from '~/types';
|
||||
import GlobalApi from '../api/global';
|
||||
|
||||
const getBackgroundString = (bg: BackgroundConfig) => {
|
||||
if (bg?.type === "url") {
|
||||
if (bg?.type === 'url') {
|
||||
return bg.url;
|
||||
} else if (bg?.type === "color") {
|
||||
} else if (bg?.type === 'color') {
|
||||
return bg.color;
|
||||
} else {
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
@ -18,17 +18,17 @@ export function useMigrateSettings(api: GlobalApi) {
|
||||
const { display, remoteContentPolicy, calm } = useSettingsState();
|
||||
|
||||
return async () => {
|
||||
let promises: Promise<any>[] = [];
|
||||
const promises: Promise<any>[] = [];
|
||||
|
||||
if (local.hideAvatars !== calm.hideAvatars) {
|
||||
promises.push(
|
||||
api.settings.putEntry("calm", "hideAvatars", local.hideAvatars)
|
||||
api.settings.putEntry('calm', 'hideAvatars', local.hideAvatars)
|
||||
);
|
||||
}
|
||||
|
||||
if (local.hideNicknames !== calm.hideNicknames) {
|
||||
promises.push(
|
||||
api.settings.putEntry("calm", "hideNicknames", local.hideNicknames)
|
||||
api.settings.putEntry('calm', 'hideNicknames', local.hideNicknames)
|
||||
);
|
||||
}
|
||||
|
||||
@ -38,15 +38,15 @@ export function useMigrateSettings(api: GlobalApi) {
|
||||
) {
|
||||
promises.push(
|
||||
api.settings.putEntry(
|
||||
"display",
|
||||
"background",
|
||||
'display',
|
||||
'background',
|
||||
getBackgroundString(local.background)
|
||||
)
|
||||
);
|
||||
promises.push(
|
||||
api.settings.putEntry(
|
||||
"display",
|
||||
"backgroundType",
|
||||
'display',
|
||||
'backgroundType',
|
||||
local.background?.type
|
||||
)
|
||||
);
|
||||
@ -57,12 +57,12 @@ export function useMigrateSettings(api: GlobalApi) {
|
||||
const localVal = local.remoteContentPolicy[key];
|
||||
if (localVal !== remoteContentPolicy[key]) {
|
||||
promises.push(
|
||||
api.settings.putEntry("remoteContentPolicy", key, localVal)
|
||||
api.settings.putEntry('remoteContentPolicy', key, localVal)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
await Promise.all(promises);
|
||||
localStorage.removeItem("localReducer");
|
||||
localStorage.removeItem('localReducer');
|
||||
};
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { GraphNotifIndex, GraphNotificationContents } from '@urbit/api';
|
||||
import { GraphNotificationContents, GraphNotifIndex } from '@urbit/api';
|
||||
|
||||
export function getParentIndex(
|
||||
idx: GraphNotifIndex,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { cite } from '~/logic/lib/util';
|
||||
import { isChannelAdmin } from '~/logic/lib/group';
|
||||
import { cite } from '~/logic/lib/util';
|
||||
|
||||
const makeIndexes = () => new Map([
|
||||
['ships', []],
|
||||
@ -23,7 +23,7 @@ const result = function(title, link, app, host) {
|
||||
const shipIndex = function(contacts) {
|
||||
const ships = [];
|
||||
Object.keys(contacts).map((e) => {
|
||||
return ships.push(result(e, `/~profile/${e}`, 'profile', contacts[e]?.status || ""));
|
||||
return ships.push(result(e, `/~profile/${e}`, 'profile', contacts[e]?.status || ''));
|
||||
});
|
||||
return ships;
|
||||
};
|
||||
@ -38,11 +38,11 @@ const commandIndex = function (currentGroup, groups, associations) {
|
||||
? (association.metadata.vip === 'member-metadata' || isChannelAdmin(group, currentGroup))
|
||||
: !currentGroup; // home workspace or hasn't loaded
|
||||
const workspace = currentGroup || '/home';
|
||||
commands.push(result(`Groups: Create`, `/~landscape/new`, 'Groups', null));
|
||||
commands.push(result('Groups: Create', '/~landscape/new', 'Groups', null));
|
||||
if (canAdd) {
|
||||
commands.push(result(`Channel: Create`, `/~landscape${workspace}/new`, 'Groups', null));
|
||||
commands.push(result('Channel: Create', `/~landscape${workspace}/new`, 'Groups', null));
|
||||
}
|
||||
commands.push(result(`Groups: Join`, `/~landscape/join`, 'Groups', null));
|
||||
commands.push(result('Groups: Join', '/~landscape/join', 'Groups', null));
|
||||
|
||||
return commands;
|
||||
};
|
||||
@ -80,7 +80,7 @@ const otherIndex = function(config) {
|
||||
logout: result('Log Out', '/~/logout', 'logout', null)
|
||||
};
|
||||
other.push(result('Tutorial', '/?tutorial=true', 'tutorial', null));
|
||||
for(let cat of config.categories) {
|
||||
for(const cat of config.categories) {
|
||||
if(idx[cat]) {
|
||||
other.push(idx[cat]);
|
||||
}
|
||||
@ -102,7 +102,7 @@ export default function index(contacts, associations, apps, currentGroup, groups
|
||||
}).map((e) => {
|
||||
// iterate through each app's metadata object
|
||||
Object.keys(associations[e])
|
||||
.filter((association) => !associations?.[e]?.[association]?.metadata?.hidden)
|
||||
.filter(association => !associations?.[e]?.[association]?.metadata?.hidden)
|
||||
.map((association) => {
|
||||
const each = associations[e][association];
|
||||
let title = each.resource;
|
||||
|
@ -1,15 +1,12 @@
|
||||
|
||||
import {
|
||||
Association,
|
||||
resourceFromPath,
|
||||
Group,
|
||||
ReferenceContent,
|
||||
} from "@urbit/api";
|
||||
ReferenceContent, resourceFromPath
|
||||
} from '@urbit/api';
|
||||
|
||||
export function getPermalinkForGraph(
|
||||
group: string,
|
||||
graph: string,
|
||||
index = ""
|
||||
index = ''
|
||||
) {
|
||||
const groupLink = getPermalinkForAssociatedGroup(group);
|
||||
const { ship, name } = resourceFromPath(graph);
|
||||
@ -21,16 +18,16 @@ function getPermalinkForAssociatedGroup(group: string) {
|
||||
return `web+urbitgraph://group/${ship}/${name}`;
|
||||
}
|
||||
|
||||
|
||||
type Permalink = GraphPermalink | GroupPermalink;
|
||||
|
||||
interface GroupPermalink {
|
||||
type: "group";
|
||||
export interface GroupPermalink {
|
||||
type: 'group';
|
||||
group: string;
|
||||
link: string;
|
||||
}
|
||||
interface GraphPermalink {
|
||||
type: "graph";
|
||||
|
||||
export interface GraphPermalink {
|
||||
type: 'graph';
|
||||
link: string;
|
||||
graph: string;
|
||||
group: string;
|
||||
@ -43,16 +40,16 @@ function parseGraphPermalink(
|
||||
segments: string[]
|
||||
): GraphPermalink | null {
|
||||
const [kind, ship, name, ...index] = segments;
|
||||
if (kind !== "graph") {
|
||||
if (kind !== 'graph') {
|
||||
return null;
|
||||
}
|
||||
const graph = `/ship/${ship}/${name}`;
|
||||
return {
|
||||
type: "graph",
|
||||
type: 'graph',
|
||||
link: link.slice(16),
|
||||
graph,
|
||||
group,
|
||||
index: `/${index.join("/")}`,
|
||||
index: `/${index.join('/')}`
|
||||
};
|
||||
}
|
||||
|
||||
@ -64,7 +61,7 @@ export function permalinkToReference(link: Permalink): ReferenceContent {
|
||||
group: link.group,
|
||||
index: link.index
|
||||
}
|
||||
}
|
||||
};
|
||||
return { reference };
|
||||
} else {
|
||||
const reference = {
|
||||
@ -89,22 +86,22 @@ export function referenceToPermalink({ reference }: ReferenceContent): Permalink
|
||||
type: 'group',
|
||||
link,
|
||||
...reference
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function parsePermalink(url: string): Permalink | null {
|
||||
const [kind, ...rest] = url.slice(17).split("/");
|
||||
if (kind === "group") {
|
||||
const [kind, ...rest] = url.slice(17).split('/');
|
||||
if (kind === 'group') {
|
||||
const [ship, name, ...graph] = rest;
|
||||
const group = `/ship/${ship}/${name}`;
|
||||
if (graph.length > 0) {
|
||||
return parseGraphPermalink(url, group, graph);
|
||||
}
|
||||
return {
|
||||
type: "group",
|
||||
type: 'group',
|
||||
group,
|
||||
link: url.slice(11),
|
||||
link: url.slice(11)
|
||||
};
|
||||
}
|
||||
return null;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Post, GraphNode } from '@urbit/api';
|
||||
import { GraphNode, Post } from '@urbit/api';
|
||||
|
||||
export const buntPost = (): Post => ({
|
||||
author: '',
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { Post, GraphNode, TextContent } from '@urbit/api';
|
||||
import { Content, GraphNode, Post, TextContent } from '@urbit/api';
|
||||
import BigIntOrderedMap from '@urbit/api/lib/BigIntOrderedMap';
|
||||
import bigInt, { BigInteger } from 'big-integer';
|
||||
import { buntPost } from '~/logic/lib/post';
|
||||
import { unixToDa } from '~/logic/lib/util';
|
||||
import BigIntOrderedMap from "@urbit/api/lib/BigIntOrderedMap";
|
||||
import bigInt, { BigInteger } from 'big-integer';
|
||||
import tokenizeMessage from './tokenizeMessage';
|
||||
|
||||
export function newPost(
|
||||
title: string,
|
||||
@ -19,13 +20,15 @@ export function newPost(
|
||||
signatures: []
|
||||
};
|
||||
|
||||
const tokenisedBody = tokenizeMessage(body);
|
||||
|
||||
const revContainer: Post = { ...root, index: root.index + '/1' };
|
||||
const commentsContainer = { ...root, index: root.index + '/2' };
|
||||
|
||||
const firstRevision: Post = {
|
||||
...revContainer,
|
||||
index: revContainer.index + '/1',
|
||||
contents: [{ text: title }, { text: body }]
|
||||
contents: [{ text: title }, ...tokenisedBody]
|
||||
};
|
||||
|
||||
const nodes = {
|
||||
@ -54,11 +57,12 @@ export function newPost(
|
||||
|
||||
export function editPost(rev: number, noteId: BigInteger, title: string, body: string) {
|
||||
const now = Date.now();
|
||||
const tokenisedBody = tokenizeMessage(body);
|
||||
const newRev: Post = {
|
||||
author: `~${window.ship}`,
|
||||
index: `/${noteId.toString()}/1/${rev}`,
|
||||
'time-sent': now,
|
||||
contents: [{ text: title }, { text: body }],
|
||||
contents: [{ text: title }, ...tokenisedBody],
|
||||
hash: null,
|
||||
signatures: []
|
||||
};
|
||||
@ -85,8 +89,9 @@ export function getLatestRevision(node: GraphNode): [number, string, string, Pos
|
||||
if (!rev) {
|
||||
return empty;
|
||||
}
|
||||
const [title, body] = rev.post.contents as TextContent[];
|
||||
return [revNum.toJSNumber(), title.text, body.text, rev.post];
|
||||
const title = rev.post.contents[0];
|
||||
const body = rev.post.contents.slice(1);
|
||||
return [revNum.toJSNumber(), title.text, body, rev.post];
|
||||
}
|
||||
|
||||
export function getLatestCommentRevision(node: GraphNode): [number, Post] {
|
||||
@ -113,10 +118,12 @@ export function getComments(node: GraphNode): GraphNode {
|
||||
return comments;
|
||||
}
|
||||
|
||||
export function getSnippet(body: string) {
|
||||
const newlineIdx = body.indexOf('\n', 2);
|
||||
const end = newlineIdx > -1 ? newlineIdx : body.length;
|
||||
const start = body.substr(0, end);
|
||||
export function getSnippet(body: Content[]) {
|
||||
const firstContent = body
|
||||
.filter((c: Content): c is TextContent => 'text' in c).map(c => c.text)[0] ?? '';
|
||||
const newlineIdx = firstContent.indexOf('\n', 2);
|
||||
const end = newlineIdx > -1 ? newlineIdx : firstContent.length;
|
||||
const start = firstContent.substr(0, end);
|
||||
|
||||
return (start === body || start.startsWith('![')) ? start : `${start}...`;
|
||||
return (start === firstContent || firstContent.startsWith('![')) ? start : `${start}...`;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React, { memo } from 'react';
|
||||
import { sigil, reactRenderer } from '@tlon/sigil-js';
|
||||
import { Box } from '@tlon/indigo-react';
|
||||
import { reactRenderer, sigil } from '@tlon/sigil-js';
|
||||
import React, { memo } from 'react';
|
||||
|
||||
export const foregroundFromBackground = (background) => {
|
||||
const rgb = {
|
||||
|
@ -1,31 +1,43 @@
|
||||
import urbitOb from 'urbit-ob';
|
||||
import { parsePermalink, permalinkToReference } from "~/logic/lib/permalinks";
|
||||
import { parsePermalink, permalinkToReference } from '~/logic/lib/permalinks';
|
||||
|
||||
const URL_REGEX = new RegExp(String(/^(([\w\-\+]+:\/\/)[-a-zA-Z0-9:@;?&=\/%\+\.\*!'\(\),\$_\{\}\^~\[\]`#|]+\w)/.source));
|
||||
|
||||
const GROUP_REGEX = new RegExp(String(/^~[-a-z_]+\/[-a-z]+/.source));
|
||||
|
||||
const isUrl = (string) => {
|
||||
try {
|
||||
return URL_REGEX.test(string);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const isRef = (str) => {
|
||||
return isUrl(str) && str.startsWith("web+urbitgraph://");
|
||||
return isUrl(str) && str.startsWith('web+urbitgraph://');
|
||||
};
|
||||
|
||||
const isGroup = str => {
|
||||
try {
|
||||
return GROUP_REGEX.test(str);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const convertToGroupRef = (group) => `web+urbitgraph://group/${group}`;
|
||||
|
||||
const tokenizeMessage = (text) => {
|
||||
let messages = [];
|
||||
let message = [];
|
||||
// by line
|
||||
let currTextBlock = [];
|
||||
let isInCodeBlock = false;
|
||||
let endOfCodeBlock = false;
|
||||
text.split(/\r?\n/).forEach((line, index) => {
|
||||
if (index !== 0) {
|
||||
message.push('\n');
|
||||
}
|
||||
// by space
|
||||
let currTextLine = [];
|
||||
// A line of backticks enters and exits a codeblock
|
||||
if (line.startsWith('```')) {
|
||||
if (line.trim().startsWith('```')) {
|
||||
// But we need to check if we've ended a codeblock
|
||||
endOfCodeBlock = isInCodeBlock;
|
||||
isInCodeBlock = (!isInCodeBlock);
|
||||
@ -34,25 +46,26 @@ const tokenizeMessage = (text) => {
|
||||
}
|
||||
|
||||
if (isInCodeBlock || endOfCodeBlock) {
|
||||
message.push(line);
|
||||
currTextLine = [line];
|
||||
} else {
|
||||
line.split(/\s/).forEach((str) => {
|
||||
const words = line.split(/\s/);
|
||||
words.forEach((word, idx) => {
|
||||
const str = isGroup(word) ? convertToGroupRef(word) : word;
|
||||
|
||||
const last = words.length - 1 === idx;
|
||||
if (
|
||||
(str.startsWith('`') && str !== '`')
|
||||
|| (str === '`' && !isInCodeBlock)
|
||||
) {
|
||||
isInCodeBlock = true;
|
||||
} else if (
|
||||
(str.endsWith('`') && str !== '`')
|
||||
|| (str === '`' && isInCodeBlock)
|
||||
) {
|
||||
isInCodeBlock = false;
|
||||
}
|
||||
|
||||
if(isRef(str) && !isInCodeBlock) {
|
||||
if (message.length > 0) {
|
||||
if (currTextLine.length > 0 || currTextBlock.length > 0) {
|
||||
// If we're in the middle of a message, add it to the stack and reset
|
||||
messages.push({ text: message.join(' ') });
|
||||
currTextLine.push('');
|
||||
messages.push({ text: currTextBlock.join('\n') + currTextLine.join(' ') });
|
||||
currTextBlock = last ? [''] : [];
|
||||
currTextLine = [];
|
||||
}
|
||||
const link = parsePermalink(str);
|
||||
if(!link) {
|
||||
@ -61,34 +74,46 @@ const tokenizeMessage = (text) => {
|
||||
const reference = permalinkToReference(link);
|
||||
messages.push(reference);
|
||||
}
|
||||
message = [];
|
||||
currTextLine = [];
|
||||
} else if (isUrl(str) && !isInCodeBlock) {
|
||||
if (message.length > 0) {
|
||||
if (currTextLine.length > 0 || currTextBlock.length > 0) {
|
||||
// If we're in the middle of a message, add it to the stack and reset
|
||||
messages.push({ text: message.join(' ') });
|
||||
message = [];
|
||||
currTextLine.push('');
|
||||
messages.push({ text: currTextBlock.join('\n') + currTextLine.join(' ') });
|
||||
currTextBlock = last ? [''] : [];
|
||||
currTextLine = [];
|
||||
}
|
||||
messages.push({ url: str });
|
||||
message = [];
|
||||
currTextLine = [];
|
||||
} else if(urbitOb.isValidPatp(str) && !isInCodeBlock) {
|
||||
if (message.length > 0) {
|
||||
if (currTextLine.length > 0 || currTextBlock.length > 0) {
|
||||
// If we're in the middle of a message, add it to the stack and reset
|
||||
messages.push({ text: message.join(' ') });
|
||||
message = [];
|
||||
currTextLine.push('');
|
||||
messages.push({ text: currTextBlock.join('\n') + currTextLine.join(' ') });
|
||||
currTextBlock = last ? [''] : [];
|
||||
currTextLine = [];
|
||||
}
|
||||
messages.push({ mention: str });
|
||||
message = [];
|
||||
currTextLine = [];
|
||||
|
||||
} else {
|
||||
message.push(str);
|
||||
currTextLine.push(str);
|
||||
}
|
||||
if (
|
||||
(str.endsWith('`') && str !== '`')
|
||||
|| (str === '`' && isInCodeBlock)
|
||||
) {
|
||||
isInCodeBlock = false;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
currTextBlock.push(currTextLine.join(' '))
|
||||
});
|
||||
|
||||
if (message.length) {
|
||||
if (currTextBlock.length) {
|
||||
// Add any remaining message
|
||||
messages.push({ text: message.join(' ') });
|
||||
messages.push({ text: currTextBlock.join('\n') });
|
||||
}
|
||||
return messages;
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Associations } from '@urbit/api';
|
||||
import { TutorialProgress } from '~/types';
|
||||
import { AlignX, AlignY } from '~/logic/lib/relativePosition';
|
||||
import { TutorialProgress } from '~/types';
|
||||
import { Direction } from '~/views/components/Triangle';
|
||||
|
||||
export const MODAL_WIDTH = 256;
|
||||
@ -92,7 +92,7 @@ export const progressDetails: Record<TutorialProgress, StepDetail> = {
|
||||
alignY: 'top',
|
||||
arrow: 'East',
|
||||
offsetX: MODAL_WIDTH + 24,
|
||||
offsetY: 80,
|
||||
offsetY: 80
|
||||
},
|
||||
channels: {
|
||||
title: 'Channels',
|
||||
@ -157,17 +157,17 @@ export const progressDetails: Record<TutorialProgress, StepDetail> = {
|
||||
alignX: 'right',
|
||||
arrow: 'South',
|
||||
offsetX: -300 + MODAL_WIDTH / 2,
|
||||
offsetY: -4,
|
||||
offsetY: -4
|
||||
},
|
||||
leap: {
|
||||
title: 'Leap',
|
||||
description:
|
||||
'Leap allows you to go to a specific channel, message, collection, profile or group simply by typing in a command or selecting a shortcut from the dropdown menu.',
|
||||
url: `/~profile/~${window.ship}`,
|
||||
alignY: "top",
|
||||
alignX: "left",
|
||||
arrow: "North",
|
||||
alignY: 'top',
|
||||
alignX: 'left',
|
||||
arrow: 'North',
|
||||
offsetX: 76,
|
||||
offsetY: -48,
|
||||
},
|
||||
offsetY: -48
|
||||
}
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { writeText } from "./util";
|
||||
import { useCallback, useState, useMemo } from "react";
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
import { writeText } from './util';
|
||||
|
||||
export function useCopy(copied: string, display: string) {
|
||||
export function useCopy(copied: string, display?: string) {
|
||||
const [didCopy, setDidCopy] = useState(false);
|
||||
const doCopy = useCallback(() => {
|
||||
writeText(copied);
|
||||
@ -11,9 +11,9 @@ export function useCopy(copied: string, display: string) {
|
||||
}, 2000);
|
||||
}, [copied]);
|
||||
|
||||
const copyDisplay = useMemo(() => (didCopy ? "Copied" : display), [
|
||||
const copyDisplay = useMemo(() => (didCopy ? 'Copied' : display), [
|
||||
didCopy,
|
||||
display,
|
||||
display
|
||||
]);
|
||||
|
||||
return { copyDisplay, doCopy, didCopy };
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { useState, useCallback, useMemo, useEffect } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
function validateDragEvent(e: DragEvent): FileList | File[] | true | null {
|
||||
const files: File[] = [];
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
export function useDropdown<C>(
|
||||
candidates: C[],
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { useEffect, RefObject, useRef, useState } from 'react';
|
||||
import _ from 'lodash';
|
||||
import { RefObject, useEffect, useState } from 'react';
|
||||
import usePreviousValue from './usePreviousValue';
|
||||
|
||||
export function distanceToBottom(el: HTMLElement) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { useState, useCallback, useEffect } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
function retrieve<T>(key: string, initial: T): T {
|
||||
const s = localStorage.getItem(key);
|
||||
|
@ -1,15 +1,13 @@
|
||||
import { Box } from '@tlon/indigo-react';
|
||||
import React, {
|
||||
useState,
|
||||
ReactNode,
|
||||
useCallback,
|
||||
useMemo,
|
||||
useRef
|
||||
useRef, useState
|
||||
} from 'react';
|
||||
|
||||
import { Box } from '@tlon/indigo-react';
|
||||
import { PropFunc } from '~/types';
|
||||
import { ModalOverlay } from '~/views/components/ModalOverlay';
|
||||
import { Portal } from '~/views/components/Portal';
|
||||
import { PropFunc } from '~/types';
|
||||
|
||||
type ModalFunc = (dismiss: () => void) => JSX.Element;
|
||||
interface UseModalProps {
|
||||
@ -59,7 +57,7 @@ export function useModal(props: UseModalProps & PropFunc<typeof Box>): UseModalR
|
||||
display="flex"
|
||||
alignItems="stretch"
|
||||
flexDirection="column"
|
||||
spacing="2"
|
||||
spacing={2}
|
||||
dismiss={dismiss}
|
||||
{...rest}
|
||||
>
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { useEffect, RefObject } from 'react';
|
||||
import { RefObject, useEffect } from 'react';
|
||||
|
||||
export function useOutsideClick(
|
||||
ref: RefObject<HTMLElement | null | undefined>,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { useMemo, useCallback } from "react";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import _ from "lodash";
|
||||
import _ from 'lodash';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
function mergeQuery(search: URLSearchParams, added: Record<string, string>) {
|
||||
_.forIn(added, (v, k) => {
|
||||
@ -32,7 +32,7 @@ export function useQuery() {
|
||||
mergeQuery(q, params);
|
||||
return {
|
||||
pathname: path,
|
||||
search: q.toString(),
|
||||
search: q.toString()
|
||||
};
|
||||
},
|
||||
[search, pathname]
|
||||
@ -41,6 +41,6 @@ export function useQuery() {
|
||||
return {
|
||||
query,
|
||||
appendQuery,
|
||||
toQuery,
|
||||
toQuery
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import {unstable_batchedUpdates} from "react-dom";
|
||||
import { useEffect, useState } from 'react';
|
||||
import { unstable_batchedUpdates } from 'react-dom';
|
||||
|
||||
export type IOInstance<I, P, O> = (
|
||||
input: I
|
||||
@ -29,7 +29,7 @@ export function useRunIO<I, O>(
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
reject(new Error("useRunIO: key changed"));
|
||||
reject(new Error('useRunIO: key changed'));
|
||||
setDone(false);
|
||||
setOutput(null);
|
||||
}, [key]);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { MouseEvent, useCallback, useState, useEffect } from 'react';
|
||||
import { MouseEvent, useCallback, useEffect, useState } from 'react';
|
||||
export type AsyncClickableState = 'waiting' | 'error' | 'loading' | 'success';
|
||||
|
||||
export function useStatelessAsyncClickable(
|
||||
|
@ -1,22 +1,16 @@
|
||||
import { useCallback, useMemo, useEffect, useRef, useState } from 'react';
|
||||
import {
|
||||
GcpState,
|
||||
S3State,
|
||||
StorageState
|
||||
} from '../../types';
|
||||
import S3 from 'aws-sdk/clients/s3';
|
||||
import GcpClient from './GcpClient';
|
||||
import { StorageClient, StorageAcl } from './StorageClient';
|
||||
import { dateToDa, deSig } from './util';
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import useStorageState from '../state/storage';
|
||||
|
||||
import GcpClient from './GcpClient';
|
||||
import { StorageAcl, StorageClient } from './StorageClient';
|
||||
import { dateToDa, deSig } from './util';
|
||||
|
||||
export interface IuseStorage {
|
||||
canUpload: boolean;
|
||||
upload: (file: File, bucket: string) => Promise<string>;
|
||||
uploadDefault: (file: File) => Promise<string>;
|
||||
uploading: boolean;
|
||||
promptUpload: () => Promise<unknown>;
|
||||
promptUpload: () => Promise<string>;
|
||||
}
|
||||
|
||||
const useStorage = ({ accept = '*' } = { accept: '*' }): IuseStorage => {
|
||||
@ -54,7 +48,7 @@ const useStorage = ({ accept = '*' } = { accept: '*' }): IuseStorage => {
|
||||
);
|
||||
|
||||
const upload = useCallback(
|
||||
async (file: File, bucket: string) => {
|
||||
async (file: File, bucket: string): Promise<string> => {
|
||||
if (client.current === null) {
|
||||
throw new Error('Storage not ready');
|
||||
}
|
||||
@ -83,7 +77,7 @@ const useStorage = ({ accept = '*' } = { accept: '*' }): IuseStorage => {
|
||||
[client, setUploading]
|
||||
);
|
||||
|
||||
const uploadDefault = useCallback(async (file: File) => {
|
||||
const uploadDefault = useCallback(async (file: File): Promise<string> => {
|
||||
if (s3.configuration.currentBucket === '') {
|
||||
throw new Error('current bucket not set');
|
||||
}
|
||||
@ -91,7 +85,7 @@ const useStorage = ({ accept = '*' } = { accept: '*' }): IuseStorage => {
|
||||
}, [s3, upload]);
|
||||
|
||||
const promptUpload = useCallback(
|
||||
() => {
|
||||
(): Promise<string> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const fileSelector = document.createElement('input');
|
||||
fileSelector.setAttribute('type', 'file');
|
||||
@ -101,10 +95,10 @@ const useStorage = ({ accept = '*' } = { accept: '*' }): IuseStorage => {
|
||||
const files = fileSelector.files;
|
||||
if (!files || files.length <= 0) {
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
uploadDefault(files[0]).then(resolve);
|
||||
document.body.removeChild(fileSelector);
|
||||
}
|
||||
});
|
||||
document.body.appendChild(fileSelector);
|
||||
fileSelector.click();
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { useState, useCallback } from "react";
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
export function useToggleState(initial: boolean) {
|
||||
const [state, setState] = useState(initial);
|
||||
|
||||
const toggle = useCallback(() => {
|
||||
setState((s) => !s);
|
||||
setState(s => !s);
|
||||
}, [setState]);
|
||||
|
||||
return [state, toggle] as const;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
export function useWaitForProps<P>(props: P, timeout = 0) {
|
||||
const [resolve, setResolve] = useState<() => void>(() => () => {});
|
||||
|
@ -1,15 +1,13 @@
|
||||
import { useEffect, useState, useCallback, useMemo } from 'react';
|
||||
import _ from 'lodash';
|
||||
import f, { compose, memoize } from 'lodash/fp';
|
||||
import bigInt, { BigInteger } from 'big-integer';
|
||||
/* eslint-disable max-lines */
|
||||
import { Association, Contact } from '@urbit/api';
|
||||
import useLocalState from '../state/local';
|
||||
import produce, { enableMapSet } from 'immer';
|
||||
import useSettingsState from '../state/settings';
|
||||
import { State, UseStore } from 'zustand';
|
||||
import { Cage } from '~/types/cage';
|
||||
import { BaseState } from '../state/base';
|
||||
import anyAscii from 'any-ascii';
|
||||
import bigInt, { BigInteger } from 'big-integer';
|
||||
import { enableMapSet } from 'immer';
|
||||
import _ from 'lodash';
|
||||
import f from 'lodash/fp';
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { IconRef } from '~/types';
|
||||
import useSettingsState from '../state/settings';
|
||||
|
||||
enableMapSet();
|
||||
|
||||
@ -24,7 +22,9 @@ export const MOMENT_CALENDAR_DATE = {
|
||||
sameElse: '~YYYY.M.D'
|
||||
};
|
||||
|
||||
export const getModuleIcon = (mod: string) => {
|
||||
export type GraphModule = 'link' | 'post' | 'chat' | 'publish';
|
||||
|
||||
export const getModuleIcon = (mod: GraphModule): IconRef => {
|
||||
if (mod === 'link') {
|
||||
return 'Collection';
|
||||
}
|
||||
@ -33,7 +33,7 @@ export const getModuleIcon = (mod: string) => {
|
||||
return 'Dashboard';
|
||||
}
|
||||
|
||||
return _.capitalize(mod);
|
||||
return _.capitalize(mod) as IconRef;
|
||||
};
|
||||
|
||||
export function wait(ms: number) {
|
||||
@ -172,9 +172,9 @@ export function dateToDa(d: Date, mil = false) {
|
||||
);
|
||||
}
|
||||
|
||||
export function deSig(ship: string) {
|
||||
export function deSig(ship: string): string {
|
||||
if (!ship) {
|
||||
return null;
|
||||
return '';
|
||||
}
|
||||
return ship.replace('~', '');
|
||||
}
|
||||
@ -201,7 +201,7 @@ export const hexToUx = (hex) => {
|
||||
return `0x${ux}`;
|
||||
};
|
||||
|
||||
export function writeText(str: string) {
|
||||
export function writeText(str: string | null): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(document.body);
|
||||
@ -226,11 +226,11 @@ export function writeText(str: string) {
|
||||
}
|
||||
|
||||
// trim patps to match dojo, chat-cli
|
||||
export function cite(ship: string) {
|
||||
export function cite(ship: string): string {
|
||||
let patp = ship,
|
||||
shortened = '';
|
||||
if (patp === null || patp === '') {
|
||||
return null;
|
||||
return '';
|
||||
}
|
||||
if (patp.startsWith('~')) {
|
||||
patp = patp.substr(1);
|
||||
@ -400,7 +400,7 @@ export function pluralize(text: string, isPlural = false, vowel = false) {
|
||||
export function useShowNickname(contact: Contact | null, hide?: boolean): boolean {
|
||||
const hideState = useSettingsState(state => state.calm.hideNicknames);
|
||||
const hideNicknames = typeof hide !== 'undefined' ? hide : hideState;
|
||||
return !!(contact && contact.nickname && !hideNicknames);
|
||||
return Boolean(contact && contact.nickname && !hideNicknames);
|
||||
}
|
||||
|
||||
interface useHoveringInterface {
|
||||
@ -413,19 +413,25 @@ interface useHoveringInterface {
|
||||
|
||||
export const useHovering = (): useHoveringInterface => {
|
||||
const [hovering, setHovering] = useState(false);
|
||||
const onMouseOver = useCallback(() => setHovering(true), [])
|
||||
const onMouseLeave = useCallback(() => setHovering(false), [])
|
||||
const onMouseOver = useCallback(() => setHovering(true), []);
|
||||
const onMouseLeave = useCallback(() => setHovering(false), []);
|
||||
const bind = useMemo(() => ({
|
||||
onMouseOver,
|
||||
onMouseLeave,
|
||||
onMouseLeave
|
||||
}), [onMouseLeave, onMouseOver]);
|
||||
|
||||
|
||||
return useMemo(() => ({ hovering, bind }), [hovering, bind]);
|
||||
};
|
||||
|
||||
export function withHovering<T>(Component: React.ComponentType<T>) {
|
||||
return React.forwardRef((props, ref) => {
|
||||
const { hovering, bind } = useHovering();
|
||||
return <Component ref={ref} hovering={hovering} bind={bind} {...props} />
|
||||
})
|
||||
}
|
||||
|
||||
const DM_REGEX = /ship\/~([a-z]|-)*\/dm--/;
|
||||
export function getItemTitle(association: Association) {
|
||||
export function getItemTitle(association: Association): string {
|
||||
if (DM_REGEX.test(association.resource)) {
|
||||
const [, , ship, name] = association.resource.split('/');
|
||||
if (ship.slice(1) === window.ship) {
|
||||
@ -433,6 +439,6 @@ export function getItemTitle(association: Association) {
|
||||
}
|
||||
return cite(ship);
|
||||
}
|
||||
return association.metadata.title || association.resource;
|
||||
return association.metadata.title ?? association.resource ?? '';
|
||||
}
|
||||
|
@ -1,13 +1,10 @@
|
||||
import React, {
|
||||
useContext,
|
||||
useState,
|
||||
useCallback,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
useEffect,
|
||||
} from "react";
|
||||
import usePreviousValue from "./usePreviousValue";
|
||||
import {Primitive} from "~/types";
|
||||
useCallback, useContext,
|
||||
|
||||
useEffect, useState
|
||||
} from 'react';
|
||||
import { Primitive } from '~/types';
|
||||
import usePreviousValue from './usePreviousValue';
|
||||
|
||||
export interface VirtualContextProps {
|
||||
save: () => void;
|
||||
@ -15,7 +12,7 @@ export interface VirtualContextProps {
|
||||
}
|
||||
const fallback: VirtualContextProps = {
|
||||
save: () => {},
|
||||
restore: () => {},
|
||||
restore: () => {}
|
||||
};
|
||||
|
||||
export const VirtualContext = React.createContext(fallback);
|
||||
@ -27,7 +24,7 @@ export function useVirtual() {
|
||||
export const withVirtual = <P extends {}>(Component: React.ComponentType<P>) =>
|
||||
React.forwardRef((props: P, ref) => (
|
||||
<VirtualContext.Consumer>
|
||||
{(context) => <Component ref={ref} {...props} {...context} />}
|
||||
{context => <Component ref={ref} {...props} {...context} />}
|
||||
</VirtualContext.Consumer>
|
||||
));
|
||||
|
||||
@ -52,7 +49,7 @@ export function useVirtualResizeState(s: boolean) {
|
||||
|
||||
export function useVirtualResizeProp(prop: Primitive) {
|
||||
const { save, restore } = useVirtual();
|
||||
const oldProp = usePreviousValue(prop)
|
||||
const oldProp = usePreviousValue(prop);
|
||||
|
||||
if(prop !== oldProp) {
|
||||
save();
|
||||
@ -61,6 +58,4 @@ export function useVirtualResizeProp(prop: Primitive) {
|
||||
useEffect(() => {
|
||||
requestAnimationFrame(restore);
|
||||
}, [prop]);
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import React from "react";
|
||||
import { ReactElement } from "react";
|
||||
import { UseStore } from "zustand";
|
||||
import { BaseState } from "../state/base";
|
||||
import React from 'react';
|
||||
import { UseStore } from 'zustand';
|
||||
import { BaseState } from '../state/base';
|
||||
|
||||
const withStateo = <
|
||||
StateType extends BaseState<any>
|
||||
@ -16,19 +15,21 @@ const withStateo = <
|
||||
(object, key) => ({ ...object, [key]: state[key] }), {}
|
||||
)
|
||||
) : useState();
|
||||
return <Component ref={ref} {...state} {...props} />
|
||||
})
|
||||
return <Component ref={ref} {...state} {...props} />;
|
||||
});
|
||||
};
|
||||
|
||||
const withState = <
|
||||
StateType extends BaseState<StateType>,
|
||||
stateKey extends keyof StateType
|
||||
>(
|
||||
interface StatePicker extends Array<any> {
|
||||
0: UseStore<any>;
|
||||
1?: string[];
|
||||
}
|
||||
|
||||
const withState = (
|
||||
Component: any,
|
||||
stores: ([UseStore<StateType>, stateKey[]])[],
|
||||
stores: StatePicker[]
|
||||
) => {
|
||||
return React.forwardRef((props, ref) => {
|
||||
let stateProps: unknown = {};
|
||||
const stateProps: unknown = {};
|
||||
stores.forEach(([store, keys]) => {
|
||||
const storeProps = Array.isArray(keys)
|
||||
? store(state => keys.reduce(
|
||||
@ -37,8 +38,8 @@ const withState = <
|
||||
: store();
|
||||
Object.assign(stateProps, storeProps);
|
||||
});
|
||||
return <Component ref={ref} {...stateProps} {...props} />
|
||||
return <Component ref={ref} {...stateProps} {...props} />;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default withState;
|
@ -18,10 +18,10 @@ export function getTitleFromWorkspace(
|
||||
|
||||
export function getGroupFromWorkspace(
|
||||
workspace: Workspace
|
||||
): string | undefined {
|
||||
): string {
|
||||
if (workspace.type === 'group') {
|
||||
return workspace.group;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return '';
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { StoreState } from '../store/type';
|
||||
import { Cage } from '~/types/cage';
|
||||
import { StoreState } from '../store/type';
|
||||
|
||||
type LocalState = Pick<StoreState, 'connection'>;
|
||||
|
||||
|
@ -1,11 +1,7 @@
|
||||
import _ from 'lodash';
|
||||
import { compose } from 'lodash/fp';
|
||||
|
||||
import { ContactUpdate } from '@urbit/api';
|
||||
|
||||
import useContactState, { ContactState } from '../state/contact';
|
||||
import _ from 'lodash';
|
||||
import { reduceState } from '../state/base';
|
||||
|
||||
import useContactState, { ContactState } from '../state/contact';
|
||||
|
||||
export const ContactReducer = (json) => {
|
||||
const data: ContactUpdate = _.get(json, 'contact-update', false);
|
||||
|
@ -1,8 +1,7 @@
|
||||
import {StoreState} from '../store/type';
|
||||
import type {GcpToken} from '../../types/gcp-state';
|
||||
import type { Cage } from '~/types/cage';
|
||||
import useStorageState, { StorageState } from '../state/storage';
|
||||
import type { GcpToken } from '../../types/gcp-state';
|
||||
import { reduceState } from '../state/base';
|
||||
import useStorageState, { StorageState } from '../state/storage';
|
||||
|
||||
export default class GcpReducer {
|
||||
reduce(json: Cage) {
|
||||
@ -13,21 +12,21 @@ export default class GcpReducer {
|
||||
}
|
||||
|
||||
const reduceToken = (json: Cage, state: StorageState): StorageState => {
|
||||
let data = json['gcp-token'];
|
||||
const data = json['gcp-token'];
|
||||
if (data) {
|
||||
setToken(data, state);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const setToken = (data: any, state: StorageState): StorageState => {
|
||||
if (isToken(data)) {
|
||||
state.gcp.token = data;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const isToken = (token: any): token is GcpToken => {
|
||||
return (typeof(token.accessKey) === 'string' &&
|
||||
typeof(token.expiresIn) === 'number');
|
||||
}
|
||||
};
|
||||
|
@ -1,9 +1,10 @@
|
||||
import _ from 'lodash';
|
||||
import BigIntOrderedMap from "@urbit/api/lib/BigIntOrderedMap";
|
||||
import { GraphNode } from '@urbit/api';
|
||||
import BigIntOrderedMap from '@urbit/api/lib/BigIntOrderedMap';
|
||||
import bigInt, { BigInteger } from 'big-integer';
|
||||
import produce from 'immer';
|
||||
import bigInt, { BigInteger } from "big-integer";
|
||||
import useGraphState, { GraphState } from '../state/graph';
|
||||
import _ from 'lodash';
|
||||
import { reduceState } from '../state/base';
|
||||
import useGraphState, { GraphState } from '../state/graph';
|
||||
|
||||
export const GraphReducer = (json) => {
|
||||
const data = _.get(json, 'graph-update', false);
|
||||
@ -36,13 +37,13 @@ const addNodesLoose = (json: any, state: GraphState): GraphState => {
|
||||
_.set(state.looseNodes, [resource], indices);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const keys = (json, state: GraphState): GraphState => {
|
||||
const data = _.get(json, 'keys', false);
|
||||
if (data) {
|
||||
state.graphKeys = new Set(data.map((res) => {
|
||||
let resource = res.ship + '/' + res.name;
|
||||
const resource = res.ship + '/' + res.name;
|
||||
return resource;
|
||||
}));
|
||||
}
|
||||
@ -52,36 +53,32 @@ const keys = (json, state: GraphState): GraphState => {
|
||||
const processNode = (node) => {
|
||||
// is empty
|
||||
if (!node.children) {
|
||||
return produce(node, draft => {
|
||||
return produce<GraphNode>(node, (draft: GraphNode) => {
|
||||
draft.children = new BigIntOrderedMap();
|
||||
});
|
||||
}
|
||||
|
||||
// is graph
|
||||
return produce(node, draft => {
|
||||
draft.children = new BigIntOrderedMap()
|
||||
return produce<GraphNode>(node, (draft: GraphNode) => {
|
||||
draft.children = new BigIntOrderedMap<GraphNode>()
|
||||
.gas(_.map(draft.children, (item, idx) =>
|
||||
[bigInt(idx), processNode(item)] as [BigInteger, any]
|
||||
));
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const addGraph = (json, state: GraphState): GraphState => {
|
||||
|
||||
|
||||
const data = _.get(json, 'add-graph', false);
|
||||
if (data) {
|
||||
if (!('graphs' in state)) {
|
||||
state.graphs = {};
|
||||
}
|
||||
|
||||
let resource = data.resource.ship + '/' + data.resource.name;
|
||||
const resource = data.resource.ship + '/' + data.resource.name;
|
||||
state.graphs[resource] = new BigIntOrderedMap();
|
||||
state.graphTimesentMap[resource] = {};
|
||||
|
||||
|
||||
state.graphs[resource] = state.graphs[resource].gas(Object.keys(data.graph).map(idx => {
|
||||
state.graphs[resource] = state.graphs[resource].gas(Object.keys(data.graph).map((idx) => {
|
||||
return [bigInt(idx), processNode(data.graph[idx])];
|
||||
}));
|
||||
|
||||
@ -93,11 +90,10 @@ const addGraph = (json, state: GraphState): GraphState => {
|
||||
const removeGraph = (json, state: GraphState): GraphState => {
|
||||
const data = _.get(json, 'remove-graph', false);
|
||||
if (data) {
|
||||
|
||||
if (!('graphs' in state)) {
|
||||
state.graphs = {};
|
||||
}
|
||||
let resource = data.ship + '/' + data.name;
|
||||
const resource = data.ship + '/' + data.name;
|
||||
state.graphKeys.delete(resource);
|
||||
delete state.graphs[resource];
|
||||
}
|
||||
@ -121,12 +117,12 @@ const addNodes = (json, state) => {
|
||||
}
|
||||
|
||||
// set parent of graph
|
||||
let parNode = graph.get(index[0]);
|
||||
const parNode = graph.get(index[0]);
|
||||
if (!parNode) {
|
||||
console.error('parent node does not exist, cannot add child');
|
||||
return graph;
|
||||
}
|
||||
return graph.set(index[0], produce(parNode, draft => {
|
||||
return graph.set(index[0], produce(parNode, (draft) => {
|
||||
draft.children = _addNode(draft.children, index.slice(1), node);
|
||||
}));
|
||||
};
|
||||
@ -137,7 +133,7 @@ const addNodes = (json, state) => {
|
||||
} else {
|
||||
const child = graph.get(index[0]);
|
||||
if (child) {
|
||||
return graph.set(index[0], produce(child, draft => {
|
||||
return graph.set(index[0], produce(child, (draft) => {
|
||||
draft.children = _remove(draft.children, index.slice(1));
|
||||
}));
|
||||
}
|
||||
@ -148,10 +144,12 @@ const addNodes = (json, state) => {
|
||||
|
||||
const _killByFuzzyTimestamp = (graph, resource, timestamp) => {
|
||||
if (state.graphTimesentMap[resource][timestamp]) {
|
||||
let index = state.graphTimesentMap[resource][timestamp];
|
||||
const index = state.graphTimesentMap[resource][timestamp];
|
||||
|
||||
if (index.split('/').length === 0) { return graph; }
|
||||
let indexArr = index.split('/').slice(1).map((ind) => {
|
||||
if (index.split('/').length === 0) {
|
||||
return graph;
|
||||
}
|
||||
const indexArr = index.split('/').slice(1).map((ind) => {
|
||||
return bigInt(ind);
|
||||
});
|
||||
|
||||
@ -174,9 +172,11 @@ const addNodes = (json, state) => {
|
||||
|
||||
const data = _.get(json, 'add-nodes', false);
|
||||
if (data) {
|
||||
if (!('graphs' in state)) { return state; }
|
||||
if (!('graphs' in state)) {
|
||||
return state;
|
||||
}
|
||||
|
||||
let resource = data.resource.ship + '/' + data.resource.name;
|
||||
const resource = data.resource.ship + '/' + data.resource.name;
|
||||
if (!(resource in state.graphs)) {
|
||||
state.graphs[resource] = new BigIntOrderedMap();
|
||||
}
|
||||
@ -187,47 +187,46 @@ const addNodes = (json, state) => {
|
||||
|
||||
state.graphKeys.add(resource);
|
||||
|
||||
let indices = Array.from(Object.keys(data.nodes));
|
||||
const indices = Array.from(Object.keys(data.nodes));
|
||||
|
||||
indices.sort((a, b) => {
|
||||
let aArr = a.split('/');
|
||||
let bArr = b.split('/');
|
||||
const aArr = a.split('/');
|
||||
const bArr = b.split('/');
|
||||
return aArr.length - bArr.length;
|
||||
});
|
||||
|
||||
indices.forEach((index) => {
|
||||
let node = data.nodes[index];
|
||||
const node = data.nodes[index];
|
||||
const old = state.graphs[resource].size;
|
||||
state.graphs[resource] = _removePending(state.graphs[resource], node.post, resource);
|
||||
const newSize = state.graphs[resource].size;
|
||||
|
||||
|
||||
if (index.split('/').length === 0) { return; }
|
||||
let indexArr = index.split('/').slice(1).map((ind) => {
|
||||
if (index.split('/').length === 0) {
|
||||
return;
|
||||
}
|
||||
const indexArr = index.split('/').slice(1).map((ind) => {
|
||||
return bigInt(ind);
|
||||
});
|
||||
|
||||
if (indexArr.length === 0) { return state; }
|
||||
if (indexArr.length === 0) {
|
||||
return state;
|
||||
}
|
||||
|
||||
if (node.post.pending) {
|
||||
state.graphTimesentMap[resource][node.post['time-sent']] = index;
|
||||
}
|
||||
|
||||
|
||||
|
||||
state.graphs[resource] = _addNode(
|
||||
state.graphs[resource],
|
||||
indexArr,
|
||||
produce(node, draft => {
|
||||
produce(node, (draft) => {
|
||||
draft.children = mapifyChildren(draft?.children || {});
|
||||
})
|
||||
);
|
||||
if(newSize !== old) {
|
||||
console.log(`${resource}, (${old}, ${newSize}, ${state.graphs[resource].size})`);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
return state;
|
||||
};
|
||||
@ -249,8 +248,8 @@ const removePosts = (json, state: GraphState): GraphState => {
|
||||
} else {
|
||||
const child = graph.get(index[0]);
|
||||
if (child) {
|
||||
return graph.set(index[0], produce(draft => {
|
||||
draft.children = _remove(draft.children, index.slice(1))
|
||||
return graph.set(index[0], produce((draft) => {
|
||||
draft.children = _remove(draft.children, index.slice(1));
|
||||
}));
|
||||
}
|
||||
return graph;
|
||||
@ -262,11 +261,15 @@ const removePosts = (json, state: GraphState): GraphState => {
|
||||
if (data) {
|
||||
const { ship, name } = data.resource;
|
||||
const res = `${ship}/${name}`;
|
||||
if (!(res in state.graphs)) { return state; }
|
||||
if (!(res in state.graphs)) {
|
||||
return state;
|
||||
}
|
||||
|
||||
data.indices.forEach((index) => {
|
||||
if (index.split('/').length === 0) { return; }
|
||||
let indexArr = index.split('/').slice(1).map((ind) => {
|
||||
if (index.split('/').length === 0) {
|
||||
return;
|
||||
}
|
||||
const indexArr = index.split('/').slice(1).map((ind) => {
|
||||
return bigInt(ind);
|
||||
});
|
||||
state.graphs[res] = _remove(state.graphs[res], indexArr);
|
||||
|
@ -1,19 +1,16 @@
|
||||
import { Enc } from '@urbit/api';
|
||||
import {
|
||||
Group,
|
||||
|
||||
GroupPolicy, GroupUpdate,
|
||||
|
||||
InvitePolicy, InvitePolicyDiff, OpenPolicy, OpenPolicyDiff, Tags
|
||||
} from '@urbit/api/groups';
|
||||
import _ from 'lodash';
|
||||
import { Cage } from '~/types/cage';
|
||||
import {
|
||||
GroupUpdate,
|
||||
Group,
|
||||
Tags,
|
||||
GroupPolicy,
|
||||
OpenPolicyDiff,
|
||||
OpenPolicy,
|
||||
InvitePolicyDiff,
|
||||
InvitePolicy
|
||||
} from '@urbit/api/groups';
|
||||
import { Enc } from '@urbit/api';
|
||||
import { resourceAsPath } from '../lib/util';
|
||||
import useGroupState, { GroupState } from '../state/group';
|
||||
import { reduceState } from '../state/base';
|
||||
import useGroupState, { GroupState } from '../state/group';
|
||||
|
||||
function decodeGroup(group: Enc<Group>): Group {
|
||||
const members = new Set(group.members);
|
||||
@ -41,7 +38,7 @@ function decodePolicy(policy: Enc<GroupPolicy>): GroupPolicy {
|
||||
function decodeTags(tags: Enc<Tags>): Tags {
|
||||
return _.reduce(
|
||||
tags,
|
||||
(acc, ships, key): Tags => {
|
||||
(acc, ships: any, key): Tags => {
|
||||
if (key.search(/\\/) === -1) {
|
||||
acc.role[key] = new Set(ships);
|
||||
return acc;
|
||||
@ -69,11 +66,10 @@ export default class GroupReducer {
|
||||
addGroup,
|
||||
removeGroup,
|
||||
changePolicy,
|
||||
expose,
|
||||
expose
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
const initial = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
const data = json['initial'];
|
||||
@ -81,7 +77,7 @@ const initial = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
state.groups = _.mapValues(data, decodeGroup);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const initialGroup = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
if ('initialGroup' in json) {
|
||||
@ -90,7 +86,7 @@ const initialGroup = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
state.groups[path] = decodeGroup(group);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const addGroup = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
if ('addGroup' in json) {
|
||||
@ -104,7 +100,7 @@ const addGroup = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
};
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const removeGroup = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
if('removeGroup' in json) {
|
||||
@ -113,7 +109,7 @@ const removeGroup = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
delete state.groups[resourcePath];
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const addMembers = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
if ('addMembers' in json) {
|
||||
@ -130,7 +126,7 @@ const addMembers = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const removeMembers = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
if ('removeMembers' in json) {
|
||||
@ -141,7 +137,7 @@ const removeMembers = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const addTag = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
if ('addTag' in json) {
|
||||
@ -177,7 +173,7 @@ const removeTag = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
_.set(tags, tagAccessors, tagged);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const changePolicy = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
if ('changePolicy' in json && state) {
|
||||
@ -195,7 +191,7 @@ const changePolicy = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const expose = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
if( 'expose' in json && state) {
|
||||
@ -204,7 +200,7 @@ const expose = (json: GroupUpdate, state: GroupState): GroupState => {
|
||||
state.groups[resourcePath].hidden = false;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const inviteChangePolicy = (diff: InvitePolicyDiff, policy: InvitePolicy) => {
|
||||
if ('addInvites' in diff) {
|
||||
@ -220,7 +216,7 @@ const inviteChangePolicy = (diff: InvitePolicyDiff, policy: InvitePolicy) => {
|
||||
} else {
|
||||
console.log('bad policy change');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const openChangePolicy = (diff: OpenPolicyDiff, policy: OpenPolicy) => {
|
||||
if ('allowRanks' in diff) {
|
||||
@ -246,4 +242,4 @@ const openChangePolicy = (diff: OpenPolicyDiff, policy: OpenPolicy) => {
|
||||
} else {
|
||||
console.log('bad policy change');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { GroupUpdate } from '@urbit/api/groups';
|
||||
import { resourceAsPath } from '~/logic/lib/util';
|
||||
import { reduceState } from '../state/base';
|
||||
import useGroupState, { GroupState } from '../state/group';
|
||||
|
||||
@ -18,7 +17,7 @@ const started = (json: any, state: GroupState): GroupState => {
|
||||
state.pendingJoin[resource] = request;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const progress = (json: any, state: GroupState): GroupState => {
|
||||
const data = json.progress;
|
||||
@ -26,7 +25,6 @@ const progress = (json: any, state: GroupState): GroupState => {
|
||||
const { progress, resource } = data;
|
||||
state.pendingJoin[resource].progress = progress;
|
||||
if(progress === 'done') {
|
||||
|
||||
setTimeout(() => {
|
||||
delete state.pendingJoin[resource];
|
||||
}, 10000);
|
||||
@ -41,8 +39,7 @@ const hide = (json: any, state: GroupState) => {
|
||||
state.pendingJoin[data].hidden = true;
|
||||
}
|
||||
return state;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
export const GroupViewReducer = (json: any) => {
|
||||
const data = json['group-view-update'];
|
||||
|
@ -2,13 +2,13 @@ import {
|
||||
NotifIndex,
|
||||
Timebox
|
||||
} from '@urbit/api';
|
||||
import { makePatDa } from '~/logic/lib/util';
|
||||
import _ from 'lodash';
|
||||
import BigIntOrderedMap from '@urbit/api/lib/BigIntOrderedMap';
|
||||
import useHarkState, { HarkState } from '../state/hark';
|
||||
import { compose } from 'lodash/fp';
|
||||
import { reduceState } from '../state/base';
|
||||
import { BigInteger } from 'big-integer';
|
||||
import _ from 'lodash';
|
||||
import { compose } from 'lodash/fp';
|
||||
import { makePatDa } from '~/logic/lib/util';
|
||||
import { reduceState } from '../state/base';
|
||||
import useHarkState, { HarkState } from '../state/hark';
|
||||
|
||||
export const HarkReducer = (json: any) => {
|
||||
const data = _.get(json, 'harkUpdate', false);
|
||||
@ -22,7 +22,7 @@ export const HarkReducer = (json: any) => {
|
||||
graphIgnore,
|
||||
graphListen,
|
||||
graphWatchSelf,
|
||||
graphMentions,
|
||||
graphMentions
|
||||
]);
|
||||
}
|
||||
const groupHookData = _.get(json, 'hark-group-hook-update', false);
|
||||
@ -30,7 +30,7 @@ export const HarkReducer = (json: any) => {
|
||||
reduceState<HarkState, any>(useHarkState, groupHookData, [
|
||||
groupInitial,
|
||||
groupListen,
|
||||
groupIgnore,
|
||||
groupIgnore
|
||||
]);
|
||||
}
|
||||
};
|
||||
@ -52,9 +52,9 @@ function reduce(data, state) {
|
||||
unreadEach,
|
||||
seenIndex,
|
||||
removeGraph,
|
||||
readAll,
|
||||
readAll
|
||||
];
|
||||
const reducer = compose(reducers.map(r => s => {
|
||||
const reducer = compose(reducers.map(r => (s) => {
|
||||
return r(data, s);
|
||||
}));
|
||||
return reducer(state);
|
||||
@ -63,13 +63,21 @@ function reduce(data, state) {
|
||||
function calculateCount(json: any, state: HarkState) {
|
||||
let count = 0;
|
||||
_.forEach(state.unreads.graph, (graphs) => {
|
||||
_.forEach(graphs, graph => {
|
||||
count += (graph?.notifications || []).length;
|
||||
_.forEach(graphs, (graph) => {
|
||||
if (typeof graph?.notifications === 'object') {
|
||||
count += graph?.notifications.length;
|
||||
} else {
|
||||
count += 0;
|
||||
}
|
||||
});
|
||||
});
|
||||
_.forEach(state.unreads.group, group => {
|
||||
count += (group?.notifications || []).length;
|
||||
})
|
||||
_.forEach(state.unreads.group, (group) => {
|
||||
if (typeof group?.notifications === 'object') {
|
||||
count += group?.notifications.length;
|
||||
} else {
|
||||
count += 0;
|
||||
}
|
||||
});
|
||||
state.notificationsCount = count;
|
||||
return state;
|
||||
}
|
||||
@ -260,7 +268,7 @@ function updateUnreads(state: HarkState, index: NotifIndex, f: (us: Set<string>)
|
||||
if(!('graph' in index)) {
|
||||
return state;
|
||||
}
|
||||
let unreads: any = _.get(state.unreads.graph, [index.graph.graph, index.graph.index, 'unreads'], new Set<string>());
|
||||
const unreads: any = _.get(state.unreads.graph, [index.graph.graph, index.graph.index, 'unreads'], new Set<string>());
|
||||
f(unreads);
|
||||
|
||||
_.set(state.unreads.graph, [index.graph.graph, index.graph.index, 'unreads'], unreads);
|
||||
@ -294,19 +302,18 @@ function removeNotificationFromUnread(state: HarkState, index: NotifIndex, time:
|
||||
const path = [index.graph.graph, index.graph.index, 'notifications'];
|
||||
const curr = _.get(state.unreads.graph, path, []);
|
||||
_.set(state.unreads.graph, path,
|
||||
curr.filter(c => !(c.time.eq(time) && notifIdxEqual(c.index, index))),
|
||||
curr.filter(c => !(c.time.eq(time) && notifIdxEqual(c.index, index)))
|
||||
);
|
||||
} else if ('group' in index) {
|
||||
const path = [index.group.group, 'notifications'];
|
||||
const curr = _.get(state.unreads.group, path, []);
|
||||
_.set(state.unreads.group, path,
|
||||
curr.filter(c => !(c.time.eq(time) && notifIdxEqual(c.index, index))),
|
||||
curr.filter(c => !(c.time.eq(time) && notifIdxEqual(c.index, index)))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function updateNotificationStats(state: HarkState, index: NotifIndex, statField: 'unreads' | 'last', f: (x: number) => number) {
|
||||
|
||||
if('graph' in index) {
|
||||
const curr: any = _.get(state.unreads.graph, [index.graph.graph, index.graph.index, statField], 0);
|
||||
_.set(state.unreads.graph, [index.graph.graph, index.graph.index, statField], f(curr));
|
||||
@ -359,7 +366,7 @@ const timebox = (json: any, state: HarkState): HarkState => {
|
||||
function more(json: any, state: HarkState): HarkState {
|
||||
const data = _.get(json, 'more', false);
|
||||
if (data) {
|
||||
_.forEach(data, d => {
|
||||
_.forEach(data, (d) => {
|
||||
reduce(d, state);
|
||||
});
|
||||
}
|
||||
@ -431,7 +438,7 @@ function archive(json: any, state: HarkState): HarkState {
|
||||
const data = _.get(json, 'archive', false);
|
||||
if (data) {
|
||||
const { index } = data;
|
||||
removeNotificationFromUnread(state, index, makePatDa(data.time))
|
||||
removeNotificationFromUnread(state, index, makePatDa(data.time));
|
||||
const time = makePatDa(data.time);
|
||||
const timebox = state.notifications.get(time);
|
||||
if (!timebox) {
|
||||
|
@ -1,11 +1,8 @@
|
||||
import _ from 'lodash';
|
||||
import { compose } from 'lodash/fp';
|
||||
|
||||
import { InviteUpdate } from '@urbit/api/invite';
|
||||
|
||||
import _ from 'lodash';
|
||||
import { Cage } from '~/types/cage';
|
||||
import useInviteState, { InviteState } from '../state/invite';
|
||||
import { reduceState } from '../state/base';
|
||||
import useInviteState, { InviteState } from '../state/invite';
|
||||
|
||||
export default class InviteReducer {
|
||||
reduce(json: Cage) {
|
||||
@ -17,7 +14,7 @@ export default class InviteReducer {
|
||||
deleteInvite,
|
||||
invite,
|
||||
accepted,
|
||||
decline,
|
||||
decline
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -29,7 +26,7 @@ const initial = (json: InviteUpdate, state: InviteState): InviteState => {
|
||||
state.invites = data;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const create = (json: InviteUpdate, state: InviteState): InviteState => {
|
||||
const data = _.get(json, 'create', false);
|
||||
@ -37,7 +34,7 @@ const create = (json: InviteUpdate, state: InviteState): InviteState => {
|
||||
state.invites[data] = {};
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const deleteInvite = (json: InviteUpdate, state: InviteState): InviteState => {
|
||||
const data = _.get(json, 'delete', false);
|
||||
@ -45,7 +42,7 @@ const deleteInvite = (json: InviteUpdate, state: InviteState): InviteState => {
|
||||
delete state.invites[data];
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const invite = (json: InviteUpdate, state: InviteState): InviteState => {
|
||||
const data = _.get(json, 'invite', false);
|
||||
@ -53,7 +50,7 @@ const invite = (json: InviteUpdate, state: InviteState): InviteState => {
|
||||
state.invites[data.term][data.uid] = data.invite;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const accepted = (json: InviteUpdate, state: InviteState): InviteState => {
|
||||
const data = _.get(json, 'accepted', false);
|
||||
@ -61,7 +58,7 @@ const accepted = (json: InviteUpdate, state: InviteState): InviteState => {
|
||||
delete state.invites[data.term][data.uid];
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const decline = (json: InviteUpdate, state: InviteState): InviteState => {
|
||||
const data = _.get(json, 'decline', false);
|
||||
@ -69,4 +66,4 @@ const decline = (json: InviteUpdate, state: InviteState): InviteState => {
|
||||
delete state.invites[data.term][data.uid];
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
@ -1,9 +1,8 @@
|
||||
import _ from 'lodash';
|
||||
import { LaunchUpdate, WeatherState } from '~/types/launch-update';
|
||||
import { Cage } from '~/types/cage';
|
||||
import useLaunchState, { LaunchState } from '../state/launch';
|
||||
import { compose } from 'lodash/fp';
|
||||
import { LaunchUpdate, WeatherState } from '~/types/launch-update';
|
||||
import { reduceState } from '../state/base';
|
||||
import useLaunchState, { LaunchState } from '../state/launch';
|
||||
|
||||
export default class LaunchReducer {
|
||||
reduce(json: Cage) {
|
||||
@ -14,29 +13,36 @@ export default class LaunchReducer {
|
||||
changeFirstTime,
|
||||
changeOrder,
|
||||
changeFirstTime,
|
||||
changeIsShown,
|
||||
changeIsShown
|
||||
]);
|
||||
}
|
||||
|
||||
const weatherData: WeatherState | boolean | Record<string, never> = _.get(json, 'weather', false);
|
||||
if (weatherData) {
|
||||
useLaunchState.getState().set(state => {
|
||||
useLaunchState.getState().set((state) => {
|
||||
state.weather = weatherData;
|
||||
});
|
||||
}
|
||||
|
||||
const locationData = _.get(json, 'location', false);
|
||||
if (locationData) {
|
||||
useLaunchState.getState().set(state => {
|
||||
useLaunchState.getState().set((state) => {
|
||||
state.userLocation = locationData;
|
||||
});
|
||||
}
|
||||
|
||||
const baseHash = _.get(json, 'baseHash', false);
|
||||
if (baseHash) {
|
||||
useLaunchState.getState().set(state => {
|
||||
useLaunchState.getState().set((state) => {
|
||||
state.baseHash = baseHash;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
const runtimeLag = _.get(json, 'runtimeLag', null);
|
||||
if (runtimeLag !== null) {
|
||||
useLaunchState.getState().set(state => {
|
||||
state.runtimeLag = runtimeLag;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -44,12 +50,12 @@ export default class LaunchReducer {
|
||||
export const initial = (json: LaunchUpdate, state: LaunchState): LaunchState => {
|
||||
const data = _.get(json, 'initial', false);
|
||||
if (data) {
|
||||
Object.keys(data).forEach(key => {
|
||||
Object.keys(data).forEach((key) => {
|
||||
state[key] = data[key];
|
||||
});
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export const changeFirstTime = (json: LaunchUpdate, state: LaunchState): LaunchState => {
|
||||
const data = _.get(json, 'changeFirstTime', false);
|
||||
@ -57,7 +63,7 @@ export const changeFirstTime = (json: LaunchUpdate, state: LaunchState): LaunchS
|
||||
state.firstTime = data;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export const changeOrder = (json: LaunchUpdate, state: LaunchState): LaunchState => {
|
||||
const data = _.get(json, 'changeOrder', false);
|
||||
@ -65,7 +71,7 @@ export const changeOrder = (json: LaunchUpdate, state: LaunchState): LaunchState
|
||||
state.tileOrdering = data;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export const changeIsShown = (json: LaunchUpdate, state: LaunchState): LaunchState => {
|
||||
const data = _.get(json, 'changeIsShown', false);
|
||||
@ -76,4 +82,4 @@ export const changeIsShown = (json: LaunchUpdate, state: LaunchState): LaunchSta
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
@ -1,11 +1,8 @@
|
||||
import _ from 'lodash';
|
||||
import { compose } from 'lodash/fp';
|
||||
|
||||
import { MetadataUpdate } from '@urbit/api/metadata';
|
||||
|
||||
import _ from 'lodash';
|
||||
import { Cage } from '~/types/cage';
|
||||
import useMetadataState, { MetadataState } from '../state/metadata';
|
||||
import { reduceState } from '../state/base';
|
||||
import useMetadataState, { MetadataState } from '../state/metadata';
|
||||
|
||||
export default class MetadataReducer {
|
||||
reduce(json: Cage) {
|
||||
@ -16,7 +13,7 @@ export default class MetadataReducer {
|
||||
add,
|
||||
update,
|
||||
remove,
|
||||
groupInitial,
|
||||
groupInitial
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -28,7 +25,7 @@ const groupInitial = (json: MetadataUpdate, state: MetadataState): MetadataState
|
||||
associations(data, state);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const associations = (json: MetadataUpdate, state: MetadataState): MetadataState => {
|
||||
const data = _.get(json, 'associations', false);
|
||||
@ -50,7 +47,7 @@ const associations = (json: MetadataUpdate, state: MetadataState): MetadataState
|
||||
state.associations = metadata;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const add = (json: MetadataUpdate, state: MetadataState): MetadataState => {
|
||||
const data = _.get(json, 'add', false);
|
||||
@ -70,7 +67,7 @@ const add = (json: MetadataUpdate, state: MetadataState): MetadataState => {
|
||||
state.associations = metadata;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const update = (json: MetadataUpdate, state: MetadataState): MetadataState => {
|
||||
const data = _.get(json, 'update-metadata', false);
|
||||
@ -90,7 +87,7 @@ const update = (json: MetadataUpdate, state: MetadataState): MetadataState => {
|
||||
state.associations = metadata;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const remove = (json: MetadataUpdate, state: MetadataState): MetadataState => {
|
||||
const data = _.get(json, 'remove', false);
|
||||
@ -105,4 +102,4 @@ const remove = (json: MetadataUpdate, state: MetadataState): MetadataState => {
|
||||
state.associations = metadata;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
@ -1,11 +1,9 @@
|
||||
import _ from 'lodash';
|
||||
import { compose } from 'lodash/fp';
|
||||
import { Cage } from '~/types/cage';
|
||||
import { S3Update } from '~/types/s3-update';
|
||||
import { reduceState } from '../state/base';
|
||||
import useStorageState, { StorageState } from '../state/storage';
|
||||
|
||||
|
||||
export default class S3Reducer {
|
||||
reduce(json: Cage) {
|
||||
const data = _.get(json, 's3-update', false);
|
||||
@ -18,7 +16,7 @@ export default class S3Reducer {
|
||||
removeBucket,
|
||||
endpoint,
|
||||
accessKeyId,
|
||||
secretAccessKey,
|
||||
secretAccessKey
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -30,7 +28,7 @@ const credentials = (json: S3Update, state: StorageState): StorageState => {
|
||||
state.s3.credentials = data;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const configuration = (json: S3Update, state: StorageState): StorageState => {
|
||||
const data = _.get(json, 'configuration', false);
|
||||
@ -41,7 +39,7 @@ const configuration = (json: S3Update, state: StorageState): StorageState => {
|
||||
};
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const currentBucket = (json: S3Update, state: StorageState): StorageState => {
|
||||
const data = _.get(json, 'setCurrentBucket', false);
|
||||
@ -49,7 +47,7 @@ const currentBucket = (json: S3Update, state: StorageState): StorageState => {
|
||||
state.s3.configuration.currentBucket = data;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const addBucket = (json: S3Update, state: StorageState): StorageState => {
|
||||
const data = _.get(json, 'addBucket', false);
|
||||
@ -58,7 +56,7 @@ const addBucket = (json: S3Update, state: StorageState): StorageState => {
|
||||
state.s3.configuration.buckets.add(data);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const removeBucket = (json: S3Update, state: StorageState): StorageState => {
|
||||
const data = _.get(json, 'removeBucket', false);
|
||||
@ -66,7 +64,7 @@ const removeBucket = (json: S3Update, state: StorageState): StorageState => {
|
||||
state.s3.configuration.buckets.delete(data);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const endpoint = (json: S3Update, state: StorageState): StorageState => {
|
||||
const data = _.get(json, 'setEndpoint', false);
|
||||
@ -74,7 +72,7 @@ const endpoint = (json: S3Update, state: StorageState): StorageState => {
|
||||
state.s3.credentials.endpoint = data;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const accessKeyId = (json: S3Update , state: StorageState): StorageState => {
|
||||
const data = _.get(json, 'setAccessKeyId', false);
|
||||
@ -82,7 +80,7 @@ const accessKeyId = (json: S3Update , state: StorageState): StorageState => {
|
||||
state.s3.credentials.accessKeyId = data;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const secretAccessKey = (json: S3Update, state: StorageState): StorageState => {
|
||||
const data = _.get(json, 'setSecretAccessKey', false);
|
||||
@ -90,4 +88,4 @@ const secretAccessKey = (json: S3Update, state: StorageState): StorageState => {
|
||||
state.s3.credentials.secretAccessKey = data;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
@ -1,26 +1,25 @@
|
||||
import { SettingsUpdate } from '@urbit/api/settings';
|
||||
import _ from 'lodash';
|
||||
import useSettingsState, { SettingsState } from '~/logic/state/settings';
|
||||
import { SettingsUpdate } from '@urbit/api/settings';
|
||||
import { reduceState } from '../state/base';
|
||||
import { string } from 'prop-types';
|
||||
|
||||
export default class SettingsReducer {
|
||||
reduce(json: any) {
|
||||
let data = json["settings-event"];
|
||||
let data = json['settings-event'];
|
||||
if (data) {
|
||||
reduceState<SettingsState, SettingsUpdate>(useSettingsState, data, [
|
||||
this.putBucket,
|
||||
this.delBucket,
|
||||
this.putEntry,
|
||||
this.delEntry,
|
||||
this.delEntry
|
||||
]);
|
||||
}
|
||||
data = json["settings-data"];
|
||||
data = json['settings-data'];
|
||||
if (data) {
|
||||
reduceState<SettingsState, SettingsUpdate>(useSettingsState, data, [
|
||||
this.getAll,
|
||||
this.getBucket,
|
||||
this.getEntry,
|
||||
this.getEntry
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -28,7 +27,7 @@ export default class SettingsReducer {
|
||||
putBucket(json: SettingsUpdate, state: SettingsState): SettingsState {
|
||||
const data = _.get(json, 'put-bucket', false);
|
||||
if (data) {
|
||||
state[data["bucket-key"]] = data.bucket;
|
||||
state[data['bucket-key']] = data.bucket;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
@ -63,7 +62,7 @@ export default class SettingsReducer {
|
||||
getAll(json: any, state: SettingsState): SettingsState {
|
||||
const data = _.get(json, 'all');
|
||||
if(data) {
|
||||
_.mergeWith(state, data, (obj, src) => _.isArray(src) ? src : undefined)
|
||||
_.mergeWith(state, data, (obj, src) => _.isArray(src) ? src : undefined);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
import produce, { setAutoFreeze } from "immer";
|
||||
import { compose } from "lodash/fp";
|
||||
import create, { State, UseStore } from "zustand";
|
||||
import { persist, devtools } from "zustand/middleware";
|
||||
import produce, { setAutoFreeze } from 'immer';
|
||||
import { compose } from 'lodash/fp';
|
||||
import create, { State, UseStore } from 'zustand';
|
||||
import { persist } from 'zustand/middleware';
|
||||
|
||||
setAutoFreeze(false);
|
||||
|
||||
|
||||
export const stateSetter = <StateType>(
|
||||
fn: (state: StateType) => void,
|
||||
set
|
||||
@ -22,7 +21,7 @@ export const reduceState = <
|
||||
reducers: ((data: UpdateType, state: StateType) => StateType)[]
|
||||
): void => {
|
||||
const reducer = compose(reducers.map(r => sta => r(data, sta)));
|
||||
state.getState().set(state => {
|
||||
state.getState().set((state) => {
|
||||
reducer(state);
|
||||
});
|
||||
};
|
||||
@ -36,25 +35,24 @@ export const stateStorageKey = (stateName: string) => {
|
||||
};
|
||||
|
||||
(window as any).clearStates = () => {
|
||||
stateStorageKeys.forEach(key => {
|
||||
stateStorageKeys.forEach((key) => {
|
||||
localStorage.removeItem(key);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export interface BaseState<StateType> extends State {
|
||||
set: (fn: (state: StateType) => void) => void;
|
||||
}
|
||||
|
||||
export const createState = <StateType extends BaseState<any>>(
|
||||
export const createState = <T extends BaseState<T>>(
|
||||
name: string,
|
||||
properties: Omit<StateType, 'set'>,
|
||||
properties: { [K in keyof Omit<T, 'set'>]: T[K] },
|
||||
blacklist: string[] = []
|
||||
): UseStore<StateType> => create(persist((set, get) => ({
|
||||
// TODO why does this typing break?
|
||||
): UseStore<T> => create(persist((set, get) => ({
|
||||
set: fn => stateSetter(fn, set),
|
||||
...properties
|
||||
...properties as any
|
||||
}), {
|
||||
blacklist,
|
||||
name: stateStorageKey(name),
|
||||
version: process.env.LANDSCAPE_SHORTHASH
|
||||
version: process.env.LANDSCAPE_SHORTHASH as any
|
||||
}));
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { Patp, Rolodex, Scry, Contact } from "@urbit/api";
|
||||
|
||||
import { BaseState, createState } from "./base";
|
||||
import {useCallback} from "react";
|
||||
import { Contact, Patp, Rolodex } from '@urbit/api';
|
||||
import { useCallback } from 'react';
|
||||
import { BaseState, createState } from './base';
|
||||
|
||||
export interface ContactState extends BaseState<ContactState> {
|
||||
contacts: Rolodex;
|
||||
@ -13,7 +12,7 @@ export interface ContactState extends BaseState<ContactState> {
|
||||
const useContactState = createState<ContactState>('Contact', {
|
||||
contacts: {},
|
||||
nackedContacts: new Set(),
|
||||
isContactPublic: false,
|
||||
isContactPublic: false
|
||||
// fetchIsAllowed: async (
|
||||
// entity,
|
||||
// name,
|
||||
@ -36,7 +35,7 @@ export function useContact(ship: string) {
|
||||
}
|
||||
|
||||
export function useOurContact() {
|
||||
return useContact(`~${window.ship}`)
|
||||
return useContact(`~${window.ship}`);
|
||||
}
|
||||
|
||||
export default useContactState;
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { Graphs, decToUd, numToUd, GraphNode, deSig, Association, resourceFromPath } from "@urbit/api";
|
||||
import {useCallback} from "react";
|
||||
|
||||
import { BaseState, createState } from "./base";
|
||||
import { Association, deSig, GraphNode, Graphs, resourceFromPath } from '@urbit/api';
|
||||
import { useCallback } from 'react';
|
||||
import { BaseState, createState } from './base';
|
||||
|
||||
export interface GraphState extends BaseState<GraphState> {
|
||||
graphs: Graphs;
|
||||
@ -22,14 +21,14 @@ export interface GraphState extends BaseState<GraphState> {
|
||||
// getYoungerSiblings: (ship: string, resource: string, count: number, index?: string) => Promise<void>;
|
||||
// getGraphSubset: (ship: string, resource: string, start: string, end: string) => Promise<void>;
|
||||
// getNode: (ship: string, resource: string, index: string) => Promise<void>;
|
||||
};
|
||||
}
|
||||
|
||||
const useGraphState = createState<GraphState>('Graph', {
|
||||
graphs: {},
|
||||
graphKeys: new Set(),
|
||||
looseNodes: {},
|
||||
pendingIndices: {},
|
||||
graphTimesentMap: {},
|
||||
graphTimesentMap: {}
|
||||
// getKeys: async () => {
|
||||
// const api = useApi();
|
||||
// const keys = await api.scry({
|
||||
|
@ -1,18 +1,17 @@
|
||||
import { Path, JoinRequests, Association, Group } from "@urbit/api";
|
||||
|
||||
import { BaseState, createState } from "./base";
|
||||
import {useCallback} from "react";
|
||||
import { Association, Group, JoinRequests } from '@urbit/api';
|
||||
import { useCallback } from 'react';
|
||||
import { BaseState, createState } from './base';
|
||||
|
||||
export interface GroupState extends BaseState<GroupState> {
|
||||
groups: {
|
||||
[group: string]: Group;
|
||||
}
|
||||
pendingJoin: JoinRequests;
|
||||
};
|
||||
}
|
||||
|
||||
const useGroupState = createState<GroupState>('Group', {
|
||||
groups: {},
|
||||
pendingJoin: {},
|
||||
pendingJoin: {}
|
||||
}, ['groups']);
|
||||
|
||||
export function useGroup(group: string) {
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { NotificationGraphConfig, Timebox, Unreads, dateToDa } from "@urbit/api";
|
||||
import BigIntOrderedMap from "@urbit/api/lib/BigIntOrderedMap";
|
||||
|
||||
import { NotificationGraphConfig, Timebox, Unreads } from '@urbit/api';
|
||||
import BigIntOrderedMap from '@urbit/api/lib/BigIntOrderedMap';
|
||||
// import { harkGraphHookReducer, harkGroupHookReducer, harkReducer } from "~/logic/subscription/hark";
|
||||
import { BaseState, createState } from "./base";
|
||||
import { BaseState, createState } from './base';
|
||||
|
||||
export const HARK_FETCH_MORE_COUNT = 3;
|
||||
|
||||
@ -17,7 +16,7 @@ export interface HarkState extends BaseState<HarkState> {
|
||||
notificationsGraphConfig: NotificationGraphConfig; // TODO unthread this everywhere
|
||||
notificationsGroupConfig: string[];
|
||||
unreads: Unreads;
|
||||
};
|
||||
}
|
||||
|
||||
const useHarkState = createState<HarkState>('Hark', {
|
||||
archivedNotifications: new BigIntOrderedMap<Timebox>(),
|
||||
@ -62,8 +61,7 @@ const useHarkState = createState<HarkState>('Hark', {
|
||||
unreads: {
|
||||
graph: {},
|
||||
group: {}
|
||||
},
|
||||
}
|
||||
}, ['notifications', 'archivedNotifications', 'unreads', 'notificationsCount']);
|
||||
|
||||
|
||||
export default useHarkState;
|
||||
|
@ -3,10 +3,10 @@ import { BaseState, createState } from './base';
|
||||
|
||||
export interface InviteState extends BaseState<InviteState> {
|
||||
invites: Invites;
|
||||
};
|
||||
}
|
||||
|
||||
const useInviteState = createState<InviteState>('Invite', {
|
||||
invites: {},
|
||||
invites: {}
|
||||
});
|
||||
|
||||
export default useInviteState;
|
@ -1,7 +1,5 @@
|
||||
import { Tile, WeatherState } from "~/types/launch-update";
|
||||
|
||||
import { BaseState, createState } from "./base";
|
||||
|
||||
import { Tile, WeatherState } from '~/types/launch-update';
|
||||
import { BaseState, createState } from './base';
|
||||
|
||||
export interface LaunchState extends BaseState<LaunchState> {
|
||||
firstTime: boolean;
|
||||
@ -12,6 +10,7 @@ export interface LaunchState extends BaseState<LaunchState> {
|
||||
weather: WeatherState | null | Record<string, never> | boolean,
|
||||
userLocation: string | null;
|
||||
baseHash: string | null;
|
||||
runtimeLag: boolean;
|
||||
};
|
||||
|
||||
const useLaunchState = createState<LaunchState>('Launch', {
|
||||
@ -20,8 +19,8 @@ const useLaunchState = createState<LaunchState>('Launch', {
|
||||
tiles: {},
|
||||
weather: null,
|
||||
userLocation: null,
|
||||
baseHash: null
|
||||
baseHash: null,
|
||||
runtimeLag: false,
|
||||
});
|
||||
|
||||
|
||||
export default useLaunchState;
|
@ -1,13 +1,12 @@
|
||||
import React, { ReactNode } from 'react';
|
||||
import produce from 'immer';
|
||||
import f from 'lodash/fp';
|
||||
import React from 'react';
|
||||
import create, { State } from 'zustand';
|
||||
import { persist } from 'zustand/middleware';
|
||||
import produce from 'immer';
|
||||
import { BackgroundConfig, RemoteContentPolicy, TutorialProgress, tutorialProgress, LeapCategories } from "~/types/local-update";
|
||||
|
||||
import { BackgroundConfig, LeapCategories, RemoteContentPolicy, TutorialProgress, tutorialProgress } from '~/types/local-update';
|
||||
|
||||
export interface LocalState {
|
||||
theme: "light" | "dark" | "auto";
|
||||
theme: 'light' | 'dark' | 'auto';
|
||||
hideAvatars: boolean;
|
||||
hideNicknames: boolean;
|
||||
remoteContentPolicy: RemoteContentPolicy;
|
||||
@ -21,12 +20,13 @@ export interface LocalState {
|
||||
hideLeapCats: LeapCategories[];
|
||||
setTutorialRef: (el: HTMLElement | null) => void;
|
||||
dark: boolean;
|
||||
mobile: boolean;
|
||||
background: BackgroundConfig;
|
||||
omniboxShown: boolean;
|
||||
suspendedFocus?: HTMLElement;
|
||||
toggleOmnibox: () => void;
|
||||
set: (fn: (state: LocalState) => void) => void
|
||||
};
|
||||
}
|
||||
|
||||
type LocalStateZus = LocalState & State;
|
||||
|
||||
@ -35,8 +35,9 @@ export const selectLocalState =
|
||||
|
||||
const useLocalState = create<LocalStateZus>(persist((set, get) => ({
|
||||
dark: false,
|
||||
mobile: false,
|
||||
background: undefined,
|
||||
theme: "auto",
|
||||
theme: 'auto',
|
||||
hideAvatars: false,
|
||||
hideNicknames: false,
|
||||
hideLeapCats: [],
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user