1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-08 05:57:02 +09:00

Merge branch 'feature/chat' of github.com:anyproto/anytype-ts into publish-test

This commit is contained in:
Andrew Simachev 2024-10-14 16:13:03 +02:00
commit 12ec6b6087
No known key found for this signature in database
GPG key ID: 1DFE44B21443F0EF
46 changed files with 354 additions and 233 deletions

View file

@ -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()),

View file

@ -0,0 +1,3 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.44444 16C4.96914 16 4.83333 15.6374 5.07407 15.3496C5.30864 15.0619 5.92593 14.4288 6.27161 13.8993C6.32099 13.8129 6.29012 13.7266 6.19753 13.6806C4.21605 12.6906 3 11.0734 3 9.23165C3 6.33669 6.11111 4 10 4C13.8889 4 17 6.33669 17 9.23165C17 12.0978 14.0494 14.4576 9.59877 14.4576C9.51852 14.4576 9.43827 14.4518 9.35802 14.446C9.27161 14.446 9.18518 14.4748 9.08025 14.5439C8.03086 15.246 6.18519 16 5.44444 16Z" fill="#252525"/>
</svg>

After

Width:  |  Height:  |  Size: 549 B

View file

@ -0,0 +1,3 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.44444 16C4.96914 16 4.83333 15.6374 5.07407 15.3496C5.30864 15.0619 5.92593 14.4288 6.27161 13.8993C6.32099 13.8129 6.29012 13.7266 6.19753 13.6806C4.21605 12.6906 3 11.0734 3 9.23165C3 6.33669 6.11111 4 10 4C13.8889 4 17 6.33669 17 9.23165C17 12.0978 14.0494 14.4576 9.59877 14.4576C9.51852 14.4576 9.43827 14.4518 9.35802 14.446C9.27161 14.446 9.18518 14.4748 9.08025 14.5439C8.03086 15.246 6.18519 16 5.44444 16Z" fill="#ebebeb"/>
</svg>

After

Width:  |  Height:  |  Size: 549 B

View file

@ -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',
},

View file

@ -137,10 +137,10 @@ export default {
'spaceAccessType',
'readersLimit',
'writersLimit',
'sharedSpacesLimit',
'targetSpaceId',
'creator',
'createdDate'
'createdDate',
'spaceMainChatId'
],
participant: [

View file

@ -168,6 +168,7 @@
"commonNothingFound": "Nothing found",
"commonEntrySpace": "My First Space",
"commonSystem": "System",
"commonMainChat": "Main сhat",
"commonMenu": "Menu",
"pluralDay": "day|days",

View file

@ -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; }

View file

@ -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; }
}
}

View file

@ -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; }

View file

@ -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); }
}

View file

