8000 Feature/JS-6951: Subscription manager by ra3orblade · Pull Request #1375 · anyproto/anytype-ts · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Feature/JS-6951: Subscription manager #1375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ts/component/block/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,11 @@ const BlockChat = observer(class BlockChat extends React.Component<I.BlockCompon
return;
};

U.Data.subscribeIds({
U.Subscription.subscribeIds({
subId: this.getSubId(),
ids,
noDeps: true,
keys: U.Data.chatRelationKeys(),
keys: U.Subscription.chatRelationKeys(),
updateDetails: true,
}, () => {
this.forceUpdate();
Expand Down
2 changes: 1 addition & 1 deletion src/ts/component/block/dataview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ const BlockDataview = observer(class BlockDataview extends React.Component<Props
this.filter = v;

if (v) {
U.Data.search({
U.Subscription.search({
filters: [],
sorts: [],
fullText: v,
Expand Down
2 changes: 1 addition & 1 deletion src/ts/component/block/dataview/view/board/column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const Column = observer(class Column extends React.Component<Props> {
S.Record.recordsClear(subId, '');
};

U.Data.searchSubscribe({
U.Subscription.subscribe({
subId,
filters: filters.map(it => Dataview.filterMapper(view, it)),
sorts: sorts.map(it => Dataview.filterMapper(view, it)),
Expand Down
2 changes: 1 addition & 1 deletion src/ts/component/block/dataview/view/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const ViewCalendar = observer(class ViewCalendar extends React.Component<I.ViewC
filters.push({ relationKey: 'id', condition: I.FilterCondition.In, value: searchIds || [] });
};

U.Data.searchSubscribe({
U.Subscription.subscribe({
subId,
filters: filters.map(it => Dataview.filterMapper(view, it)),
sorts: sorts.map(it => Dataview.filterMapper(view, it)),
Expand Down
4 changes: 2 additions & 2 deletions src/ts/component/block/featured.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ const BlockFeatured = observer(class BlockFeatured extends React.Component<Props
return null;
};

const object = S.Detail.get(rootId, storeId, U.Data.participantRelationKeys());
const object = S.Detail.get(rootId, storeId, U.Subscription.participantRelationKeys());
const relationKey = object.globalName ? 'globalName': 'identity';

return (
Expand Down Expand Up @@ -462,7 +462,7 @@ const BlockFeatured = observer(class BlockFeatured extends React.Component<Props
{ relationKey: 'recommendedLayout', condition: I.FilterCondition.In, value: U.Object.getPageLayouts() },
{ relationKey: 'uniqueKey', condition: I.FilterCondition.NotIn, value: [ J.Constant.typeKey.template, J.Constant.typeKey.type ] }
],
keys: U.Data.typeRelationKeys(),
keys: U.Subscription.typeRelationKeys(),
skipIds: [ object.type ],
onClick: (item: any) => {
keyboard.disableClose(true);
Expand Down
6 changes: 3 additions & 3 deletions src/ts/component/list/object.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const ListObject = observer(forwardRef<ListObjectRefProps, Props>(({

S.Record.metaSet(subId, '', { offset });

U.Data.searchSubscribe({
U.Subscription.subscribe({
spaceId,
subId,
sorts: [ { relationKey: sortId, type: sortType } ],
Expand Down Expand Up @@ -226,8 +226,8 @@ const ListObject = observer(forwardRef<ListObjectRefProps, Props>(({
setSortId(columnList[0].relationKey);

return () => {
C.ObjectSearchUnsubscribe([ subId ]);
}
U.Subscription.destroyList([ subId ]);
};
}, []);

useEffect(() => getData(1), [ sortId, sortType ]);
Expand Down
2 changes: 1 addition & 1 deletion src/ts/component/list/objectManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const ListManager = observer(forwardRef<ListManagerRefProps, Props>(({

setIsLoading(true);

U.Data.searchSubscribe({
U.Subscription.subscribe({
subId,
sorts,
filters: fl,
Expand Down
2 changes: 1 addition & 1 deletion src/ts/component/menu/block/cover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ const MenuBlockCover = observer(class MenuBlockCover extends React.Component<I.M

this.setState({ isLoading: true });

U.Data.search({
U.Subscription.search({
filters,
sorts,
fullText: filter,
Expand Down
2 changes: 1 addition & 1 deletion src/ts/component/menu/block/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ const MenuBlockLink = observer(class MenuBlockLink extends React.Component<I.Men
return;
};

U.Data.search({
U.Subscription.search({
filters,
sorts,
fullText: filter,
Expand Down
2 changes: 1 addition & 1 deletion src/ts/component/menu/block/mention.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ const MenuBlockMention = observer(class MenuBlockMention extends React.Component
this.setState({ isLoading: true });
};

U.Data.search({
U.Subscription.search({
filters,
sorts,
fullText: filter,
Expand Down
2 changes: 1 addition & 1 deletion src/ts/component/menu/dataview/file/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ const MenuDataviewFileList = observer(class MenuDataviewFileList extends React.C
this.setState({ isLoading: true });
};

U.Data.search({
U.Subscription.search({
filters,
sorts,
fullText: filter,
Expand Down
2 changes: 1 addition & 1 deletion src/ts/component/menu/dataview/object/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ const MenuDataviewObjectList = observer(class MenuDataviewObjectList extends Rea
filters.push({ relationKey: 'id', condition: I.FilterCondition.In, value });
};

U.Data.search({
U.Subscription.search({
filters,
sorts,
fullText: filter,
Expand Down
4 changes: 2 additions & 2 deletions src/ts/component/menu/dataview/template/list.tsx
3D11
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const MenuTemplateList = observer(class MenuTemplateList extends React.Component
};

componentWillUnmount () {
C.ObjectSearchUnsubscribe([ this.getSubId() ]);
U.Subscription.destroyList([ this.getSubId() ]);
this.unbind();
};

Expand Down Expand Up @@ -171,7 +171,7 @@ const MenuTemplateList = observer(class MenuTemplateList extends React.Component
];
const keys = J.Relation.default.concat([ 'targetObjectType' ]);

U.Data.searchSubscribe({
U.Subscription.subscribe({
subId: this.getSubId(),
filters,
sorts,
Expand Down
2 changes: 1 addition & 1 deletion src/ts/component/menu/participant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const MenuParticipant = observer(forwardRef<I.MenuRef, I.Menu>((props: I.Menu, r
const { object } = data;

const load = () => {
U.Object.getById(object.id, { keys: U.Data.participantRelationKeys() }, (object: any) => {
U.Object.getById(object.id, { keys: U.Subscription.participantRelationKeys() }, (object: any) => {
if (object) {
props.param.data.object = object;
};
Expand Down
2 changes: 1 addition & 1 deletion src/ts/component/menu/relation/suggest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ const MenuRelationSuggest = observer(class MenuRelationSuggest extends React.Com
};

loadRequest (param: any, callBack?: (message: any) => void) {
U.Data.search(param, (message: any) => {
U.Subscription.search(param, (message: any) => {
this.items = this.items.concat(message.records || []);

if (callBack) {
Expand Down
2 changes: 1 addition & 1 deletion src/ts/component/menu/search/object.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ const MenuSearchObject = observer(class MenuSearchObject extends React.Component
this.setState({ isLoading: true });
};

U.Data.search({
U.Subscription.search({
spaceId,
filters,
sorts,
Expand Down
2 changes: 1 addition & 1 deletion src/ts/component/menu/smile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ const MenuSmile = observer(class MenuSmile extends React.Component<I.Menu, State

this.setLoading(true);

U.Data.search({
U.Subscription.search({
filters,
sorts,
fullText: filter,
Expand Down
6 changes: 3 additions & 3 deletions src/ts/component/menu/syncStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ const MenuSyncStatus = observer(class MenuSyncStatus extends React.Component<I.M
this._isMounted = false;
this.onCloseInfo();

C.ObjectSearchUnsubscribe([ SUB_ID ]);
U.Subscription.destroyList([ SUB_ID ]);
};

onContextMenu (e, item) {
Expand Down Expand Up @@ -272,11 +272,11 @@ const MenuSyncStatus = observer(class MenuSyncStatus extends React.Component<I.M

this.setState({ isLoading: true });

U.Data.searchSubscribe({
U.Subscription.subscribe({
subId: SUB_ID,
filters,
sorts,
keys: U.Data.syncStatusRelationKeys(),
keys: U.Subscription.syncStatusRelationKeys(),
offset: 0,
limit: 30,
}, () => {
Expand Down
4 changes: 2 additions & 2 deletions src/ts/component/menu/type/suggest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ const MenuTypeSuggest = observer(forwardRef<I.MenuRef, I.Menu>((props, ref) => {
itemList.current = [];
};

U.Data.search({
U.Subscription.search({
filters,
sorts,
keys: U.Data.typeRelationKeys(),
keys: U.Subscription.typeRelationKeys(),
fullText: filter,
offset: offset.current,
limit: J.Constant.limit.menuRecords,
Expand Down
2 changes: 1 addition & 1 deletion src/ts/component/page/elements/head/simple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ const HeadSimple = observer(class HeadSimple extends React.Component<Props> {
const isType = U.Object.isTypeLayout(object.layout);

if (isType) {
U.Data.searchSubscribe({
U.Subscription.subscribe({
subId: SUB_ID_CHECK,
filters: [
{ relationKey: 'type', condition: I.FilterCondition.Equal, value: object.id },
Expand Down
2 changes: 1 addition & 1 deletion src/ts/component/page/main/date.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const PageMainDate = observer(forwardRef<{}, I.PageComponent>((props, ref: any)
return;
};

U.Data.search({
U.Subscription.search({
filters: getFilters(start, end),
keys: [ relationKey ],
}, (message: any) => {
Expand Down
2 changes: 1 addition & 1 deletion src/ts/component/page/main/settings/data/publish.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const PageMainSettingsDataPublish = observer(class PageMainSettingsDataPublish e
};

componentWillUnmount(): void {
C.ObjectSearchUnsubscribe([ SUB_ID ]);
U.Subscription.destroyList([ SUB_ID ]);
};

load () {
Expand Down
4 changes: 2 additions & 2 deletions src/ts/component/popup/invite/confirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ const PopupInviteConfirm = observer(forwardRef<{}, I.Popup>((props, ref) => {
const load = () => {
setIsLoading(true);

U.Data.search({
U.Subscription.search({
spaceId,
keys: U.Data.participantRelationKeys(),
keys: U.Subscription.participantRelationKeys(),
filters: [
{ relationKey: 'resolvedLayout', condition: I.FilterCondition.Equal, value: I.ObjectLayout.Participant },
],
Expand Down
6 changes: 3 additions & 3 deletions src/ts/component/popup/relation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const PopupRelation = observer(class PopupRelation extends React.Component<I.Pop

componentWillUnmount(): void {
S.Menu.closeAll(J.Menu.cell);
C.ObjectSearchUnsubscribe([ SUB_ID_OBJECT, SUB_ID_DEPS ]);
U.Subscription.destroyList([ SUB_ID_OBJECT, SUB_ID_DEPS ]);
};

loadObjects (callBack?: () => void) {
Expand All @@ -133,7 +133,7 @@ const PopupRelation = observer(class PopupRelation extends React.Component<I.Pop
const objectIds = this.getObjectIds();
const keys = this.getRelationKeys();

U.Data.searchSubscribe({
U.Subscription.subscribe({
subId: SUB_ID_OBJECT,
filters: [
{ relationKey: 'id', condition: I.FilterCondition.In, value: objectIds },
Expand Down Expand Up @@ -191,7 +191,7 @@ const PopupRelation = observer(class PopupRelation extends React.Component<I.Pop
return;
};

U.Data.searchSubscribe({
U.Subscription.subscribe({
subId: SUB_ID_DEPS,
filters: [
{ relationKey: 'id', condition: I.FilterCondition.In, value: depIds },
Expand Down
6 changes: 3 additions & 3 deletions src/ts/component/popup/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ const PopupSearch = observer(class PopupSearch extends React.Component<I.Popup,
this._isMounted = false;
this.unbind();

C.ObjectSearchUnsubscribe([ J.Constant.subId.search ]);
U.Subscription.destroyList([ J.Constant.subId.search ]);
window.clearTimeout(this.timeout);
};

Expand Down Expand Up @@ -587,7 +587,7 @@ const PopupSearch = observer(class PopupSearch extends React.Component<I.Popup,
{ relationKey: 'lastOpenedDate', type: I.SortType.Desc },
{ relationKey: 'lastModifiedDate', type: I.SortType.Desc },
{ relationKey: 'type', type: I.SortType.Asc },
].map(U.Data.sortMapper);
].map(U.Subscription.sortMapper);

let limit = J.Constant.limit.menuRecords;

Expand Down Expand Up @@ -623,7 +623,7 @@ const PopupSearch = observer(class PopupSearch extends React.Component<I.Popup,
this.items = this.items.concat(records);

if (this.items.length) {
U.Data.subscribeIds({
U.Subscription.subscribeIds({
subId: J.Constant.subId.search,
ids: this.items.map(it => it.id),
noDeps: true,
Expand Down
4 changes: 2 additions & 2 deletions src/ts/component/sidebar/page/allObject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ const SidebarPageObject = observer(class SidebarPageObject extends React.Compone
S.Record.recordsSet(J.Constant.subId.allObject, '', []);
};

U.Data.searchSubscribe({
U.Subscription.subscribe({
subId: J.Constant.subId.allObject,
filters,
sorts,
Expand All @@ -403,7 +403,7 @@ const SidebarPageObject = observer(class SidebarPageObject extends React.Compone

loadSearchIds (clear: boolean) {
if (this.filter) {
U.Data.search({
U.Subscription.search({
filters: [],
sorts: [],
fullText: this.filter,
Expand Down
6 changes: 3 additions & 3 deletions src/ts/component/sidebar/page/settings/library.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ const SidebarSettingsLibrary = observer(class SidebarSettingsLibrary extends Rea
};

componentWillUnmount () {
C.ObjectSearchUnsubscribe([ J.Constant.subId.library ]);
U.Subscription.destroyList([ J.Constant.subId.library ]);
};

initSort () {
Expand Down Expand Up @@ -256,7 +256,7 @@ const SidebarSettingsLibrary = observer(class SidebarSettingsLibrary extends Rea
S.Record.recordsSet(J.Constant.subId.library, '', []);
};

U.Data.searchSubscribe({
U.Subscription.subscribe({
subId: J.Constant.subId.library,
filters,
sorts,
Expand All @@ -275,7 +275,7 @@ const SidebarSettingsLibrary = observer(class SidebarSettingsLibrary extends Rea

loadSearchIds (clear: boolean) {
if (this.filter) {
U.Data.search({
U.Subscription.search({
filters: [],
sorts: [],
fullText: this.filter,
Expand Down
2 changes: 1 addition & 1 deletion src/ts/component/widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ const WidgetIndex = observer(forwardRef<{}, Props>((props, ref) => {
};
};

U.Data.searchSubscribe({
U.Subscription.subscribe({
subId: subId.current,
filters,
sorts,
Expand Down
8 changes: 5 additions & 3 deletions src/ts/component/widget/tree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const WidgetTree = observer(forwardRef<WidgetTreeRefProps, I.WidgetComponent>((p
const subIds = getSubIds();

if (subIds.length) {
C.ObjectSearchUnsubscribe(subIds);
U.Subscription.destroyList(subIds);
clear();
};
};
Expand Down Expand Up @@ -179,7 +179,7 @@ const WidgetTree = observer(forwardRef<WidgetTreeRefProps, I.WidgetComponent>((p
};

subscriptionHashes.current[nodeId] = hash;
U.Data.subscribeIds({
U.Subscription.subscribeIds({
subId,
ids: links,
keys: J.Relation.sidebar,
Expand Down Expand Up @@ -380,8 +380,10 @@ const WidgetTree = observer(forwardRef<WidgetTreeRefProps, I.WidgetComponent>((p
};

return () => {
/*
unsubscribe();
//Action.pageClose([ targetId, traceId ].join('-'), false);
Action.pageClose([ targetId, traceId ].join('-'), false);
*/
};
}, []);

Expand Down
Loading
0