Merge 640190610c into release/next-js

This commit is contained in:
janeway-bot 2021-03-10 02:47:19 +04:00 committed by GitHub
commit d5bed9f7e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 61 additions and 31 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d279b349fb7825ce1dfd79e98a647a397cdd9db9bb7b4f68636b02b33ae5d578
size 9219596
oid sha256:24e674adc2bc225cbf522da9ebbb6f1ca0364730392be4e59fbbd65b5028efa5
size 9283548

View File

@ -5,7 +5,7 @@
/- glob
/+ 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))]
+$ all-states
$% state-0

View File

@ -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.5e5637d7960360d37d6e.js"></script>
<script src="/~landscape/js/bundle/index.8a99030d28740234ac24.js"></script>
</body>
</html>

View File

@ -237,6 +237,12 @@ export default class GraphApi extends BaseApi<StoreState> {
action['add-nodes'].resource.ship =
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) => {
for (let index in action['add-nodes'].nodes) {
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[]) {

View File

@ -11,8 +11,6 @@ export const GraphReducer = (json, state) => {
removeGraph(data, state);
addNodes(data, state);
removeNodes(data, state);
pendingIndices(data, state);
}
};
@ -58,6 +56,8 @@ const addGraph = (json, state) => {
let resource = data.resource.ship + '/' + data.resource.name;
state.graphs[resource] = new BigIntOrderedMap();
state.graphTimesentMap[resource] = {};
for (let idx in data.graph) {
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 _addNode = (graph, index, node, resource) => {
// set child of graph
@ -139,9 +130,9 @@ const addNodes = (json, state) => {
return graph;
};
const _removePending = (graph, post) => {
if (post.hash && state.pendingIndices[post.hash]) {
let index = state.pendingIndices[post.hash];
const _killByFuzzyTimestamp = (graph, resource, timestamp) => {
if (state.graphTimesentMap[resource][timestamp]) {
let index = state.graphTimesentMap[resource][timestamp];
if (index.split('/').length === 0) { return; }
let indexArr = index.split('/').slice(1).map((ind) => {
@ -149,12 +140,24 @@ const addNodes = (json, state) => {
});
graph = _remove(graph, indexArr);
delete state.pendingIndices[post.hash];
delete state.graphTimesentMap[resource][timestamp];
}
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);
if (data) {
if (!('graphs' in state)) { return; }
@ -163,6 +166,11 @@ const addNodes = (json, state) => {
if (!(resource in state.graphs)) {
state.graphs[resource] = new BigIntOrderedMap();
}
if (!(resource in state.graphTimesentMap)) {
state.graphTimesentMap[resource] = {};
}
state.graphKeys.add(resource);
let indices = Array.from(Object.keys(data.nodes));
@ -177,22 +185,27 @@ const addNodes = (json, state) => {
indices.forEach((index) => {
let node = data.nodes[index];
graph = _removePending(graph, node.post);
graph = _removePending(graph, node.post, resource);
if (index.split('/').length === 0) { return; }
index = index.split('/').slice(1).map((ind) => {
let indexArr = index.split('/').slice(1).map((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 || {});
graph = _addNode(
graph,
index,
indexArr,
node
);
});
state.graphs[resource] = graph;

View File

@ -100,7 +100,7 @@ export default class GlobalStore extends BaseStore<StoreState> {
notificationsCount: 0,
settings: {},
pendingJoin: {},
pendingIndices: {}
graphTimesentMap: {}
};
}

View File

@ -28,6 +28,7 @@ export function ChatResource(props: ChatResourceProps) {
const groupPath = props.association.group;
const group = props.groups[groupPath];
const contacts = props.contacts;
const graphPath = station.slice(7);
const graph = props.graphs[station.slice(7)];
const isChatMissing = !props.graphKeys.has(station.slice(7));
const unreadCount = props.unreads.graph?.[station]?.['/']?.unreads || 0;
@ -159,7 +160,7 @@ export function ChatResource(props: ChatResourceProps) {
association={props.association}
associations={props.associations}
groups={props.groups}
pendingSize={Object.keys(props.pendingIndices || {}).length}
pendingSize={Object.keys(props.graphTimesentMap[graphPath] || {}).length}
group={group}
ship={owner}
station={station}

View File

@ -33,7 +33,7 @@ export function LinkResource(props: LinkResourceProps) {
associations,
graphKeys,
unreads,
pendingIndices,
graphTimesentMap,
storage,
history
} = props;
@ -79,7 +79,7 @@ export function LinkResource(props: LinkResourceProps) {
baseUrl={resourceUrl}
group={group}
path={resource.group}
pendingSize={Object.keys(props.pendingIndices || {}).length}
pendingSize={Object.keys(graphTimesentMap[resourcePath] || {}).length}
api={api}
mb={3}
/>

View File

@ -93,7 +93,14 @@ export const LinkItem = (props: LinkItemProps): ReactElement => {
const isUnread = props.unreads.graph?.[appPath]?.['/']?.unreads?.has(node.post.index);
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
lineHeight="tall"
display='flex'
@ -155,7 +162,9 @@ export const LinkItem = (props: LinkItemProps): ReactElement => {
></Author>
<Box ml="auto">
<Link to={`${baseUrl}/${index}`}>
<Link
to={node.post.pending ? '#' : `${baseUrl}/${index}`}
style={{ cursor: node.post.pending ? 'default' : 'pointer' }}>
<Box display='flex'>
<Icon color={commColor} icon='Chat' />
<Text color={commColor} ml={1}>{node.children.size}</Text>