mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-09 17:45:02 +09:00
refactoring: remove graph fake subscription for MenuDataviewContext
This commit is contained in:
parent
c774b985e5
commit
351944e1bb
5 changed files with 21 additions and 38 deletions
|
@ -83,7 +83,6 @@ export default {
|
|||
store: 'store',
|
||||
archive: 'archive',
|
||||
sidebar: 'sidebar',
|
||||
graph: 'graph',
|
||||
space: 'space',
|
||||
files: 'files',
|
||||
participant: 'participant',
|
||||
|
|
|
@ -126,21 +126,11 @@ const ViewGraph = observer(class ViewGraph extends React.Component<I.ViewCompone
|
|||
};
|
||||
|
||||
this.data.nodes = message.nodes.map(it => S.Detail.mapper(it));
|
||||
|
||||
U.Data.onSubscribe(J.Constant.subId.graph, 'id', J.Relation.graph, {
|
||||
error: {},
|
||||
records: message.nodes,
|
||||
dependencies: [],
|
||||
counters: { total: message.nodes.length },
|
||||
});
|
||||
|
||||
this.resize();
|
||||
this.forceUpdate();
|
||||
|
||||
if (this.refGraph) {
|
||||
this.refGraph.init();
|
||||
};
|
||||
|
||||
this.forceUpdate();
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -80,7 +80,8 @@ class MenuContext extends React.Component<I.Menu> {
|
|||
getSections () {
|
||||
const { param } = this.props;
|
||||
const { data } = param;
|
||||
const { subId, objectIds, getObject, isCollection } = data;
|
||||
const { subId, getObject, isCollection } = data;
|
||||
const objectIds = this.getObjectIds();
|
||||
const length = objectIds.length;
|
||||
const canWrite = U.Space.canMyParticipantWrite();
|
||||
const exportObject = { id: 'export', icon: 'export', name: translate('menuObjectExport') };
|
||||
|
@ -110,13 +111,7 @@ class MenuContext extends React.Component<I.Menu> {
|
|||
let allowedRelation = true;
|
||||
|
||||
objectIds.forEach((it: string) => {
|
||||
let object = null;
|
||||
if (getObject) {
|
||||
object = getObject(it);
|
||||
} else
|
||||
if (subId) {
|
||||
object = S.Detail.get(subId, it);
|
||||
};
|
||||
const object = this.getObject(subId, getObject, it);
|
||||
|
||||
if (!object || object._empty_) {
|
||||
return;
|
||||
|
@ -201,6 +196,14 @@ class MenuContext extends React.Component<I.Menu> {
|
|||
|
||||
return sections;
|
||||
};
|
||||
|
||||
getObjectIds () {
|
||||
return this.props.param.data.objectIds || [];
|
||||
};
|
||||
|
||||
getObject (subId: string, getObject: (id: string) => any, id: string) {
|
||||
return getObject ? getObject(id) : S.Detail.get(subId, id);
|
||||
};
|
||||
|
||||
getItems () {
|
||||
const sections = this.getSections();
|
||||
|
@ -220,7 +223,8 @@ class MenuContext extends React.Component<I.Menu> {
|
|||
onOver (e: any, item: any) {
|
||||
const { param, getId, getSize, close } = this.props;
|
||||
const { data, className, classNameWrap } = param;
|
||||
const { objectIds, onLinkTo, route } = data;
|
||||
const { onLinkTo, route } = data;
|
||||
const objectIds = this.getObjectIds();
|
||||
|
||||
if (!keyboard.isMouseDisabled) {
|
||||
this.props.setActive(item, false);
|
||||
|
@ -341,10 +345,11 @@ class MenuContext extends React.Component<I.Menu> {
|
|||
|
||||
const { param, close } = this.props;
|
||||
const { data } = param;
|
||||
const { subId, objectIds, onSelect, targetId, isCollection, route, relationKeys, view, blockId } = data;
|
||||
const { subId, getObject, onSelect, targetId, isCollection, route, relationKeys, view, blockId } = data;
|
||||
const objectIds = this.getObjectIds();
|
||||
const win = $(window);
|
||||
const count = objectIds.length;
|
||||
const first = count == 1 ? S.Detail.get(subId, objectIds[0], []) : null;
|
||||
const length = objectIds.length;
|
||||
const first = length == 1 ? this.getObject(subId, getObject, objectIds[0]) : null;
|
||||
const cb = () => {
|
||||
if (onSelect) {
|
||||
onSelect(item.id);
|
||||
|
@ -370,7 +375,7 @@ class MenuContext extends React.Component<I.Menu> {
|
|||
U.Object.openConfig({ id: message.ids[0], layout: first.layout });
|
||||
};
|
||||
|
||||
analytics.event('DuplicateObject', { count, route });
|
||||
analytics.event('DuplicateObject', { count: length, route });
|
||||
|
||||
if (isCollection) {
|
||||
C.ObjectCollectionAdd(targetId, message.ids, () => {
|
||||
|
@ -409,7 +414,7 @@ class MenuContext extends React.Component<I.Menu> {
|
|||
case 'unlink': {
|
||||
C.ObjectCollectionRemove(targetId, objectIds, () => {
|
||||
cb();
|
||||
analytics.event('UnlinkFromCollection', { count, route });
|
||||
analytics.event('UnlinkFromCollection', { count: length, route });
|
||||
});
|
||||
break;
|
||||
};
|
||||
|
|
|
@ -139,21 +139,11 @@ const PageMainGraph = observer(class PageMainGraph extends React.Component<I.Pag
|
|||
};
|
||||
|
||||
this.data.nodes = message.nodes.map(it => S.Detail.mapper(it));
|
||||
|
||||
U.Data.onSubscribe(J.Constant.subId.graph, 'id', J.Relation.graph, {
|
||||
error: {},
|
||||
records: message.nodes,
|
||||
dependencies: [],
|
||||
counters: { total: message.nodes.length },
|
||||
});
|
||||
|
||||
this.resize();
|
||||
this.forceUpdate();
|
||||
|
||||
if (this.refGraph) {
|
||||
this.refGraph.init();
|
||||
};
|
||||
|
||||
this.forceUpdate();
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -400,7 +400,6 @@ const Graph = observer(class Graph extends React.Component<Props> {
|
|||
...param,
|
||||
data: {
|
||||
route: analytics.route.graph,
|
||||
subId: J.Constant.subId.graph,
|
||||
objectIds: ids,
|
||||
getObject: id => this.getNode(id),
|
||||
allowedLink: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue