mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-10 10:00:48 +09:00
merge
This commit is contained in:
commit
688a402cd7
9 changed files with 61 additions and 42 deletions
|
@ -221,12 +221,11 @@ const MenuDataviewFileList = observer(class MenuDataviewFileList extends React.C
|
|||
};
|
||||
|
||||
load (clear: boolean, callBack?: (message: any) => void) {
|
||||
const { config } = commonStore;
|
||||
const { param } = this.props;
|
||||
const { data } = param;
|
||||
const { types, filter } = data;
|
||||
const { filter } = data;
|
||||
const filters: I.Filter[] = [
|
||||
{ operator: I.FilterOperator.And, relationKey: 'layout', condition: I.FilterCondition.In, value: [ I.ObjectLayout.File, I.ObjectLayout.Image ] }
|
||||
{ operator: I.FilterOperator.And, relationKey: 'layout', condition: I.FilterCondition.In, value: UtilObject.getFileLayouts() }
|
||||
];
|
||||
const sorts = [
|
||||
{ relationKey: 'name', type: I.SortType.Asc },
|
||||
|
|
|
@ -54,8 +54,7 @@ const MenuDataviewFileValues = observer(class MenuDataviewFileValues extends Rea
|
|||
let content = null;
|
||||
|
||||
switch (item.layout) {
|
||||
default:
|
||||
case I.ObjectLayout.File: {
|
||||
default: {
|
||||
cn.push('isFile');
|
||||
content = <File {...item} />;
|
||||
break;
|
||||
|
@ -167,7 +166,7 @@ const MenuDataviewFileValues = observer(class MenuDataviewFileValues extends Rea
|
|||
noClose: true,
|
||||
placeholderFocus: translate('menuDataviewFileValuesFindAFile'),
|
||||
filters: [
|
||||
{ operator: I.FilterOperator.And, relationKey: 'layout', condition: I.FilterCondition.In, value: [ I.ObjectLayout.File, I.ObjectLayout.Image ] }
|
||||
{ operator: I.FilterOperator.And, relationKey: 'layout', condition: I.FilterCondition.In, value: UtilObject.getFileLayouts() }
|
||||
],
|
||||
onChange: (value: string[], callBack?: () => void) => {
|
||||
this.save(value);
|
||||
|
@ -248,14 +247,17 @@ const MenuDataviewFileValues = observer(class MenuDataviewFileValues extends Rea
|
|||
case 'download': {
|
||||
let url = '';
|
||||
switch (item.layout) {
|
||||
case I.ObjectLayout.File:
|
||||
default: {
|
||||
url = commonStore.fileUrl(item.id);
|
||||
break;
|
||||
};
|
||||
|
||||
case I.ObjectLayout.Image:
|
||||
case I.ObjectLayout.Image: {
|
||||
url = commonStore.imageUrl(item.id, Constant.size.image);
|
||||
break;
|
||||
};
|
||||
};
|
||||
|
||||
if (url) {
|
||||
Renderer.send('download', url);
|
||||
};
|
||||
|
|
|
@ -240,6 +240,14 @@ const IconObject = observer(class IconObject extends React.Component<Props> {
|
|||
break;
|
||||
};
|
||||
|
||||
case I.ObjectLayout.Bookmark: {
|
||||
if (iconImage) {
|
||||
icn = icn.concat([ 'iconCommon', 'c' + iconSize ]);
|
||||
icon = <img src={commonStore.imageUrl(iconImage, iconSize * 2)} className={icn.join(' ')} />;
|
||||
};
|
||||
break;
|
||||
};
|
||||
|
||||
case I.ObjectLayout.Image: {
|
||||
if (id) {
|
||||
cn.push('withImage');
|
||||
|
@ -252,14 +260,8 @@ const IconObject = observer(class IconObject extends React.Component<Props> {
|
|||
break;
|
||||
};
|
||||
|
||||
case I.ObjectLayout.Bookmark: {
|
||||
if (iconImage) {
|
||||
icn = icn.concat([ 'iconCommon', 'c' + iconSize ]);
|
||||
icon = <img src={commonStore.imageUrl(iconImage, iconSize * 2)} className={icn.join(' ')} />;
|
||||
};
|
||||
break;
|
||||
};
|
||||
|
||||
case I.ObjectLayout.Video:
|
||||
case I.ObjectLayout.Audio:
|
||||
case I.ObjectLayout.File: {
|
||||
icn = icn.concat([ 'iconFile', 'c' + iconSize ]);
|
||||
icon = <img src={UtilFile.iconImage(object)} className={icn.join(' ')} />;
|
||||
|
|
|
@ -44,6 +44,8 @@ class Dispatcher {
|
|||
return;
|
||||
};
|
||||
|
||||
window.clearTimeout(this.timeoutStream);
|
||||
|
||||
const request = new Commands.StreamRequest();
|
||||
request.setToken(authStore.token);
|
||||
|
||||
|
@ -60,30 +62,33 @@ class Dispatcher {
|
|||
this.stream.on('status', (status) => {
|
||||
if (status.code) {
|
||||
console.error('[Dispatcher.stream] Restarting', status);
|
||||
this.listenEvents();
|
||||
this.reconnect();
|
||||
};
|
||||
});
|
||||
|
||||
this.stream.on('end', () => {
|
||||
console.error('[Dispatcher.stream] end, restarting');
|
||||
|
||||
let t = 3;
|
||||
if (this.reconnects == 20) {
|
||||
t = 5;
|
||||
};
|
||||
if (this.reconnects == 40) {
|
||||
t = 60;
|
||||
this.reconnects = 0;
|
||||
};
|
||||
|
||||
window.clearTimeout(this.timeoutStream);
|
||||
this.timeoutStream = window.setTimeout(() => {
|
||||
this.listenEvents();
|
||||
this.reconnects++;
|
||||
}, t * 1000);
|
||||
this.reconnect();
|
||||
});
|
||||
};
|
||||
|
||||
reconnect () {
|
||||
let t = 3;
|
||||
if (this.reconnects == 20) {
|
||||
t = 5;
|
||||
};
|
||||
if (this.reconnects == 40) {
|
||||
t = 60;
|
||||
this.reconnects = 0;
|
||||
};
|
||||
|
||||
window.clearTimeout(this.timeoutStream);
|
||||
this.timeoutStream = window.setTimeout(() => {
|
||||
this.listenEvents();
|
||||
this.reconnects++;
|
||||
}, t * 1000);
|
||||
};
|
||||
|
||||
eventType (v: number): string {
|
||||
const V = Events.Event.Message.ValueCase;
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ class UtilData {
|
|||
layoutClass (id: string, layout: I.ObjectLayout) {
|
||||
let c = '';
|
||||
switch (layout) {
|
||||
default: c = UtilCommon.toCamelCase('is-' + I.ObjectLayout[layout]); break;
|
||||
default: c = UtilCommon.toCamelCase(`is-${I.ObjectLayout[layout]}`); break;
|
||||
case I.ObjectLayout.Image: c = (id ? 'isImage' : 'isFile'); break;
|
||||
};
|
||||
return c;
|
||||
|
@ -528,15 +528,16 @@ class UtilData {
|
|||
};
|
||||
|
||||
case I.ObjectLayout.Human:
|
||||
case I.ObjectLayout.Participant:
|
||||
case I.ObjectLayout.Relation:
|
||||
case I.ObjectLayout.File:
|
||||
case I.ObjectLayout.Image: {
|
||||
case I.ObjectLayout.Relation: {
|
||||
ret.withIcon = true;
|
||||
break;
|
||||
};
|
||||
};
|
||||
|
||||
if (UtilObject.isFileLayout(object.layout)) {
|
||||
ret.withIcon = true;
|
||||
};
|
||||
|
||||
if (checkType) {
|
||||
ret.className.push('noSystemBlocks');
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { I, Relation, UtilCommon, UtilFile, UtilSmile } from 'Lib';
|
||||
import { I, Relation, UtilCommon, UtilObject, UtilFile, UtilSmile } from 'Lib';
|
||||
import { commonStore } from 'Store';
|
||||
import Colors from 'json/colors.json';
|
||||
import Theme from 'json/theme.json';
|
||||
|
@ -19,6 +19,8 @@ class UtilGraph {
|
|||
break;
|
||||
};
|
||||
|
||||
case I.ObjectLayout.Audio:
|
||||
case I.ObjectLayout.Video:
|
||||
case I.ObjectLayout.File: {
|
||||
src = UtilFile.iconPath(d);
|
||||
break;
|
||||
|
|
|
@ -262,6 +262,8 @@ class UtilMenu {
|
|||
{ id: I.ObjectLayout.Task },
|
||||
{ id: I.ObjectLayout.Set },
|
||||
{ id: I.ObjectLayout.File },
|
||||
{ id: I.ObjectLayout.Audio },
|
||||
{ id: I.ObjectLayout.Video },
|
||||
{ id: I.ObjectLayout.Image },
|
||||
{ id: I.ObjectLayout.Type },
|
||||
{ id: I.ObjectLayout.Relation },
|
||||
|
|
|
@ -113,16 +113,20 @@ class UtilObject {
|
|||
actionByLayout (v: I.ObjectLayout): string {
|
||||
v = v || I.ObjectLayout.Page;
|
||||
|
||||
if (this.isFileLayout(v)) {
|
||||
return 'media';
|
||||
};
|
||||
|
||||
if (this.isSetLayout(v)) {
|
||||
return 'set';
|
||||
};
|
||||
|
||||
let r = '';
|
||||
switch (v) {
|
||||
default: r = 'edit'; break;
|
||||
case I.ObjectLayout.Date:
|
||||
case I.ObjectLayout.Set:
|
||||
case I.ObjectLayout.Collection: r = 'set'; break;
|
||||
case I.ObjectLayout.Type: r = 'type'; break;
|
||||
case I.ObjectLayout.Relation: r = 'relation'; break;
|
||||
case I.ObjectLayout.File:
|
||||
case I.ObjectLayout.Image: r = 'media'; break;
|
||||
case I.ObjectLayout.Navigation: r = 'navigation'; break;
|
||||
case I.ObjectLayout.Graph: r = 'graph'; break;
|
||||
case I.ObjectLayout.Store: r = 'store'; break;
|
||||
|
|
|
@ -214,6 +214,8 @@ class DetailStore {
|
|||
};
|
||||
|
||||
case I.ObjectLayout.File:
|
||||
case I.ObjectLayout.Audio:
|
||||
case I.ObjectLayout.Video:
|
||||
case I.ObjectLayout.Image: {
|
||||
object = this.mapFile(object);
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue