diff --git a/electron/js/preload.js b/electron/js/preload.js index 6fdf22d998..65694204d7 100644 --- a/electron/js/preload.js +++ b/electron/js/preload.js @@ -24,7 +24,7 @@ contextBridge.exposeInMainWorld('Electron', { dirName: fp => path.dirname(fp), fileName: fp => path.basename(fp), fileMime: fp => mime.lookup(fp), - fileExt: fp => path.extname(fp), + fileExt: fp => path.extname(fp).replace(/^./, ''), fileSize: fp => fs.statSync(fp).size, isDirectory: fp => fs.lstatSync(fp).isDirectory(), defaultPath: () => path.join(app.getPath('appData'), app.getName()), diff --git a/src/img/icon/widget/button/chat.svg b/src/img/icon/widget/button/chat.svg new file mode 100644 index 0000000000..743c7b5162 --- /dev/null +++ b/src/img/icon/widget/button/chat.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/img/theme/dark/icon/widget/button/chat.svg b/src/img/theme/dark/icon/widget/button/chat.svg new file mode 100644 index 0000000000..edec41900f --- /dev/null +++ b/src/img/theme/dark/icon/widget/button/chat.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/json/constant.ts b/src/json/constant.ts index de42980878..157428572b 100644 --- a/src/json/constant.ts +++ b/src/json/constant.ts @@ -93,7 +93,9 @@ export default { profile: 'profile', deleted: 'deleted', type: 'type', + typeStore: 'typeStore', relation: 'relation', + relationStore: 'relationStore', option: 'option', store: 'store', archive: 'archive', @@ -101,7 +103,7 @@ export default { space: 'space', fileManager: 'fileManager', participant: 'participant', - myParticipant: 'myParticipant', + subSpace: 'subSpace', allObject: 'allObject', }, diff --git a/src/json/relation.ts b/src/json/relation.ts index f2f3f7b50e..5e0164e181 100644 --- a/src/json/relation.ts +++ b/src/json/relation.ts @@ -137,10 +137,10 @@ export default { 'spaceAccessType', 'readersLimit', 'writersLimit', - 'sharedSpacesLimit', 'targetSpaceId', 'creator', - 'createdDate' + 'createdDate', + 'spaceMainChatId' ], participant: [ diff --git a/src/json/text.json b/src/json/text.json index e7bbf68c39..f02847d64d 100644 --- a/src/json/text.json +++ b/src/json/text.json @@ -168,6 +168,7 @@ "commonNothingFound": "Nothing found", "commonEntrySpace": "My First Space", "commonSystem": "System", + "commonMainChat": "Main сhat", "commonMenu": "Menu", "pluralDay": "day|days", diff --git a/src/scss/block/text.scss b/src/scss/block/text.scss index da0a620c81..098cf7bc11 100644 --- a/src/scss/block/text.scss +++ b/src/scss/block/text.scss @@ -110,6 +110,14 @@ .block.blockText.textDescription > .wrapMenu:hover > .icon.dnd { opacity: 1; } + .block.blockText.textHeader1, + .block.blockText.textHeader2, + .block.blockText.textHeader3 { + markupmention { + .space { width: 6px; } + } + } + /* Header1 */ .block.blockText.textHeader1 { padding: 22px 0px 0px 0px; } diff --git a/src/scss/popup/preview.scss b/src/scss/popup/preview.scss index 7fc81dd5a5..cc281548fd 100644 --- a/src/scss/popup/preview.scss +++ b/src/scss/popup/preview.scss @@ -10,17 +10,34 @@ $gallerySlidesH: calc(100vh - $galleryHeaderH - $galleryFooterH); } .popup.popupPreview { - .innerWrap { border-radius: 6px; background: none; } + .innerWrap { border-radius: 6px; background: none; width: 100%; height: 100%; margin: 0px !important; left: 0px; top: 0px; } .innerWrap.anim { transition: $transitionAllCommon; } #loader { background: var(--color-bg-primary); width: 100%; height: 100%; border-radius: 6px; } - .wrap { width: 100vw; height: 100vh; overflow: hidden; } + .wrap { display: flex; flex-direction: column; overflow: hidden; } .wrap { - .galleryHeader { position: relative; height: $galleryHeaderH; } + .galleryHeader { + position: relative; -webkit-app-region: no-drag; display: flex; align-items: center; justify-content: space-between; width: 100%; color: var(--color-text-secondary); + text-shadow: 0px 0px 5px rgba(0,0,0,0.7); padding: 16px; z-index: 1; height: $galleryHeaderH; + } + .galleryHeader { + .side.center { text-align: center; max-width: calc(100% - 80px); height: 100%; display: flex; align-items: center; } + .name { @include text-overflow-nw; line-height: 18px; } - .gallerySlides { position: relative; height: $gallerySlidesH; } + .side.right { text-align: right; display: flex; gap: 0px 16px; align-items: center; } + .side.right { + .icon { width: 20px; height: 20px; opacity: 0.75; } + .icon:hover, .icon.hover { opacity: 1; } + .icon.expand { background-image: url('~img/icon/expand.svg'); }; + .icon.more { background-image: url('~img/icon/popup/preview/more.svg'); } + } + } + + .gallerySlides { position: relative; flex-grow: 1; } .gallerySlides { + .swiper-wrapper { align-items: center; } .swiper-slide { height: $gallerySlidesH; } + .previewItem { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; } .mediaContainer { position: relative; z-index: 2; } @@ -31,7 +48,7 @@ $gallerySlidesH: calc(100vh - $galleryHeaderH - $galleryFooterH); .swiper-button-disabled { display: none; } } - .galleryFooter { position: relative; height: $galleryFooterH; } + .galleryFooter { position: relative; height: $galleryFooterH; flex-shrink: 0; } .galleryFooter { .thumbnails { position: relative; height: 100%; display: flex; align-items: center; justify-content: center; } .swiper { z-index: 2; } @@ -61,22 +78,7 @@ $gallerySlidesH: calc(100vh - $galleryHeaderH - $galleryFooterH); .innerDimmer { position: absolute; z-index: 0; width: 100%; height: 100%; } } - .head { - display: flex; align-items: center; position: absolute; left: 0px; top: 0px; height: 52px; justify-content: space-between; - width: 100%; color: var(--color-text-inversion); text-shadow: 0px 0px 5px rgba(0,0,0,0.7); padding: 0px 16px; z-index: 1; - } - .head { - .side.center { text-align: center; max-width: calc(100% - 80px); height: 100%; display: flex; align-items: center; } - .name { @include text-overflow-nw; line-height: 18px; } - - .side.right { text-align: right; display: flex; gap: 0px 16px; align-items: center; } - .side.right { - .icon { width: 20px; height: 20px; opacity: 0.75; } - .icon:hover, .icon.hover { opacity: 1; } - .icon.expand { background-image: url('~img/icon/expand.svg'); }; - .icon.more { background-image: url('~img/icon/popup/preview/more.svg'); } - } - } + .media { width: 100%; height: 100%; object-fit: contain; margin: 0px auto; } } } diff --git a/src/scss/theme/dark/widget.scss b/src/scss/theme/dark/widget.scss index de069c0566..6a0b319102 100644 --- a/src/scss/theme/dark/widget.scss +++ b/src/scss/theme/dark/widget.scss @@ -68,8 +68,7 @@ .item { .icon.member { background-image: url('#{$themePath}/icon/widget/button/member.svg'); } .icon.all { background-image: url('#{$themePath}/icon/widget/button/all.svg'); } - .icon.bin { background-image: url('#{$themePath}/icon/widget/button/bin.svg'); } - .icon.store { background-image: url('#{$themePath}/icon/widget/button/store.svg'); } + .icon.chat { background-image: url('#{$themePath}/icon/widget/button/chat.svg'); } .side.right { .icon.more:hover, .icon.more.hover { background-image: url('#{$themePath}/icon/menu/action/more1.svg'); opacity: 1; } diff --git a/src/scss/widget/buttons.scss b/src/scss/widget/buttons.scss index 4e5692b1fb..e16299777f 100644 --- a/src/scss/widget/buttons.scss +++ b/src/scss/widget/buttons.scss @@ -28,6 +28,7 @@ .icon { width: 20px; height: 20px; flex-shrink: 0; } .icon.member { background-image: url('~img/icon/widget/button/member.svg'); } .icon.all { background-image: url('~img/icon/widget/button/all.svg'); } + .icon.chat { background-image: url('~img/icon/widget/button/chat.svg'); } .cnt { color: var(--color-text-secondary); } } diff --git a/src/ts/component/block/chat/attachment/index.tsx b/src/ts/component/block/chat/attachment/index.tsx index 45da8f3a1c..fcebd61e3e 100644 --- a/src/ts/component/block/chat/attachment/index.tsx +++ b/src/ts/component/block/chat/attachment/index.tsx @@ -177,7 +177,7 @@ const ChatAttachment = observer(class ChatAttachment extends React.Component { - Action.openFileDialog([], paths => { + Action.openFileDialog({ properties: [ 'multiSelections' ] }, paths => { if (paths.length) { - addAttachments([ getObjectFromPath(paths[0]) ]); + addAttachments(paths.map(path => getObjectFromPath(path))); }; }); }; diff --git a/src/ts/component/block/chat/message/index.tsx b/src/ts/component/block/chat/message/index.tsx index e5df1164eb..11b7da2f72 100644 --- a/src/ts/component/block/chat/message/index.tsx +++ b/src/ts/component/block/chat/message/index.tsx @@ -38,14 +38,13 @@ const ChatMessage = observer(class ChatMessage extends React.Component { }; render () { - const { rootId, blockId, id, isThread, isNew, readonly, onThread, onContextMenu, onMore, onReply, getReplyContent } = this.props; + const { rootId, id, isThread, isNew, readonly, onThread, onContextMenu, onMore, onReply, getReplyContent } = this.props; const { space } = S.Common; const { account } = S.Auth; const message = S.Chat.getMessage(rootId, id); const { creator, content, createdAt, modifiedAt, reactions, isFirst, isLast, replyToMessageId } = message; - const subId = S.Record.getSubId(rootId, blockId); const author = U.Space.getParticipant(U.Space.getParticipantId(space, creator)); - const attachments = (message.attachments || []).map(it => S.Detail.get(subId, it.target)).filter(it => !it.isDeleted); + const attachments = this.getAttachments(); const hasReactions = reactions.length; const hasAttachments = attachments.length; const isSelf = creator == account.id; @@ -315,25 +314,23 @@ const ChatMessage = observer(class ChatMessage extends React.Component { }; onAttachmentRemove (attachmentId: string) { - const { rootId, id } = this.props; - const message = S.Chat.getMessage(rootId, id); - const attachments = (message.attachments || []).filter(it => it.target != attachmentId); - - this.update({ attachments }); + this.update({ attachments: this.getAttachments().filter(it => it.target != attachmentId) }); }; onPreview (preview: any) { - const data: any = preview; + const data: any = { ...preview }; + const gallery = []; - let gallery = []; - - Object.keys(this.attachmentRefs).forEach((key) => { + Object.keys(this.attachmentRefs).forEach(key => { const ref = this.attachmentRefs[key]; - gallery.push(ref?.getPreviewItem()); + if (ref) { + const item = ref.getPreviewItem(); + if (item) { + gallery.push(item); + }; + }; }); - gallery = gallery.filter(it => it); - data.gallery = gallery; data.initialIdx = gallery.findIndex(it => it.src == preview.src); @@ -347,11 +344,16 @@ const ChatMessage = observer(class ChatMessage extends React.Component { C.ChatEditMessageContent(rootId, id, message); }; - getAttachmentsClass (): string { + getAttachments (): any[] { const { rootId, blockId, id } = this.props; const subId = S.Record.getSubId(rootId, blockId); const message = S.Chat.getMessage(rootId, id); - const attachments = (message.attachments || []).map(it => S.Detail.get(subId, it.target)); + + return (message.attachments || []).map(it => S.Detail.get(subId, it.target)).filter(it => !it._empty_ && !it.isDeleted); + }; + + getAttachmentsClass (): string { + const attachments = this.getAttachments(); const mediaLayouts = [ I.ObjectLayout.Image, I.ObjectLayout.Video ]; const media = attachments.filter(it => mediaLayouts.includes(it.layout)); const al = attachments.length; @@ -361,6 +363,7 @@ const ChatMessage = observer(class ChatMessage extends React.Component { if (ml && (ml == al)) { c.push(`withLayout ${ml >= 10 ? `layout-10` : `layout-${ml}`}`); }; + return c.join(' '); }; diff --git a/src/ts/component/block/embed.tsx b/src/ts/component/block/embed.tsx index 55f9d3139d..f4230b77a6 100644 --- a/src/ts/component/block/embed.tsx +++ b/src/ts/component/block/embed.tsx @@ -469,12 +469,9 @@ const BlockEmbed = observer(class BlockEmbed extends React.Component { return; }; - Action.openFileDialog(accept, paths => { + Action.openFileDialog({ extensions: accept }, paths => { if (onChangeFile) { onChangeFile(e, paths[0]); }; diff --git a/src/ts/component/list/object.tsx b/src/ts/component/list/object.tsx index c0f36ffc00..52821e11ee 100644 --- a/src/ts/component/list/object.tsx +++ b/src/ts/component/list/object.tsx @@ -13,6 +13,7 @@ interface Column { }; interface Props { + spaceId: string; subId: string; rootId: string; columns: Column[]; @@ -27,6 +28,7 @@ const LIMIT = 50; const ListObject = observer(class ListObject extends React.Component { public static defaultProps: Props = { + spaceId: '', subId: '', rootId: '', columns: [], @@ -189,7 +191,7 @@ const ListObject = observer(class ListObject extends React.Component { }; getData (page: number, callBack?: (message: any) => void) { - const { subId, sources } = this.props; + const { spaceId, subId, sources } = this.props; const offset = (page - 1) * LIMIT; const filters = [ { relationKey: 'layout', condition: I.FilterCondition.NotIn, value: U.Object.excludeFromSet() }, @@ -198,6 +200,7 @@ const ListObject = observer(class ListObject extends React.Component { S.Record.metaSet(subId, '', { offset }); U.Data.searchSubscribe({ + spaceId, subId, sorts: [ { relationKey: 'lastModifiedDate', type: I.SortType.Desc } @@ -209,7 +212,6 @@ const ListObject = observer(class ListObject extends React.Component { limit: LIMIT, ignoreHidden: true, ignoreDeleted: true, - ignoreWorkspace: true, }, callBack); }; diff --git a/src/ts/component/menu/block/context.tsx b/src/ts/component/menu/block/context.tsx index 17719b0a6f..bcef6a012f 100644 --- a/src/ts/component/menu/block/context.tsx +++ b/src/ts/component/menu/block/context.tsx @@ -191,10 +191,10 @@ const MenuBlockContext = observer(class MenuBlockContext extends React.Component let menuId = ''; let menuParam: any = { element: `#${getId()} #button-${blockId}-${type}`, + className: 'fromContext', offsetY: 6, horizontal: I.MenuDirection.Center, noAnimation: true, - className: 'fromContext', data: { rootId, blockId, diff --git a/src/ts/component/menu/block/cover.tsx b/src/ts/component/menu/block/cover.tsx index b4b354ecc6..ce42daa4df 100644 --- a/src/ts/component/menu/block/cover.tsx +++ b/src/ts/component/menu/block/cover.tsx @@ -267,7 +267,7 @@ const MenuBlockCover = observer(class MenuBlockCover extends React.Component { + Action.openFileDialog({ extensions: J.Constant.fileExtension.cover }, paths => { close(); if (onUploadStart) { diff --git a/src/ts/component/menu/dataview/file/list.tsx b/src/ts/component/menu/dataview/file/list.tsx index 45f56c189c..8a5a7d38a6 100644 --- a/src/ts/component/menu/dataview/file/list.tsx +++ b/src/ts/component/menu/dataview/file/list.tsx @@ -306,7 +306,7 @@ const MenuDataviewFileList = observer(class MenuDataviewFileList extends React.C }; onUpload () { - Action.openFileDialog([], paths => { + Action.openFileDialog({}, paths => { C.FileUpload(S.Common.space, '', paths[0], I.FileType.None, {}, (message: any) => { if (!message.error.code) { this.onChange(message.objectId); diff --git a/src/ts/component/menu/quickCapture.tsx b/src/ts/component/menu/quickCapture.tsx index 1202c1aaa3..ca2e447273 100644 --- a/src/ts/component/menu/quickCapture.tsx +++ b/src/ts/component/menu/quickCapture.tsx @@ -221,7 +221,6 @@ class MenuQuickCapture extends React.Component { const layouts = U.Object.getPageLayouts().concat(U.Object.getSetLayouts()).concat(I.ObjectLayout.Chat); const filters: any[] = [ - { relationKey: 'spaceId', condition: I.FilterCondition.In, value: [ J.Constant.storeSpaceId, S.Common.space ] }, { relationKey: 'layout', condition: I.FilterCondition.In, value: I.ObjectLayout.Type }, { relationKey: 'recommendedLayout', condition: I.FilterCondition.In, value: layouts }, { relationKey: 'uniqueKey', condition: I.FilterCondition.NotEqual, value: J.Constant.typeKey.template }, @@ -231,32 +230,40 @@ class MenuQuickCapture extends React.Component { { relationKey: 'name', type: I.SortType.Asc }, ]; - U.Data.search({ + const param = { filters, sorts, keys: U.Data.typeRelationKeys(), fullText: filter, offset: this.offset, - ignoreWorkspace: true, - }, (message: any) => { - if (!this._isMounted) { - return; - }; + }; - if (message.error.code) { - return; - }; + if (clear) { + this.items = []; + }; + + this.loadRequest(param, () => { + this.loadRequest({ ...param, spaceId: J.Constant.storeSpaceId }, (message: any) => { + if (!this._isMounted) { + return; + }; + + if (callBack) { + callBack(message); + }; + + this.forceUpdate(); + }); + }); + }; + + loadRequest (param: any, callBack?: (message: any) => void) { + U.Data.search(param, (message: any) => { + this.items = this.items.concat(message.records || []); if (callBack) { callBack(message); }; - - if (clear) { - this.items = []; - }; - - this.items = this.items.concat(message.records || []); - this.forceUpdate(); }); }; diff --git a/src/ts/component/menu/relation/suggest.tsx b/src/ts/component/menu/relation/suggest.tsx index e1b8dd0881..eb7a05e955 100644 --- a/src/ts/component/menu/relation/suggest.tsx +++ b/src/ts/component/menu/relation/suggest.tsx @@ -222,53 +222,54 @@ const MenuRelationSuggest = observer(class MenuRelationSuggest extends React.Com const { data } = param; const filter = String(data.filter || ''); const filters: any[] = [ - { relationKey: 'spaceId', condition: I.FilterCondition.In, value: [ J.Constant.storeSpaceId, S.Common.space ] }, { relationKey: 'layout', condition: I.FilterCondition.In, value: I.ObjectLayout.Relation }, { relationKey: 'relationKey', condition: I.FilterCondition.NotIn, value: data.skipKeys || [] }, ]; const sorts = [ - { relationKey: 'spaceId', type: I.SortType.Desc }, { relationKey: 'lastUsedDate', type: I.SortType.Desc }, { relationKey: 'name', type: I.SortType.Asc }, ]; if (clear) { this.setState({ isLoading: true }); + this.items = []; }; - U.Data.search({ + const requestParam = { filters, sorts, keys: J.Relation.relation, fullText: filter, offset: this.offset, limit: J.Constant.limit.menuRecords, - ignoreWorkspace: true, - }, (message: any) => { - if (!this._isMounted) { - return; - }; + }; - if (message.error.code) { - this.setState({ isLoading: false }); - return; - }; + this.loadRequest(requestParam, () => { + this.loadRequest({ ...requestParam, spaceId: J.Constant.storeSpaceId }, (message: any) => { + if (!this._isMounted) { + return; + }; + + if (callBack) { + callBack(message); + }; + + if (clear) { + this.setState({ isLoading: false }); + } else { + this.forceUpdate(); + }; + }); + }); + }; + + loadRequest (param: any, callBack?: (message: any) => void) { + U.Data.search(param, (message: any) => { + this.items = this.items.concat(message.records || []); if (callBack) { callBack(message); }; - - if (clear) { - this.items = []; - }; - - this.items = this.items.concat(message.records || []); - - if (clear) { - this.setState({ isLoading: false }); - } else { - this.forceUpdate(); - }; }); }; @@ -375,7 +376,6 @@ const MenuRelationSuggest = observer(class MenuRelationSuggest extends React.Com classNameWrap, data: { rebind: this.rebind, - ignoreWorkspace: true, }, }; @@ -387,7 +387,6 @@ const MenuRelationSuggest = observer(class MenuRelationSuggest extends React.Com menuParam.className = 'single'; const filters: I.Filter[] = [ - { relationKey: 'spaceId', condition: I.FilterCondition.Equal, value: J.Constant.storeSpaceId }, { relationKey: 'layout', condition: I.FilterCondition.Equal, value: I.ObjectLayout.Relation }, { relationKey: 'id', condition: I.FilterCondition.NotIn, value: sources }, { relationKey: 'relationKey', condition: I.FilterCondition.NotIn, value: skipKeys }, @@ -396,6 +395,7 @@ const MenuRelationSuggest = observer(class MenuRelationSuggest extends React.Com menuParam.data = Object.assign(menuParam.data, { keys: U.Data.typeRelationKeys(), filters, + spaceId: J.Constant.storeSpaceId, sorts: [ { relationKey: 'name', type: I.SortType.Asc }, ], diff --git a/src/ts/component/menu/search/object.tsx b/src/ts/component/menu/search/object.tsx index 32376c2257..c6da12e540 100644 --- a/src/ts/component/menu/search/object.tsx +++ b/src/ts/component/menu/search/object.tsx @@ -301,9 +301,10 @@ const MenuSearchObject = observer(class MenuSearchObject extends React.Component const { param } = this.props; const { data } = param; - const { type, dataMapper, dataSort, dataChange, skipIds, keys, ignoreWorkspace } = data; + const { type, dataMapper, dataSort, dataChange, skipIds, keys } = data; const filter = String(data.filter || ''); const templateType = S.Record.getTemplateType(); + const spaceId = data.spaceId || S.Common.space; const filters: any[] = [ { relationKey: 'layout', condition: I.FilterCondition.NotIn, value: U.Object.excludeFromSet() }, @@ -335,13 +336,13 @@ const MenuSearchObject = observer(class MenuSearchObject extends React.Component }; U.Data.search({ + spaceId, filters, sorts, keys: keys || J.Relation.default, fullText: filter, offset: this.offset, limit: J.Constant.limit.menuRecords, - ignoreWorkspace: (typeof ignoreWorkspace === 'undefined' ? false : ignoreWorkspace), }, (message: any) => { if (!this._isMounted) { return; diff --git a/src/ts/component/menu/smile.tsx b/src/ts/component/menu/smile.tsx index e521ff6ef0..75503ccff3 100644 --- a/src/ts/component/menu/smile.tsx +++ b/src/ts/component/menu/smile.tsx @@ -1058,7 +1058,7 @@ const MenuSmile = observer(class MenuSmile extends React.Component { + Action.openFileDialog({ extensions: J.Constant.fileExtension.cover }, paths => { if (!paths.length) { return; }; diff --git a/src/ts/component/menu/type/suggest.tsx b/src/ts/component/menu/type/suggest.tsx index 22ccb1ccf0..ae6824168c 100644 --- a/src/ts/component/menu/type/suggest.tsx +++ b/src/ts/component/menu/type/suggest.tsx @@ -223,13 +223,11 @@ const MenuTypeSuggest = observer(class MenuTypeSuggest extends React.Component { - if (!this._isMounted) { - return; - }; + }; - if (message.error.code) { - this.setState({ isLoading: false }); - return; - }; + this.loadRequest(requestParam, () => { + this.loadRequest({ ...requestParam, spaceId: J.Constant.storeSpaceId }, (message: any) => { + if (!this._isMounted) { + return; + }; + + if (callBack) { + callBack(message); + }; + + if (clear) { + this.setState({ isLoading: false }); + } else { + this.forceUpdate(); + }; + }); + }); + }; + + loadRequest (param: any, callBack?: (message: any) => void) { + U.Data.search(param, (message: any) => { + this.items = this.items.concat(message.records || []); if (callBack) { callBack(message); }; - - if (clear) { - this.items = []; - }; - - this.items = this.items.concat(message.records || []); - - if (clear) { - this.setState({ isLoading: false }); - } else { - this.forceUpdate(); - }; }); }; @@ -382,7 +383,6 @@ const MenuTypeSuggest = observer(class MenuTypeSuggest extends React.Component @@ -85,6 +81,7 @@ const PageMainRelation = observer(class PageMainRelation extends React.Component this.refListType = ref} {...this.props} + spaceId={object.spaceId} subId={subIdType} rootId={rootId} columns={[]} @@ -101,10 +98,10 @@ const PageMainRelation = observer(class PageMainRelation extends React.Component ref={ref => this.refListObject = ref} {...this.props} sources={[ rootId ]} + spaceId={object.spaceId} subId={subIdObject} rootId={rootId} columns={columnsObject} - filters={filtersObject} /> diff --git a/src/ts/component/page/main/type.tsx b/src/ts/component/page/main/type.tsx index 64ef2e1993..883782a21d 100644 --- a/src/ts/component/page/main/type.tsx +++ b/src/ts/component/page/main/type.tsx @@ -73,9 +73,6 @@ const PageMainType = observer(class PageMainType extends React.Component @@ -281,16 +278,15 @@ const PageMainType = observer(class PageMainType extends React.Component { diff --git a/src/ts/component/popup/page/settings/space/index.tsx b/src/ts/component/popup/page/settings/space/index.tsx index 46cc3ccfaa..07c0b57e25 100644 --- a/src/ts/component/popup/page/settings/space/index.tsx +++ b/src/ts/component/popup/page/settings/space/index.tsx @@ -46,10 +46,10 @@ const PopupSettingsSpaceIndex = observer(class PopupSettingsSpaceIndex extends R const { account, accountSpaceId } = S.Auth; const spaces = U.Space.getList(); const space = U.Space.getSpaceview(); - const creator = S.Detail.get(J.Constant.subId.space, space.creator); + const creator = U.Space.getCreator(space.targetSpaceId, space.creator); const home = U.Space.getDashboard(); const type = S.Record.getTypeById(S.Common.type); - const personalSpace = U.Space.getSpaceviewBySpaceId(accountSpaceId); + const profile = U.Space.getProfile(); const usageCn = [ 'item' ]; const requestCnt = this.getRequestCnt(); @@ -81,7 +81,7 @@ const PopupSettingsSpaceIndex = observer(class PopupSettingsSpaceIndex extends R }).filter(it => it); const isRed = (bytesUsed / bytesLimit >= STORAGE_FULL) || (localUsage > bytesLimit); - if (personalSpace && (sharedCnt >= personalSpace.sharedSpacesLimit) && !space.isShared) { + if ((sharedCnt >= profile.sharedSpacesLimit) && !space.isShared) { canShare = false; canMembers = false; }; diff --git a/src/ts/component/popup/page/settings/space/list.tsx b/src/ts/component/popup/page/settings/space/list.tsx index 8d28372314..c6ed8c5b84 100644 --- a/src/ts/component/popup/page/settings/space/list.tsx +++ b/src/ts/component/popup/page/settings/space/list.tsx @@ -13,7 +13,7 @@ const PopupSettingsPageSpacesList = observer(class PopupSettingsPageSpacesList e const Row = (space: any) => { const { targetSpaceId } = space; const participant = U.Space.getMyParticipant(targetSpaceId); - const creator = S.Detail.get(J.Constant.subId.space, space.creator); + const creator = U.Space.getCreator(targetSpaceId, space.creator); const hasMenu = targetSpaceId != accountSpaceId; let creatorElement = null; diff --git a/src/ts/component/popup/page/settings/space/share.tsx b/src/ts/component/popup/page/settings/space/share.tsx index b5cbc60c43..8909d9be52 100644 --- a/src/ts/component/popup/page/settings/space/share.tsx +++ b/src/ts/component/popup/page/settings/space/share.tsx @@ -331,16 +331,21 @@ const PopupSettingsSpaceShare = observer(class PopupSettingsSpaceShare extends R }; onInitLink () { - this.refButton?.setLoading(true); + const btn = this.refButton; + if (!btn || btn.state.isLoading) { + return; + }; + + btn.setLoading(true); C.SpaceMakeShareable(S.Common.space, (message: any) => { if (this.setError(message.error)) { - this.refButton?.setLoading(false); + btn.setLoading(false); return; }; C.SpaceInviteGenerate(S.Common.space, (message: any) => { - this.refButton?.setLoading(false); + btn.setLoading(false); if (!this.setError(message.error)) { this.setInvite(message.inviteCid, message.inviteKey); diff --git a/src/ts/component/popup/preview.tsx b/src/ts/component/popup/preview.tsx index ea7b478db4..e9ef39d625 100644 --- a/src/ts/component/popup/preview.tsx +++ b/src/ts/component/popup/preview.tsx @@ -5,6 +5,10 @@ import { I, S, J, U, keyboard, sidebar, translate } from 'Lib'; import { Swiper, SwiperSlide } from 'swiper/react'; import { Keyboard, Mousewheel, Thumbs, Navigation } from 'swiper/modules'; +interface State { + current: any; +}; + const BORDER = 16; const WIDTH_VIDEO = 1040; const HEIGHT_VIDEO = 585; @@ -18,12 +22,16 @@ class PopupPreview extends React.Component { thumbs = null; galleryMap: Map = new Map(); current: any = null; + state = { + current: null, + }; constructor (props: I.Popup) { super(props); this.onMore = this.onMore.bind(this); this.onError = this.onError.bind(this); + this.onExpand = this.onExpand.bind(this); this.setCurrent = this.setCurrent.bind(this); }; @@ -31,6 +39,7 @@ class PopupPreview extends React.Component { const { param, close } = this.props; const { data } = param; const { gallery } = data; + const { current } = this.state; const initial = data.initialIdx || 0; const getContent = (item: any, idx: number, isThumb?: boolean) => { @@ -68,17 +77,16 @@ class PopupPreview extends React.Component { return (
- {this.current ? ( -
-
-
+ {current ? ( + +
- +
-
+
) : ''}
@@ -86,7 +94,7 @@ class PopupPreview extends React.Component { this.swiper = swiper} initialSlide={initial} - spaceBetween={8} + spaceBetween={0} slidesPerView={1} centeredSlides={true} keyboard={{ enabled: true }} @@ -94,10 +102,10 @@ class PopupPreview extends React.Component { thumbs={{ swiper: this.thumbs }} navigation={true} modules={[ Mousewheel, Keyboard, Thumbs, Navigation ]} - onTransitionEnd={(data) => this.setCurrent(data.activeIndex)} + onTransitionEnd={data => this.setCurrent(data.activeIndex)} > {gallery.map((item: any, i: number) => ( - + close()}> {getContent(item, i)} ))} @@ -111,7 +119,7 @@ class PopupPreview extends React.Component { onSwiper={swiper => this.thumbs = swiper} initialSlide={initial} spaceBetween={8} - slidesPerView={'auto'} + slidesPerView="auto" modules={[ Thumbs ]} > {gallery.map((item: any, i: number) => ( @@ -167,8 +175,7 @@ class PopupPreview extends React.Component { const item = gallery[idx]; if (item && item.object) { - this.current = item.object; - this.forceUpdate(); + this.setState({ current: item.object }); }; }; @@ -176,26 +183,41 @@ class PopupPreview extends React.Component { keyboard.shortcut('escape', e, () => this.props.close()); }; - onMore () { - const { getId, close } = this.props; + onExpand (e: any) { + e.stopPropagation(); + e.preventDefault(); - if (!this.current) { + const { current } = this.state; + + S.Popup.closeAll(null, () => { + if (current) { + U.Object.openAuto(current); + }; + }); + }; + + onMore (e: any) { + e.stopPropagation(); + e.preventDefault(); + + const { getId, close } = this.props; + const { current } = this.state; + + if (!current) { return; }; - const cb = () => { - close(); - }; + const cb = () => close(); S.Menu.open('object', { element: `#${getId()} #button-header-more`, horizontal: I.MenuDirection.Right, subIds: J.Menu.object, data: { - rootId: this.current.id, - blockId: this.current.id, - blockIds: [ this.current.id ], - object: this.current, + rootId: current.id, + blockId: current.id, + blockIds: [ current.id ], + object: current, isFilePreview: true, onArchive: cb, onDelete: cb, @@ -207,8 +229,12 @@ class PopupPreview extends React.Component { const { getId } = this.props; const node = $(`#${getId()}-innerWrap`); const wrap = node.find(`#itemPreview-${idx}`); - const obj = this.galleryMap.get(idx); + if (!wrap.length) { + return; + }; + + const obj = this.galleryMap.get(idx); if (!obj) { return; }; diff --git a/src/ts/component/popup/search.tsx b/src/ts/component/popup/search.tsx index 93d43042e5..36af27c12b 100644 --- a/src/ts/component/popup/search.tsx +++ b/src/ts/component/popup/search.tsx @@ -589,7 +589,6 @@ const PopupSearch = observer(class PopupSearch extends React.Component { + C.ObjectSearchWithMeta(space, filters, sorts, J.Relation.default.concat([ 'links', 'backlinks', '_score' ]), filter, this.offset, limit, (message) => { if (message.error.code) { this.setState({ isLoading: false }); return; diff --git a/src/ts/component/popup/settings/onboarding.tsx b/src/ts/component/popup/settings/onboarding.tsx index d930834732..85c985a344 100644 --- a/src/ts/component/popup/settings/onboarding.tsx +++ b/src/ts/component/popup/settings/onboarding.tsx @@ -133,7 +133,7 @@ const PopupSettingsOnboarding = observer(class PopupSettingsOnboarding extends R }; onUpload () { - Action.openFileDialog([ 'yml' ], (paths: string[]) => this.onChange('path', paths[0])); + Action.openFileDialog({ extensions: [ 'yml' ] }, (paths: string[]) => this.onChange('path', paths[0])); }; onSave () { diff --git a/src/ts/component/widget/buttons.tsx b/src/ts/component/widget/buttons.tsx index ed4d6098af..e258944b82 100644 --- a/src/ts/component/widget/buttons.tsx +++ b/src/ts/component/widget/buttons.tsx @@ -64,6 +64,10 @@ const WidgetButtons = observer(class WidgetSpace extends React.Component void) { + openFileDialog (param: any, callBack?: (paths: string[]) => void) { + param = Object.assign({ + extensions: [], + properties: [], + }, param); + + const properties = param.properties || []; + const extensions = param.extensions || []; + const options: any = { - properties: [ 'openFile' ], + properties: [ 'openFile' ].concat(properties), }; - if (extensions && extensions.length) { + if (extensions.length) { options.filters = [ { name: 'Filtered extensions', extensions }, ]; @@ -400,7 +408,7 @@ class Action { const { dataPath } = S.Common; const { mode, path } = networkConfig; - this.openFileDialog([ 'zip' ], paths => { + this.openFileDialog({ extensions: [ 'zip' ] }, paths => { C.AccountRecoverFromLegacyExport(paths[0], dataPath, U.Common.rand(1, J.Constant.count.icon), (message: any) => { if (onError(message.error)) { return; diff --git a/src/ts/lib/api/command.ts b/src/ts/lib/api/command.ts index f8b39fd715..a1d6cecac7 100644 --- a/src/ts/lib/api/command.ts +++ b/src/ts/lib/api/command.ts @@ -1544,9 +1544,10 @@ export const ObjectListModifyDetailValues = (objectIds: string[], operations: an dispatcher.request(ObjectListModifyDetailValues.name, request, callBack); }; -export const ObjectSearch = (filters: I.Filter[], sorts: I.Sort[], keys: string[], fullText: string, offset: number, limit: number, callBack?: (message: any) => void) => { +export const ObjectSearch = (spaceId: string, filters: I.Filter[], sorts: I.Sort[], keys: string[], fullText: string, offset: number, limit: number, callBack?: (message: any) => void) => { const request = new Rpc.Object.Search.Request(); + request.setSpaceid(spaceId); request.setFiltersList(filters.map(Mapper.To.Filter)); request.setSortsList(sorts.map(Mapper.To.Sort)); request.setFulltext(fullText); @@ -1557,9 +1558,10 @@ export const ObjectSearch = (filters: I.Filter[], sorts: I.Sort[], keys: string[ dispatcher.request(ObjectSearch.name, request, callBack); }; -export const ObjectSearchWithMeta = (filters: I.Filter[], sorts: I.Sort[], keys: string[], fullText: string, offset: number, limit: number, callBack?: (message: any) => void) => { +export const ObjectSearchWithMeta = (spaceId: string, filters: I.Filter[], sorts: I.Sort[], keys: string[], fullText: string, offset: number, limit: number, callBack?: (message: any) => void) => { const request = new Rpc.Object.SearchWithMeta.Request(); + request.setSpaceid(spaceId); request.setFiltersList(filters.map(Mapper.To.Filter)); request.setSortsList(sorts.map(Mapper.To.Sort)); request.setFulltext(fullText); @@ -1570,9 +1572,10 @@ export const ObjectSearchWithMeta = (filters: I.Filter[], sorts: I.Sort[], keys: dispatcher.request(ObjectSearchWithMeta.name, request, callBack); }; -export const ObjectSearchSubscribe = (subId: string, filters: I.Filter[], sorts: I.Sort[], keys: string[], sources: string[], offset: number, limit: number, afterId: string, beforeId: string, noDeps: boolean, collectionId: string, callBack?: (message: any) => void) => { +export const ObjectSearchSubscribe = (spaceId: string, subId: string, filters: I.Filter[], sorts: I.Sort[], keys: string[], sources: string[], offset: number, limit: number, afterId: string, beforeId: string, noDeps: boolean, collectionId: string, callBack?: (message: any) => void) => { const request = new Rpc.Object.SearchSubscribe.Request(); + request.setSpaceid(spaceId); request.setSubid(subId); request.setFiltersList(filters.map(Mapper.To.Filter)); request.setSortsList(sorts.map(Mapper.To.Sort)); @@ -1601,9 +1604,10 @@ export const ObjectGroupsSubscribe = (spaceId: string, subId: string, relationKe dispatcher.request(ObjectGroupsSubscribe.name, request, callBack); }; -export const ObjectSubscribeIds = (subId: string, ids: string[], keys: string[], noDeps: boolean, callBack?: (message: any) => void) => { +export const ObjectSubscribeIds = (spaceId: string, subId: string, ids: string[], keys: string[], noDeps: boolean, callBack?: (message: any) => void) => { const request = new Rpc.Object.SubscribeIds.Request(); + request.setSpaceid(spaceId); request.setSubid(subId); request.setIdsList(ids); request.setKeysList(keys); diff --git a/src/ts/lib/api/dispatcher.ts b/src/ts/lib/api/dispatcher.ts index 7e7c72c2b1..714383b103 100644 --- a/src/ts/lib/api/dispatcher.ts +++ b/src/ts/lib/api/dispatcher.ts @@ -797,7 +797,7 @@ class Dispatcher { // Added space should be subscribed to my participant if (U.Object.isSpaceViewLayout(details.layout) && details.targetSpaceId) { - U.Data.createMyParticipantSubscriptions([ details.targetSpaceId ]); + U.Data.createSubSpaceSubscriptions([ details.targetSpaceId ]); }; updateMarkup = true; diff --git a/src/ts/lib/api/mapper.ts b/src/ts/lib/api/mapper.ts index c2b6cdd1ca..4f19061676 100644 --- a/src/ts/lib/api/mapper.ts +++ b/src/ts/lib/api/mapper.ts @@ -76,6 +76,7 @@ export const Mapper = { deviceId: obj.getDeviceid(), localStoragePath: obj.getLocalstoragepath(), accountSpaceId: obj.getAccountspaceid(), + techSpaceId: obj.getTechspaceid(), spaceViewId: obj.getSpaceviewid(), widgetsId: obj.getWidgetsid(), analyticsId: obj.getAnalyticsid(), diff --git a/src/ts/lib/dataview.ts b/src/ts/lib/dataview.ts index 0fba1d5df3..9d30bdc29f 100644 --- a/src/ts/lib/dataview.ts +++ b/src/ts/lib/dataview.ts @@ -101,7 +101,6 @@ class Dataview { keys: J.Relation.default, offset: 0, limit: 0, - ignoreWorkspace: false, sources: [], clear: false, collectionId: '', diff --git a/src/ts/lib/util/data.ts b/src/ts/lib/util/data.ts index 217b5fe470..cf4915a63f 100644 --- a/src/ts/lib/util/data.ts +++ b/src/ts/lib/util/data.ts @@ -2,6 +2,7 @@ import * as Sentry from '@sentry/browser'; import { I, C, M, S, J, U, keyboard, translate, Storage, analytics, dispatcher, Mark, focus, Renderer, Action, Survey, Onboarding, Preview } from 'Lib'; type SearchSubscribeParams = Partial<{ + spaceId: string; subId: string; idField: string; filters: I.Filter[]; @@ -13,7 +14,6 @@ type SearchSubscribeParams = Partial<{ beforeId: string; offset: number; limit: number; - ignoreWorkspace: boolean; ignoreHidden: boolean; ignoreDeleted: boolean; withArchived: boolean; @@ -289,17 +289,20 @@ class UtilData { return; }; + const { techSpaceId } = account.info; const list: any[] = [ { + spaceId: techSpaceId, subId: J.Constant.subId.profile, + keys: this.profileRelationKeys(), filters: [ { relationKey: 'id', condition: I.FilterCondition.Equal, value: account.info.profileObjectId }, ], noDeps: true, - ignoreWorkspace: true, ignoreHidden: false, }, { + spaceId: techSpaceId, subId: J.Constant.subId.space, keys: this.spaceRelationKeys(), filters: [ @@ -308,17 +311,16 @@ class UtilData { sorts: [ { relationKey: 'createdDate', type: I.SortType.Desc }, ], - ignoreWorkspace: true, ignoreHidden: false, }, ]; this.createSubscriptions(list, () => { - this.createMyParticipantSubscriptions(null, callBack); + this.createSubSpaceSubscriptions(null, callBack); }); }; - createMyParticipantSubscriptions (ids: string[], callBack?: () => void) { + createSubSpaceSubscriptions (ids: string[], callBack?: () => void) { const { account } = S.Auth; if (!account) { @@ -343,15 +345,23 @@ class UtilData { const list = []; spaces.forEach(space => { + const ids = [ + space.creator, + U.Space.getParticipantId(space.targetSpaceId, account.id), + ]; + + if (![ I.HomePredefinedId.Graph, I.HomePredefinedId.Last ].includes(space.spaceDashboardId)) { + ids.push(space.spaceDashboardId); + }; + list.push({ - subId: [ J.Constant.subId.myParticipant, space.targetSpaceId ].join('-'), + spaceId: space.targetSpaceId, + subId: U.Space.getSubSpaceSubId(space.targetSpaceId), keys: this.participantRelationKeys(), filters: [ - { relationKey: 'spaceId', condition: I.FilterCondition.Equal, value: space.targetSpaceId }, - { relationKey: 'id', condition: I.FilterCondition.Equal, value: U.Space.getParticipantId(space.targetSpaceId, account.id) }, + { relationKey: 'id', condition: I.FilterCondition.In, value: ids }, ], noDeps: true, - ignoreWorkspace: true, ignoreDeleted: true, ignoreHidden: false, }); @@ -376,37 +386,58 @@ class UtilData { subId: J.Constant.subId.type, keys: this.typeRelationKeys(), filters: [ - { relationKey: 'spaceId', condition: I.FilterCondition.In, value: [ J.Constant.storeSpaceId, space ] }, { relationKey: 'layout', condition: I.FilterCondition.In, value: I.ObjectLayout.Type }, ], sorts: [ - { relationKey: 'spaceId', type: I.SortType.Desc }, { relationKey: 'lastUsedDate', type: I.SortType.Desc }, { relationKey: 'name', type: I.SortType.Asc }, ], noDeps: true, - ignoreWorkspace: true, ignoreDeleted: true, ignoreHidden: false, onSubscribe: () => { S.Record.getTypes().forEach(it => S.Record.typeKeyMapSet(it.spaceId, it.uniqueKey, it.id)); } }, + { + spaceId: J.Constant.storeSpaceId, + subId: J.Constant.subId.typeStore, + keys: this.typeRelationKeys(), + filters: [ + { relationKey: 'layout', condition: I.FilterCondition.In, value: I.ObjectLayout.Type }, + ], + sorts: [ + { relationKey: 'lastUsedDate', type: I.SortType.Desc }, + { relationKey: 'name', type: I.SortType.Asc }, + ], + noDeps: true, + ignoreDeleted: true, + ignoreHidden: false, + }, { subId: J.Constant.subId.relation, keys: J.Relation.relation, filters: [ - { relationKey: 'spaceId', condition: I.FilterCondition.In, value: [ J.Constant.storeSpaceId, space ] }, { relationKey: 'layout', condition: I.FilterCondition.In, value: I.ObjectLayout.Relation }, ], noDeps: true, - ignoreWorkspace: true, ignoreDeleted: true, ignoreHidden: false, onSubscribe: () => { S.Record.getRelations().forEach(it => S.Record.relationKeyMapSet(it.spaceId, it.relationKey, it.id)); }, }, + { + spaceId: J.Constant.storeSpaceId, + subId: J.Constant.subId.relationStore, + keys: J.Relation.relation, + filters: [ + { relationKey: 'layout', condition: I.FilterCondition.In, value: I.ObjectLayout.Relation }, + ], + noDeps: true, + ignoreDeleted: true, + ignoreHidden: false, + }, { subId: J.Constant.subId.option, keys: J.Relation.option, @@ -463,6 +494,10 @@ class UtilData { ids.forEach(id => Action.dbClearRoot(id)); }; + profileRelationKeys () { + return J.Relation.default.concat('sharedSpacesLimit'); + }; + spaceRelationKeys () { return J.Relation.default.concat(J.Relation.space).concat(J.Relation.participant); }; @@ -765,17 +800,13 @@ class UtilData { }; searchDefaultFilters (param: any) { - const { config, space } = S.Common; - const { ignoreWorkspace, ignoreHidden, ignoreDeleted, withArchived } = param; + const { config } = S.Common; + const { ignoreHidden, ignoreDeleted, withArchived } = param; const filters = param.filters || []; const chatDerivedType = S.Record.getChatDerivedType(); filters.push({ relationKey: 'uniqueKey', condition: I.FilterCondition.NotEqual, value: J.Constant.typeKey.chatDerived }); - if (!ignoreWorkspace) { - filters.push({ relationKey: 'spaceId', condition: I.FilterCondition.Equal, value: space }); - }; - if (ignoreHidden && !config.debug.hiddenObject) { filters.push({ relationKey: 'isHidden', condition: I.FilterCondition.NotEqual, value: true }); filters.push({ relationKey: 'isHiddenDiscovery', condition: I.FilterCondition.NotEqual, value: true }); @@ -829,9 +860,10 @@ class UtilData { }; searchSubscribe (param: SearchSubscribeParams, callBack?: (message: any) => void) { - const { config, space } = S.Common; + const { space } = S.Common; param = Object.assign({ + spaceId: space, subId: '', idField: 'id', filters: [], @@ -840,7 +872,6 @@ class UtilData { sources: [], offset: 0, limit: 0, - ignoreWorkspace: false, ignoreHidden: true, ignoreDeleted: true, withArchived: false, @@ -850,7 +881,7 @@ class UtilData { collectionId: '' }, param); - const { subId, idField, sorts, sources, offset, limit, ignoreWorkspace, afterId, beforeId, noDeps, collectionId } = param; + const { spaceId, subId, idField, sorts, sources, offset, limit, afterId, beforeId, noDeps, collectionId } = param; const keys: string[] = [ ...new Set(param.keys as string[]) ]; const filters = this.searchDefaultFilters(param); @@ -863,7 +894,7 @@ class UtilData { keys.push(idField); }; - C.ObjectSearchSubscribe(subId, filters, sorts.map(this.sortMapper), keys, sources, offset, limit, afterId, beforeId, noDeps, collectionId, (message: any) => { + C.ObjectSearchSubscribe(spaceId, subId, filters, sorts.map(this.sortMapper), keys, sources, offset, limit, afterId, beforeId, noDeps, collectionId, (message: any) => { this.onSubscribe(subId, idField, keys, message); if (callBack) { @@ -873,7 +904,10 @@ class UtilData { }; subscribeIds (param: any, callBack?: (message: any) => void) { + const { space } = S.Common; + param = Object.assign({ + spaceId: space, subId: '', ids: [], keys: J.Relation.default, @@ -881,7 +915,7 @@ class UtilData { idField: 'id', }, param); - const { subId, keys, noDeps, idField } = param; + const { spaceId, subId, keys, noDeps, idField } = param; const ids = U.Common.arrayUnique(param.ids.filter(it => it)); if (!subId) { @@ -897,7 +931,7 @@ class UtilData { keys.push(idField); }; - C.ObjectSubscribeIds(subId, ids, keys, noDeps, (message: any) => { + C.ObjectSubscribeIds(spaceId, subId, ids, keys, noDeps, (message: any) => { (message.records || []).sort((c1: any, c2: any) => { const i1 = ids.indexOf(c1.id); const i2 = ids.indexOf(c2.id); @@ -915,7 +949,10 @@ class UtilData { }; search (param: SearchSubscribeParams & { fullText?: string }, callBack?: (message: any) => void) { + const { space } = S.Common; + param = Object.assign({ + spaceId: space, idField: 'id', fullText: '', filters: [], @@ -923,13 +960,12 @@ class UtilData { keys: J.Relation.default, offset: 0, limit: 0, - ignoreWorkspace: false, ignoreHidden: true, ignoreDeleted: true, withArchived: false, }, param); - const { idField, sorts, offset, limit } = param; + const { spaceId, idField, sorts, offset, limit } = param; const keys: string[] = [ ...new Set(param.keys as string[]) ]; const filters = this.searchDefaultFilters(param); @@ -937,7 +973,7 @@ class UtilData { keys.push(idField); }; - C.ObjectSearch(filters, sorts.map(this.sortMapper), keys, param.fullText, offset, limit, (message: any) => { + C.ObjectSearch(spaceId, filters, sorts.map(this.sortMapper), keys, param.fullText, offset, limit, (message: any) => { if (message.records) { message.records = message.records.map(it => S.Detail.mapper(it)); }; @@ -985,7 +1021,6 @@ class UtilData { { relationKey: 'isDeleted', condition: I.FilterCondition.NotEqual, value: true }, { relationKey: 'layout', condition: I.FilterCondition.NotIn, value: U.Object.getFileAndSystemLayouts() }, { relationKey: 'id', condition: I.FilterCondition.NotEqual, value: J.Constant.anytypeProfileId }, - { relationKey: 'spaceId', condition: I.FilterCondition.In, value: [ space ] }, ]; if (templateType) { diff --git a/src/ts/lib/util/menu.ts b/src/ts/lib/util/menu.ts index 8196ee6c16..7ceb730cc9 100644 --- a/src/ts/lib/util/menu.ts +++ b/src/ts/lib/util/menu.ts @@ -558,12 +558,14 @@ class UtilMenu { S.Detail.update(J.Constant.subId.space, { id: spaceview, details: { spaceDashboardId: object.id } }, false); if (update) { - S.Detail.update(J.Constant.subId.space, { id: object.id, details: object }, false); + S.Detail.update(U.Space.getSubSpaceSubId(space), { id: object.id, details: object }, false); }; - if (openRoute) { - U.Space.openDashboard('route'); - }; + U.Data.createSubSpaceSubscriptions([ space ], () => { + if (openRoute) { + U.Space.openDashboard('route'); + }; + }); }); }; diff --git a/src/ts/lib/util/object.ts b/src/ts/lib/util/object.ts index c25a51ea45..8830aa594a 100644 --- a/src/ts/lib/util/object.ts +++ b/src/ts/lib/util/object.ts @@ -256,13 +256,9 @@ class UtilObject { { relationKey: 'id', condition: I.FilterCondition.In, value: ids } ]; - C.ObjectSearch(filters, [], [], '', 0, 0, (message: any) => { - if (message.error.code || !message.records.length) { - return; - }; - + U.Data.search({ filters }, (message: any) => { if (callBack) { - callBack(message.records.map(it => S.Detail.mapper(it)).filter(it => !it._empty_)); + callBack((message.records || []).filter(it => !it._empty_)); }; }); }; diff --git a/src/ts/lib/util/space.ts b/src/ts/lib/util/space.ts index 382c2ffac3..2fcaf50c05 100644 --- a/src/ts/lib/util/space.ts +++ b/src/ts/lib/util/space.ts @@ -45,7 +45,7 @@ class UtilSpace { if (id == I.HomePredefinedId.Last) { ret = this.getLastOpened(); } else { - ret = S.Detail.get(J.Constant.subId.space, id); + ret = S.Detail.get(U.Space.getSubSpaceSubId(space.targetSpaceId), id); }; if (!ret || ret._empty_ || ret.isDeleted) { @@ -113,6 +113,10 @@ class UtilSpace { return object._empty_ ? null : object; }; + getSubSpaceSubId (spaceId: string) { + return [ J.Constant.subId.subSpace, spaceId ].join('-'); + }; + getMyParticipant (spaceId?: string) { const { account } = S.Auth; const { space } = S.Common; @@ -123,12 +127,16 @@ class UtilSpace { spaceId = spaceId || space; - const subId = [ J.Constant.subId.myParticipant, spaceId ].join('-'); + const subId = this.getSubSpaceSubId(spaceId); const object = S.Detail.get(subId, this.getParticipantId(spaceId, account.id)); return object._empty_ ? null : object; }; + getCreator (spaceId: string, id: string) { + return S.Detail.get(this.getSubSpaceSubId(spaceId), id); + }; + canMyParticipantWrite (spaceId?: string): boolean { const participant = this.getMyParticipant(spaceId); return participant ? (participant.isWriter || participant.isOwner) : true; diff --git a/src/ts/model/account.ts b/src/ts/model/account.ts index ce2e2af723..affb32956b 100644 --- a/src/ts/model/account.ts +++ b/src/ts/model/account.ts @@ -9,6 +9,7 @@ class AccountInfo implements I.AccountInfo { deviceId = ''; localStoragePath = ''; accountSpaceId = ''; + techSpaceId = ''; spaceViewId = ''; widgetsId = ''; analyticsId = ''; @@ -21,6 +22,7 @@ class AccountInfo implements I.AccountInfo { this.deviceId = String(props.deviceId || ''); this.localStoragePath = String(props.localStoragePath || ''); this.accountSpaceId = String(props.accountSpaceId || ''); + this.techSpaceId = String(props.techSpaceId || ''); this.spaceViewId = String(props.spaceViewId || ''); this.widgetsId = String(props.widgetsId || ''); this.analyticsId = String(props.analyticsId || ''); @@ -33,6 +35,7 @@ class AccountInfo implements I.AccountInfo { deviceId: observable, localStoragePath: observable, accountSpaceId: observable, + techSpaceId: observable, spaceViewId: observable, widgetsId: observable, analyticsId: observable, diff --git a/src/ts/store/detail.ts b/src/ts/store/detail.ts index 6d9c9f48d8..84e8db21b5 100644 --- a/src/ts/store/detail.ts +++ b/src/ts/store/detail.ts @@ -285,8 +285,8 @@ class DetailStore { object.spaceLocalStatus = Number(object.spaceLocalStatus) || I.SpaceStatus.Unknown; object.readersLimit = Number(object.readersLimit) || 0; object.writersLimit = Number(object.writersLimit) || 0; - object.sharedSpacesLimit = Number(object.sharedSpacesLimit) || 0; object.spaceId = Relation.getStringValue(object.spaceId); + object.spaceMainChatId = Relation.getStringValue(object.spaceMainChatId); object.spaceDashboardId = Relation.getStringValue(object.spaceDashboardId); object.targetSpaceId = Relation.getStringValue(object.targetSpaceId); object.iconOption = Number(object.iconOption) || 1; @@ -343,4 +343,4 @@ class DetailStore { }; -export const Detail: DetailStore = new DetailStore(); \ No newline at end of file +export const Detail: DetailStore = new DetailStore();