mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 16:51:42 +03:00
Merge 640190610c
into release/next-js
This commit is contained in:
commit
d5bed9f7e4
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:d279b349fb7825ce1dfd79e98a647a397cdd9db9bb7b4f68636b02b33ae5d578
|
oid sha256:24e674adc2bc225cbf522da9ebbb6f1ca0364730392be4e59fbbd65b5028efa5
|
||||||
size 9219596
|
size 9283548
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
/- glob
|
/- glob
|
||||||
/+ default-agent, verb, dbug
|
/+ default-agent, verb, dbug
|
||||||
|%
|
|%
|
||||||
++ hash 0v3.i5rmt.7fid4.sr9bh.0pcpi.cmc0v
|
++ hash 0v7.sjbvb.4gg0l.1qmbv.fmobl.d2tsq
|
||||||
+$ state-0 [%0 hash=@uv glob=(unit (each glob:glob tid=@ta))]
|
+$ state-0 [%0 hash=@uv glob=(unit (each glob:glob tid=@ta))]
|
||||||
+$ all-states
|
+$ all-states
|
||||||
$% state-0
|
$% state-0
|
||||||
|
@ -24,6 +24,6 @@
|
|||||||
<div id="portal-root"></div>
|
<div id="portal-root"></div>
|
||||||
<script src="/~landscape/js/channel.js"></script>
|
<script src="/~landscape/js/channel.js"></script>
|
||||||
<script src="/~landscape/js/session.js"></script>
|
<script src="/~landscape/js/session.js"></script>
|
||||||
<script src="/~landscape/js/bundle/index.5e5637d7960360d37d6e.js"></script>
|
<script src="/~landscape/js/bundle/index.8a99030d28740234ac24.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -237,6 +237,12 @@ export default class GraphApi extends BaseApi<StoreState> {
|
|||||||
action['add-nodes'].resource.ship =
|
action['add-nodes'].resource.ship =
|
||||||
action['add-nodes'].resource.ship.slice(1);
|
action['add-nodes'].resource.ship.slice(1);
|
||||||
|
|
||||||
|
this.store.handleEvent({ data: {
|
||||||
|
'graph-update': action
|
||||||
|
} });
|
||||||
|
|
||||||
|
return pendingPromise;
|
||||||
|
/* TODO: stop lying to our users about pending states
|
||||||
return pendingPromise.then((pendingHashes) => {
|
return pendingPromise.then((pendingHashes) => {
|
||||||
for (let index in action['add-nodes'].nodes) {
|
for (let index in action['add-nodes'].nodes) {
|
||||||
action['add-nodes'].nodes[index].post.hash =
|
action['add-nodes'].nodes[index].post.hash =
|
||||||
@ -250,6 +256,7 @@ export default class GraphApi extends BaseApi<StoreState> {
|
|||||||
}
|
}
|
||||||
} });
|
} });
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
removeNodes(ship: Patp, name: string, indices: string[]) {
|
removeNodes(ship: Patp, name: string, indices: string[]) {
|
||||||
|
@ -11,8 +11,6 @@ export const GraphReducer = (json, state) => {
|
|||||||
removeGraph(data, state);
|
removeGraph(data, state);
|
||||||
addNodes(data, state);
|
addNodes(data, state);
|
||||||
removeNodes(data, state);
|
removeNodes(data, state);
|
||||||
|
|
||||||
pendingIndices(data, state);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -58,6 +56,8 @@ const addGraph = (json, state) => {
|
|||||||
|
|
||||||
let resource = data.resource.ship + '/' + data.resource.name;
|
let resource = data.resource.ship + '/' + data.resource.name;
|
||||||
state.graphs[resource] = new BigIntOrderedMap();
|
state.graphs[resource] = new BigIntOrderedMap();
|
||||||
|
state.graphTimesentMap[resource] = {};
|
||||||
|
|
||||||
|
|
||||||
for (let idx in data.graph) {
|
for (let idx in data.graph) {
|
||||||
let item = data.graph[idx];
|
let item = data.graph[idx];
|
||||||
@ -97,15 +97,6 @@ const mapifyChildren = (children) => {
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
const pendingIndices = (json, state) => {
|
|
||||||
const data = _.get(json, 'pending-indices', false);
|
|
||||||
if (data) {
|
|
||||||
Object.keys(data).forEach((key) => {
|
|
||||||
state.pendingIndices[data[key]] = key;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const addNodes = (json, state) => {
|
const addNodes = (json, state) => {
|
||||||
const _addNode = (graph, index, node, resource) => {
|
const _addNode = (graph, index, node, resource) => {
|
||||||
// set child of graph
|
// set child of graph
|
||||||
@ -139,9 +130,9 @@ const addNodes = (json, state) => {
|
|||||||
return graph;
|
return graph;
|
||||||
};
|
};
|
||||||
|
|
||||||
const _removePending = (graph, post) => {
|
const _killByFuzzyTimestamp = (graph, resource, timestamp) => {
|
||||||
if (post.hash && state.pendingIndices[post.hash]) {
|
if (state.graphTimesentMap[resource][timestamp]) {
|
||||||
let index = state.pendingIndices[post.hash];
|
let index = state.graphTimesentMap[resource][timestamp];
|
||||||
|
|
||||||
if (index.split('/').length === 0) { return; }
|
if (index.split('/').length === 0) { return; }
|
||||||
let indexArr = index.split('/').slice(1).map((ind) => {
|
let indexArr = index.split('/').slice(1).map((ind) => {
|
||||||
@ -149,12 +140,24 @@ const addNodes = (json, state) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
graph = _remove(graph, indexArr);
|
graph = _remove(graph, indexArr);
|
||||||
delete state.pendingIndices[post.hash];
|
delete state.graphTimesentMap[resource][timestamp];
|
||||||
}
|
}
|
||||||
|
|
||||||
return graph;
|
return graph;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const _removePending = (graph, post, resource) => {
|
||||||
|
if (!post.hash) {
|
||||||
|
return graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
graph = _killByFuzzyTimestamp(graph, resource, post['time-sent']);
|
||||||
|
graph = _killByFuzzyTimestamp(graph, resource, post['time-sent'] - 1);
|
||||||
|
graph = _killByFuzzyTimestamp(graph, resource, post['time-sent'] + 1);
|
||||||
|
|
||||||
|
return graph;
|
||||||
|
};
|
||||||
|
|
||||||
const data = _.get(json, 'add-nodes', false);
|
const data = _.get(json, 'add-nodes', false);
|
||||||
if (data) {
|
if (data) {
|
||||||
if (!('graphs' in state)) { return; }
|
if (!('graphs' in state)) { return; }
|
||||||
@ -163,6 +166,11 @@ const addNodes = (json, state) => {
|
|||||||
if (!(resource in state.graphs)) {
|
if (!(resource in state.graphs)) {
|
||||||
state.graphs[resource] = new BigIntOrderedMap();
|
state.graphs[resource] = new BigIntOrderedMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(resource in state.graphTimesentMap)) {
|
||||||
|
state.graphTimesentMap[resource] = {};
|
||||||
|
}
|
||||||
|
|
||||||
state.graphKeys.add(resource);
|
state.graphKeys.add(resource);
|
||||||
|
|
||||||
let indices = Array.from(Object.keys(data.nodes));
|
let indices = Array.from(Object.keys(data.nodes));
|
||||||
@ -177,22 +185,27 @@ const addNodes = (json, state) => {
|
|||||||
|
|
||||||
indices.forEach((index) => {
|
indices.forEach((index) => {
|
||||||
let node = data.nodes[index];
|
let node = data.nodes[index];
|
||||||
graph = _removePending(graph, node.post);
|
graph = _removePending(graph, node.post, resource);
|
||||||
|
|
||||||
if (index.split('/').length === 0) { return; }
|
if (index.split('/').length === 0) { return; }
|
||||||
index = index.split('/').slice(1).map((ind) => {
|
let indexArr = index.split('/').slice(1).map((ind) => {
|
||||||
return bigInt(ind);
|
return bigInt(ind);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (index.length === 0) { return; }
|
if (indexArr.length === 0) { return; }
|
||||||
|
|
||||||
|
if (node.post.pending) {
|
||||||
|
state.graphTimesentMap[resource][node.post['time-sent']] = index;
|
||||||
|
}
|
||||||
|
|
||||||
node.children = mapifyChildren(node?.children || {});
|
node.children = mapifyChildren(node?.children || {});
|
||||||
|
|
||||||
graph = _addNode(
|
graph = _addNode(
|
||||||
graph,
|
graph,
|
||||||
index,
|
indexArr,
|
||||||
node
|
node
|
||||||
);
|
);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
state.graphs[resource] = graph;
|
state.graphs[resource] = graph;
|
||||||
|
@ -100,7 +100,7 @@ export default class GlobalStore extends BaseStore<StoreState> {
|
|||||||
notificationsCount: 0,
|
notificationsCount: 0,
|
||||||
settings: {},
|
settings: {},
|
||||||
pendingJoin: {},
|
pendingJoin: {},
|
||||||
pendingIndices: {}
|
graphTimesentMap: {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ export function ChatResource(props: ChatResourceProps) {
|
|||||||
const groupPath = props.association.group;
|
const groupPath = props.association.group;
|
||||||
const group = props.groups[groupPath];
|
const group = props.groups[groupPath];
|
||||||
const contacts = props.contacts;
|
const contacts = props.contacts;
|
||||||
|
const graphPath = station.slice(7);
|
||||||
const graph = props.graphs[station.slice(7)];
|
const graph = props.graphs[station.slice(7)];
|
||||||
const isChatMissing = !props.graphKeys.has(station.slice(7));
|
const isChatMissing = !props.graphKeys.has(station.slice(7));
|
||||||
const unreadCount = props.unreads.graph?.[station]?.['/']?.unreads || 0;
|
const unreadCount = props.unreads.graph?.[station]?.['/']?.unreads || 0;
|
||||||
@ -159,7 +160,7 @@ export function ChatResource(props: ChatResourceProps) {
|
|||||||
association={props.association}
|
association={props.association}
|
||||||
associations={props.associations}
|
associations={props.associations}
|
||||||
groups={props.groups}
|
groups={props.groups}
|
||||||
pendingSize={Object.keys(props.pendingIndices || {}).length}
|
pendingSize={Object.keys(props.graphTimesentMap[graphPath] || {}).length}
|
||||||
group={group}
|
group={group}
|
||||||
ship={owner}
|
ship={owner}
|
||||||
station={station}
|
station={station}
|
||||||
|
@ -33,7 +33,7 @@ export function LinkResource(props: LinkResourceProps) {
|
|||||||
associations,
|
associations,
|
||||||
graphKeys,
|
graphKeys,
|
||||||
unreads,
|
unreads,
|
||||||
pendingIndices,
|
graphTimesentMap,
|
||||||
storage,
|
storage,
|
||||||
history
|
history
|
||||||
} = props;
|
} = props;
|
||||||
@ -79,7 +79,7 @@ export function LinkResource(props: LinkResourceProps) {
|
|||||||
baseUrl={resourceUrl}
|
baseUrl={resourceUrl}
|
||||||
group={group}
|
group={group}
|
||||||
path={resource.group}
|
path={resource.group}
|
||||||
pendingSize={Object.keys(props.pendingIndices || {}).length}
|
pendingSize={Object.keys(graphTimesentMap[resourcePath] || {}).length}
|
||||||
api={api}
|
api={api}
|
||||||
mb={3}
|
mb={3}
|
||||||
/>
|
/>
|
||||||
|
@ -93,7 +93,14 @@ export const LinkItem = (props: LinkItemProps): ReactElement => {
|
|||||||
const isUnread = props.unreads.graph?.[appPath]?.['/']?.unreads?.has(node.post.index);
|
const isUnread = props.unreads.graph?.[appPath]?.['/']?.unreads?.has(node.post.index);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box mx="auto" px={3} maxWidth="768px" ref={ref} width="100%" {...rest}>
|
<Box
|
||||||
|
mx="auto"
|
||||||
|
px={3}
|
||||||
|
maxWidth="768px"
|
||||||
|
ref={ref}
|
||||||
|
width="100%"
|
||||||
|
opacity={node.post.pending ? '0.5' : '1'}
|
||||||
|
{...rest}>
|
||||||
<Box
|
<Box
|
||||||
lineHeight="tall"
|
lineHeight="tall"
|
||||||
display='flex'
|
display='flex'
|
||||||
@ -155,7 +162,9 @@ export const LinkItem = (props: LinkItemProps): ReactElement => {
|
|||||||
></Author>
|
></Author>
|
||||||
|
|
||||||
<Box ml="auto">
|
<Box ml="auto">
|
||||||
<Link to={`${baseUrl}/${index}`}>
|
<Link
|
||||||
|
to={node.post.pending ? '#' : `${baseUrl}/${index}`}
|
||||||
|
style={{ cursor: node.post.pending ? 'default' : 'pointer' }}>
|
||||||
<Box display='flex'>
|
<Box display='flex'>
|
||||||
<Icon color={commColor} icon='Chat' />
|
<Icon color={commColor} icon='Chat' />
|
||||||
<Text color={commColor} ml={1}>{node.children.size}</Text>
|
<Text color={commColor} ml={1}>{node.children.size}</Text>
|
||||||
|
Loading…
Reference in New Issue
Block a user