mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 16:51:42 +03:00
Merge 344e40fda7
into release/next-js
This commit is contained in:
commit
49706ebf13
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c512d0c3da3ce7f0ac25babcbbceba04a9e62975e9d92aec56ab00e1c2fc6224
|
||||
size 8618963
|
||||
oid sha256:9f504eec4f36c7f6074b9988cfd4bfac2bb88617a84d7172c5061e6711b3bbda
|
||||
size 8682363
|
||||
|
@ -5,7 +5,7 @@
|
||||
/- glob
|
||||
/+ default-agent, verb, dbug
|
||||
|%
|
||||
++ hash 0v5.sekq0.8skge.ekt62.i73ig.g5sep
|
||||
++ hash 0v1.4u9gp.rs1fi.ki7ok.ib4cp.mgdvs
|
||||
+$ state-0 [%0 hash=@uv glob=(unit (each glob:glob tid=@ta))]
|
||||
+$ all-states
|
||||
$% state-0
|
||||
|
@ -9,11 +9,17 @@
|
||||
+$ card card:agent:gall
|
||||
+$ versioned-state
|
||||
$% state-0
|
||||
state-1
|
||||
==
|
||||
::
|
||||
+$ state-0
|
||||
$: %0
|
||||
watching=(set [resource index:post])
|
||||
[%0 base-state-0]
|
||||
::
|
||||
+$ state-1
|
||||
[%1 base-state-0]
|
||||
::
|
||||
+$ base-state-0
|
||||
$: watching=(set [resource index:post])
|
||||
mentions=_&
|
||||
watch-on-self=_&
|
||||
==
|
||||
@ -36,7 +42,7 @@
|
||||
::
|
||||
--
|
||||
::
|
||||
=| state-0
|
||||
=| state-1
|
||||
=* state -
|
||||
::
|
||||
=<
|
||||
@ -57,13 +63,25 @@
|
||||
::
|
||||
++ on-save !>(state)
|
||||
++ on-load
|
||||
|= old=vase
|
||||
|= =vase
|
||||
^- (quip card _this)
|
||||
:_ this(state !<(state-0 old))
|
||||
=+ !<(old=versioned-state vase)
|
||||
=| cards=(list card)
|
||||
|-
|
||||
?: ?=(%0 -.old)
|
||||
%_ $
|
||||
-.old %1
|
||||
::
|
||||
cards
|
||||
:_ cards
|
||||
[%pass / %agent [our dap]:bowl %poke noun+!>(%rewatch-dms)]
|
||||
==
|
||||
:_ this(state old)
|
||||
=. cards (flop cards)
|
||||
%+ welp
|
||||
?: (~(has by wex.bowl) [/graph our.bowl %graph-store])
|
||||
~
|
||||
~[watch-graph:ha]
|
||||
cards
|
||||
[watch-graph:ha cards]
|
||||
%+ turn
|
||||
^- (list mark)
|
||||
:~ %graph-validator-chat
|
||||
@ -103,9 +121,23 @@
|
||||
?+ mark (on-poke:def mark vase)
|
||||
%hark-graph-hook-action
|
||||
(hark-graph-hook-action !<(action:hook vase))
|
||||
%noun
|
||||
(poke-noun !<(* vase))
|
||||
==
|
||||
[cards this]
|
||||
::
|
||||
++ 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 ~] ~)))
|
||||
==
|
||||
::
|
||||
++ hark-graph-hook-action
|
||||
|= =action:hook
|
||||
^- (quip card _state)
|
||||
@ -223,23 +255,14 @@
|
||||
++ add-graph
|
||||
|= rid=resource
|
||||
^- (quip card _state)
|
||||
=/ group-rid=(unit resource)
|
||||
(group-from-app-resource:met %graph rid)
|
||||
?~ group-rid
|
||||
~& no-group+rid
|
||||
`state
|
||||
=/ is-hidden=?
|
||||
!(is-managed:grp u.group-rid)
|
||||
=/ should-watch
|
||||
|(is-hidden &(watch-on-self =(our.bowl entity.rid)))
|
||||
?. should-watch
|
||||
`state
|
||||
=/ graph=graph:graph-store :: graph in subscription is bunted
|
||||
(get-graph-mop:gra rid)
|
||||
=/ node=(unit node:graph-store)
|
||||
(bind (peek:orm:graph-store graph) |=([@ =node:graph-store] node))
|
||||
=^ cards state
|
||||
(check-nodes (drop node) rid)
|
||||
?. (should-watch:ha rid)
|
||||
[cards state]
|
||||
:_ state(watching (~(put in watching) [rid ~]))
|
||||
(weld cards (give:ha ~[/updates] %listen [rid ~]))
|
||||
::
|
||||
@ -277,6 +300,9 @@
|
||||
--
|
||||
::
|
||||
|_ =bowl:gall
|
||||
+* met ~(. metadata bowl)
|
||||
grp ~(. grouplib bowl)
|
||||
gra ~(. graph bowl)
|
||||
::
|
||||
++ get-conversion
|
||||
|= rid=resource
|
||||
@ -314,6 +340,16 @@
|
||||
%.y
|
||||
$(contents t.contents)
|
||||
::
|
||||
++ should-watch
|
||||
|= rid=resource
|
||||
^- ?
|
||||
=/ group-rid=(unit resource)
|
||||
(group-from-app-resource:met %graph rid)
|
||||
?~ group-rid %.n
|
||||
?| !(is-managed:grp u.group-rid)
|
||||
&(watch-on-self =(our.bowl entity.rid))
|
||||
==
|
||||
::
|
||||
++ handle-update
|
||||
|_ $: rid=resource :: input
|
||||
updates=(list node:graph-store)
|
||||
|
@ -49,7 +49,7 @@
|
||||
:: $cache: useful to have precalculated, but can be derived from state
|
||||
:: albeit expensively
|
||||
+$ cache
|
||||
$: by-index=(jug stats-index:store @da)
|
||||
$: by-index=(jug stats-index:store [time=@da =index:store])
|
||||
~
|
||||
==
|
||||
::
|
||||
@ -228,6 +228,7 @@
|
||||
[%count count]
|
||||
(~(gut by last-seen) stats-index *time)
|
||||
==
|
||||
::
|
||||
++ give-each-unreads
|
||||
^- (list [stats-index:store stats:store])
|
||||
%+ turn
|
||||
@ -477,19 +478,16 @@
|
||||
::
|
||||
++ read-index-each
|
||||
|= [=stats-index:store ref=index:graph-store]
|
||||
%+ read-index stats-index
|
||||
%- read-indices
|
||||
%+ skim
|
||||
~(tap ^in (~(get ju by-index) stats-index))
|
||||
|= time=@da
|
||||
|= [time=@da =index:store]
|
||||
=/ =timebox:store
|
||||
(gut-orm notifications time)
|
||||
%+ roll
|
||||
~(tap ^in timebox)
|
||||
|= [[=index:store not=notification:store] out=?]
|
||||
?: out out
|
||||
?. (stats-index-is-index:store stats-index index) out
|
||||
?. ?=(%graph -.index) out
|
||||
?. ?=(%graph -.contents.not) out
|
||||
=/ not=notification:store
|
||||
(~(got by timebox) index)
|
||||
?. ?=(%graph -.index) %.n
|
||||
?. ?=(%graph -.contents.not) %.n
|
||||
(lien list.contents.not |=(p=post:post =(index.p ref)))
|
||||
::
|
||||
++ read-each
|
||||
@ -517,35 +515,18 @@
|
||||
++ read-count
|
||||
|= =stats-index:store
|
||||
=. unreads-count (~(put by unreads-count) stats-index 0)
|
||||
=/ times=(list @da)
|
||||
=/ times=(list [@da index:store])
|
||||
~(tap ^in (~(get ju by-index) stats-index))
|
||||
(give:(read-index stats-index times) %read-count stats-index)
|
||||
(give:(read-indices times) %read-count stats-index)
|
||||
::
|
||||
++ read-index
|
||||
|= [=stats-index:store times=(list @da)]
|
||||
++ read-indices
|
||||
|= times=(list [time=@da =index:store])
|
||||
|-
|
||||
?~ times poke-core
|
||||
=/ core
|
||||
(read-stats-index i.times stats-index)
|
||||
(read-note i.times)
|
||||
$(poke-core core, times t.times)
|
||||
::
|
||||
++ read-stats-index
|
||||
|= [time=@da =stats-index:store]
|
||||
=/ keys
|
||||
~(tap ^in ~(key by (gut-orm notifications time)))
|
||||
|- ^+ poke-core
|
||||
?~ keys
|
||||
poke-core
|
||||
?. (stats-index-is-index:store stats-index i.keys)
|
||||
$(keys t.keys)
|
||||
=/ =notification:store
|
||||
(~(got by (gut-orm notifications time)) i.keys)
|
||||
?: read.notification
|
||||
$(keys t.keys)
|
||||
=/ core
|
||||
(read-note time i.keys)
|
||||
$(poke-core core, keys t.keys)
|
||||
::
|
||||
++ seen-index
|
||||
|= [time=@da =stats-index:store]
|
||||
=/ new-time=@da
|
||||
@ -570,7 +551,7 @@
|
||||
=. last-seen
|
||||
((dif-map-by-key ,@da) last-seen indices)
|
||||
=. by-index
|
||||
((dif-map-by-key ,(set @da)) by-index indices)
|
||||
((dif-map-by-key ,(set [@da =index:store])) by-index indices)
|
||||
poke-core
|
||||
::
|
||||
++ get-stats-indices
|
||||
@ -603,10 +584,10 @@
|
||||
~(tap ^in set)
|
||||
|-
|
||||
?~ indices poke-core
|
||||
=/ times=(list @da)
|
||||
=/ times=(list [time=@da =index:store])
|
||||
~(tap ^in (~(get ju by-index) i.indices))
|
||||
=. poke-core
|
||||
(read-index i.indices times)
|
||||
(read-indices times)
|
||||
$(indices t.indices)
|
||||
--
|
||||
::
|
||||
@ -694,7 +675,7 @@
|
||||
%_ +.state
|
||||
::
|
||||
by-index
|
||||
%. [(to-stats-index:store index) time]
|
||||
%. [(to-stats-index:store index) time index]
|
||||
?: read
|
||||
~(del ju by-index)
|
||||
~(put ju by-index)
|
||||
|
@ -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.6056641fbc32a19ee0fd.js"></script>
|
||||
<script src="/~landscape/js/bundle/index.86c6e416c338a305e1e9.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -63,7 +63,7 @@ class Channel {
|
||||
}
|
||||
|
||||
resetDebounceTimer() {
|
||||
if(this.debounceTimer) {
|
||||
if (this.debounceTimer) {
|
||||
clearTimeout(this.debounceTimer);
|
||||
this.debounceTimer = null;
|
||||
}
|
||||
@ -182,19 +182,19 @@ class Channel {
|
||||
// sends a JSON command command to the server.
|
||||
//
|
||||
sendJSONToChannel(j) {
|
||||
if(!j && this.outstandingJSON.length === 0) {
|
||||
return;
|
||||
}
|
||||
let req = new XMLHttpRequest();
|
||||
req.open("PUT", this.channelURL());
|
||||
req.setRequestHeader("Content-Type", "application/json");
|
||||
|
||||
if (this.lastEventId == this.lastAcknowledgedEventId) {
|
||||
if(j) {
|
||||
if (j) {
|
||||
this.outstandingJSON.push(j);
|
||||
}
|
||||
let x = JSON.stringify(this.outstandingJSON);
|
||||
req.send(x);
|
||||
|
||||
if (this.outstandingJSON.length > 0) {
|
||||
let x = JSON.stringify(this.outstandingJSON);
|
||||
req.send(x);
|
||||
}
|
||||
} else {
|
||||
// we add an acknowledgment to clear the server side queue
|
||||
//
|
||||
@ -203,15 +203,15 @@ class Channel {
|
||||
//
|
||||
let payload = [
|
||||
...this.outstandingJSON,
|
||||
{action: "ack", "event-id": parseInt(this.lastEventId)}
|
||||
{action: "ack", "event-id": this.lastEventId}
|
||||
];
|
||||
if(j) {
|
||||
if (j) {
|
||||
payload.push(j)
|
||||
}
|
||||
let x = JSON.stringify(payload);
|
||||
req.send(x);
|
||||
|
||||
this.lastEventId = this.lastAcknowledgedEventId;
|
||||
this.lastAcknowledgedEventId = this.lastEventId;
|
||||
}
|
||||
this.outstandingJSON = [];
|
||||
|
||||
@ -227,7 +227,7 @@ class Channel {
|
||||
|
||||
this.eventSource = new EventSource(this.channelURL(), {withCredentials:true});
|
||||
this.eventSource.onmessage = e => {
|
||||
this.lastEventId = e.lastEventId;
|
||||
this.lastEventId = parseInt(e.lastEventId, 10);
|
||||
|
||||
let obj = JSON.parse(e.data);
|
||||
let pokeFuncs = this.outstandingPokes.get(obj.id);
|
||||
|
Loading…
Reference in New Issue
Block a user