@ -177,7 +177,7 @@ const ChatAttachment = observer(class ChatAttachment extends React.Component<Pro
renderImage () {
const { object } = this.props;
this.previewItem = { type: I.FileType.Image };
this.previewItem = { type: I.FileType.Image, object };
if (!this.src) {
if (object.isTmp && object.file) {
@ -189,7 +189,6 @@ const ChatAttachment = observer(class ChatAttachment extends React.Component<Pro
this.src = './img/space.svg';
} else {
this.src = S.Common.imageUrl(object.id, J.Size.image);
this.previewItem.object = object;
};
};
@ -210,7 +209,7 @@ const ChatAttachment = observer(class ChatAttachment extends React.Component<Pro
const { object } = this.props;
const src = S.Common.fileUrl(object.id);
this.previewItem = { src, type: I.FileType.Video };
this.previewItem = { type: I.FileType.Video, src, object };
return (
<MediaVideo
@ -248,6 +247,10 @@ const ChatAttachment = observer(class ChatAttachment extends React.Component<Pro
onPreview () {
const { onPreview } = this.props;
if (!this.previewItem) {
return;
};
if (onPreview) {
onPreview(this.previewItem);
} else {

View file

@ -241,9 +241,9 @@ const ChatButtons = observer(class ChatButtons extends React.Component<Props, St
];
const upload = () => {
Action.openFileDialog([], paths => {
Action.openFileDialog({ properties: [ 'multiSelections' ] }, paths => {
if (paths.length) {
addAttachments([ getObjectFromPath(paths[0]) ]);
addAttachments(paths.map(path => getObjectFromPath(path)));
};
});
};

View file

@ -38,14 +38,13 @@ const ChatMessage = observer(class ChatMessage extends React.Component<Props> {
};
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<Props> {
};
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<Props> {
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<Props> {
if (ml && (ml == al)) {
c.push(`withLayout ${ml >= 10 ? `layout-10` : `layout-${ml}`}`);
};
return c.join(' ');
};

View file

@ -469,12 +469,9 @@ const BlockEmbed = observer(class BlockEmbed extends React.Component<I.BlockComp
return;
};
const range = this.getRange();
if (!range) {
return;
};
this.range = this.getRange();
S.Common.filterSet(range.from, '');
S.Common.filterSet(this.range.from, '');
this.onLatexMenu(e, 'select', true);
};

View file

@ -260,7 +260,7 @@ class InputWithFile extends React.Component<Props, State> {
return;
};
Action.openFileDialog(accept, paths => {
Action.openFileDialog({ extensions: accept }, paths => {
if (onChangeFile) {
onChangeFile(e, paths[0]);
};

View file

@ -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<Props> {
public static defaultProps: Props = {
spaceId: '',
subId: '',
rootId: '',
columns: [],
@ -189,7 +191,7 @@ const ListObject = observer(class ListObject extends React.Component<Props> {
};
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<Props> {
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<Props> {
limit: LIMIT,
ignoreHidden: true,
ignoreDeleted: true,
ignoreWorkspace: true,
}, callBack);
};

View file

@ -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,

View file

@ -267,7 +267,7 @@ const MenuBlockCover = observer(class MenuBlockCover extends React.Component<I.M
const { data } = param;
const { onUpload, onUploadStart } = data;
Action.openFileDialog(J.Constant.fileExtension.cover, paths => {
Action.openFileDialog({ extensions: J.Constant.fileExtension.cover }, paths => {
close();
if (onUploadStart) {

View file

@ -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);

View file

@ -221,7 +221,6 @@ class MenuQuickCapture extends React.Component<I.Menu, State> {
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<I.Menu, State> {
{ 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();
});
};

View file

@ -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 },
],

View file

@ -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;

View file

@ -1058,7 +1058,7 @@ const MenuSmile = observer(class MenuSmile extends React.Component<I.Menu, State
};
onUpload () {
Action.openFileDialog(J.Constant.fileExtension.cover, paths => {
Action.openFileDialog({ extensions: J.Constant.fileExtension.cover }, paths => {
if (!paths.length) {
return;
};

View file

@ -223,13 +223,11 @@ const MenuTypeSuggest = observer(class MenuTypeSuggest extends React.Component<I
const { skipIds } = data;
const filter = String(data.filter || '');
const sorts = [
{ relationKey: 'spaceId', type: I.SortType.Desc },
{ relationKey: 'lastUsedDate', type: I.SortType.Desc },
{ relationKey: 'name', type: I.SortType.Asc },
];
let 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 },
];
if (data.filters) {
@ -242,41 +240,44 @@ const MenuTypeSuggest = observer(class MenuTypeSuggest extends React.Component<I
if (clear) {
this.setState({ isLoading: true });
this.items = [];
};
U.Data.search({
const requestParam = {
filters,
sorts,
keys: U.Data.typeRelationKeys(),
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();
};
});
};
@ -382,7 +383,6 @@ const MenuTypeSuggest = observer(class MenuTypeSuggest extends React.Component<I
noFlipY: true,
data: {
rebind: this.rebind,
ignoreWorkspace: true,
},
};
@ -400,7 +400,6 @@ const MenuTypeSuggest = observer(class MenuTypeSuggest extends React.Component<I
menuParam.className = className.join(' ');
let filters: I.Filter[] = [
{ relationKey: 'spaceId', condition: I.FilterCondition.Equal, value: J.Constant.storeSpaceId },
{ relationKey: 'layout', condition: I.FilterCondition.Equal, value: I.ObjectLayout.Type },
{ relationKey: 'id', condition: I.FilterCondition.NotIn, value: sources },
];
@ -409,7 +408,7 @@ const MenuTypeSuggest = observer(class MenuTypeSuggest extends React.Component<I
};
menuParam.data = Object.assign(menuParam.data, {
ignoreWorkspace: true,
spaceId: J.Constant.storeSpaceId,
keys: U.Data.typeRelationKeys(),
filters,
sorts: [

View file

@ -50,13 +50,9 @@ const PageMainRelation = observer(class PageMainRelation extends React.Component
];
const filtersType: I.Filter[] = [
{ relationKey: 'spaceId', condition: I.FilterCondition.Equal, value: object.spaceId },
{ relationKey: 'layout', condition: I.FilterCondition.Equal, value: I.ObjectLayout.Type },
{ relationKey: 'recommendedRelations', condition: I.FilterCondition.In, value: [ rootId ] },
];
const filtersObject: I.Filter[] = [
{ relationKey: 'spaceId', condition: I.FilterCondition.Equal, value: object.spaceId },
];
return (
<div>
@ -85,6 +81,7 @@ const PageMainRelation = observer(class PageMainRelation extends React.Component
<ListObject
ref={ref => 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}
/>
</div>
</div>

View file

@ -73,9 +73,6 @@ const PageMainType = observer(class PageMainType extends React.Component<I.PageC
const subIdObject = this.getSubIdObject();
const totalObject = S.Record.getMeta(subIdObject, '').total;
const totalTemplate = templates.length + (allowedTemplate ? 1 : 0);
const filtersObject: I.Filter[] = [
{ relationKey: 'spaceId', condition: I.FilterCondition.Equal, value: this.getSpaceId() },
];
if (!recommendedRelations.includes('rel-description')) {
recommendedRelations.push('rel-description');
@ -217,10 +214,10 @@ const PageMainType = observer(class PageMainType extends React.Component<I.PageC
<ListObject
{...this.props}
sources={[ rootId ]}
spaceId={this.getSpaceId()}
subId={subIdObject}
rootId={rootId}
columns={columns}
filters={filtersObject}
relationKeys={recommendedKeys}
/>
</div>
@ -281,16 +278,15 @@ const PageMainType = observer(class PageMainType extends React.Component<I.PageC
const rootId = this.getRootId();
U.Data.searchSubscribe({
spaceId: this.getSpaceId(),
subId: this.getSubIdTemplate(),
filters: [
{ relationKey: 'spaceId', condition: I.FilterCondition.Equal, value: this.getSpaceId() },
{ relationKey: 'targetObjectType', condition: I.FilterCondition.Equal, value: rootId },
],
sorts: [
{ relationKey: 'lastModifiedDate', type: I.SortType.Desc },
],
keys: [ 'id' ],
ignoreWorkspace: true,
ignoreDeleted: true,
});
};

View file

@ -116,13 +116,12 @@ const PopupInviteConfirm = observer(class PopupInviteConfirm extends React.Compo
load () {
U.Data.search({
spaceId: this.getSpaceId(),
keys: U.Data.participantRelationKeys(),
filters: [
{ relationKey: 'layout', condition: I.FilterCondition.Equal, value: I.ObjectLayout.Participant },
{ relationKey: 'spaceId', condition: I.FilterCondition.Equal, value: this.getSpaceId() },
],
ignoreHidden: false,
ignoreWorkspace: true,
ignoreDeleted: true,
noDeps: true,
}, (message: any) => {

View file

@ -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;
};

View file

@ -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;

View file

@ -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);

View file

@ -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<I.Popup> {
thumbs = null;
galleryMap: Map<number, any> = 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<I.Popup> {
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<I.Popup> {
return (
<div id="wrap" className="wrap">
<div className="galleryHeader">
{this.current ? (
<div className="head">
<div className="side left">
</div>
{current ? (
<React.Fragment>
<div className="side left" />
<div className="side center">
<ObjectName object={this.current} />
<ObjectName object={current} />
</div>
<div className="side right">
<Icon id="button-header-more" tooltip={translate('commonMenu')} className="more" onClick={this.onMore} />
</div>
</div>
</React.Fragment>
) : ''}
</div>
@ -86,7 +94,7 @@ class PopupPreview extends React.Component<I.Popup> {
<Swiper
onSwiper={swiper => 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<I.Popup> {
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) => (
<SwiperSlide key={i}>
<SwiperSlide key={i} onClick={() => close()}>
{getContent(item, i)}
</SwiperSlide>
))}
@ -111,7 +119,7 @@ class PopupPreview extends React.Component<I.Popup> {
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<I.Popup> {
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<I.Popup> {
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<I.Popup> {
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;
};

View file

@ -589,7 +589,6 @@ const PopupSearch = observer(class PopupSearch extends React.Component<I.Popup,
const filters: any[] = [
{ relationKey: 'layout', condition: I.FilterCondition.NotIn, value: U.Object.getSystemLayouts() },
{ relationKey: 'type', condition: I.FilterCondition.NotEqual, value: templateType?.id },
{ relationKey: 'spaceId', condition: I.FilterCondition.Equal, value: space }
];
const sorts = [
{ relationKey: 'lastOpenedDate', type: I.SortType.Desc },
@ -611,7 +610,7 @@ const PopupSearch = observer(class PopupSearch extends React.Component<I.Popup,
this.setState({ isLoading: true });
};
C.ObjectSearchWithMeta(filters, sorts, J.Relation.default.concat([ 'links', 'backlinks', '_score' ]), filter, this.offset, limit, (message) => {
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;

View file

@ -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 () {

View file

@ -64,6 +64,10 @@ const WidgetButtons = observer(class WidgetSpace extends React.Component<I.Widge
ret.unshift({ id: 'member', name: translate('commonMembers') });
};
if (space.spaceMainChatId) {
ret.push({ id: 'chat', name: translate('commonMainChat') });
};
return ret;
};
@ -71,6 +75,8 @@ const WidgetButtons = observer(class WidgetSpace extends React.Component<I.Widge
e.preventDefault();
e.stopPropagation();
const space = U.Space.getSpaceview();
switch (item.id) {
case 'member': {
S.Popup.open('settings', { data: { page: 'spaceShare', isSpace: true }, className: 'isSpace' });
@ -81,6 +87,11 @@ const WidgetButtons = observer(class WidgetSpace extends React.Component<I.Widge
sidebar.objectContainerToggle();
break;
};
case 'chat': {
U.Object.openAuto({ id: space.spaceMainChatId, layout: I.ObjectLayout.Chat });
break;
};
};
};

View file

@ -19,6 +19,7 @@ export interface AccountInfo {
deviceId: string;
localStoragePath: string;
accountSpaceId: string;
techSpaceId: string;
spaceViewId: string;
widgetsId: string;
analyticsId: string;

View file

@ -212,12 +212,20 @@ class Action {
analytics.event('DownloadMedia', { route });
};
openFileDialog (extensions: string[], callBack?: (paths: string[]) => 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;

View file

@ -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);

View file

@ -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;

View file

@ -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(),

View file

@ -101,7 +101,6 @@ class Dataview {
keys: J.Relation.default,
offset: 0,
limit: 0,
ignoreWorkspace: false,
sources: [],
clear: false,
collectionId: '',

View file

@ -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) {

View file

@ -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');
};
});
});
};

View file

@ -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_));
};
});
};

View file

@ -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;

View file

@ -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,

View file

@ -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();
export const Detail: DetailStore = new DetailStore();