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

JS-2377: fix + refactoring

This commit is contained in:
Andrew Simachev 2025-02-25 14:27:44 +01:00
parent d337171226
commit 012a60b78b
No known key found for this signature in database
GPG key ID: 1DFE44B21443F0EF
13 changed files with 60 additions and 34 deletions

View file

@ -40,7 +40,7 @@ const PageAuthDeleted = observer(forwardRef<{}, I.PageComponent>(() => {
const onCancel = () => {
C.AccountRevertDeletion((message) => {
S.Auth.accountSetStatus(message.status);
U.Space.openDashboard('route');
U.Space.openDashboard();
analytics.event('CancelDeletion');
});
};

View file

@ -31,7 +31,7 @@ const PageAuthPinCheck = observer(forwardRef<{}, I.PageComponent>(() => {
keyboard.setPinChecked(true);
if (account) {
redirect ? U.Router.go(redirect, routeParam) : U.Space.openDashboard('route', routeParam);
redirect ? U.Router.go(redirect, routeParam) : U.Space.openDashboard(routeParam);
} else {
U.Router.go('/', routeParam);
};

View file

@ -24,7 +24,7 @@ const PageMainImport = forwardRef<{}, I.PageComponent>((props, ref) => {
if (message.error.code) {
setError(message.error.description);
} else {
U.Space.openDashboard('route');
U.Space.openDashboard();
window.setTimeout(() => {
S.Popup.open('usecase', {
@ -53,7 +53,7 @@ const PageMainImport = forwardRef<{}, I.PageComponent>((props, ref) => {
text={translate('commonBack')}
color="blank"
className="c36"
onClick={() => U.Space.openDashboard('route')}
onClick={() => U.Space.openDashboard()}
/>
</div>
) : <Loader />}

View file

@ -29,7 +29,7 @@ const PageMainInvite = forwardRef<PageMainInviteRefProps, I.PageComponent>((prop
setError(translate('pageMainInviteErrorData'));
} else {
C.SpaceInviteView(data.cid, data.key, (message: any) => {
U.Space.openDashboard('route', { replace: true });
U.Space.openDashboard({ replace: true });
S.Popup.closeAll(null, () => {
const space = U.Space.getSpaceviewBySpaceId(message.spaceId);
@ -118,7 +118,7 @@ const PageMainInvite = forwardRef<PageMainInviteRefProps, I.PageComponent>((prop
text={translate('commonBack')}
color="blank"
className="c36"
onClick={() => U.Space.openDashboard('route')}
onClick={() => U.Space.openDashboard()}
/>
</div>
) : <Loader />}

View file

@ -22,7 +22,7 @@ const PageMainMembership = observer(forwardRef<I.PageRef, I.PageComponent>((prop
return;
};
U.Space.openDashboard('route', {
U.Space.openDashboard({
replace: true,
animate: true,
onFadeIn: () => {
@ -95,7 +95,7 @@ const PageMainMembership = observer(forwardRef<I.PageRef, I.PageComponent>((prop
text={translate('commonBack')}
color="blank"
className="c36"
onClick={() => U.Space.openDashboard('route')}
onClick={() => U.Space.openDashboard()}
/>
</div>
) : <Loader />}

View file

@ -17,7 +17,7 @@ const PageMainObject = forwardRef<{}, I.PageComponent>((props, ref) => {
C.ObjectShow(id, '', spaceId, (message: any) => {
if (message.error.code) {
U.Space.openDashboard('route');
U.Space.openDashboard();
return;
};

View file

@ -28,7 +28,7 @@ const SidebarSettings = observer(class SidebarSettings extends React.Component<P
const onBack = () => {
if (!this.routeBack || !this.routeBack.pathname) {
U.Space.openDashboard('route');
U.Space.openDashboard();
return;
};

View file

@ -1,7 +1,7 @@
import React, { forwardRef, useRef, useEffect, useLayoutEffect } from 'react';
import $ from 'jquery';
import { Icon, Label, Button } from 'Component';
import { S, U, translate } from 'Lib';
import { I, S, U, translate } from 'Lib';
interface Props {
className?: string;
@ -14,7 +14,30 @@ const Deleted = forwardRef<HTMLDivElement, Props>(({
}, ref) => {
const nodeRef = useRef<HTMLDivElement>(null);
const onClick = isPopup ? () => S.Popup.close('page') : () => U.Space.openDashboard('route');
const onClick = () => {
if (isPopup) {
S.Popup.close('page');
} else {
const home = U.Space.getDashboard();
let last = null;
if (home && (home.id == I.HomePredefinedId.Last)) {
last = U.Space.getLastObject();
};
if (last) {
U.Object.getById(home.id, {}, object => {
if (!object || object.isDeleted) {
U.Object.openRoute({ layout: I.ObjectLayout.Empty }, { replace: true });
} else {
U.Space.openDashboard();
};
});
} else {
U.Space.openDashboard();
};
};
};
const textButton = isPopup ? translate('commonClose') : translate('utilDeletedBackToDashboard');
const unbind = () => {

View file

@ -228,7 +228,7 @@ class Keyboard {
// Go to dashboard
this.shortcut('alt+h', e, () => {
if (S.Auth.account && !S.Popup.isOpen('search')) {
U.Space.openDashboard('route');
U.Space.openDashboard();
};
});
@ -346,7 +346,7 @@ class Keyboard {
let prev = history.entries[history.index - 1];
if (account && !prev) {
U.Space.openDashboard('route');
U.Space.openDashboard();
return;
};

View file

@ -589,7 +589,7 @@ class UtilCommon {
};
});
U.Space.openDashboard('route', { replace: true });
U.Space.openDashboard({ replace: true });
}
},
});

View file

@ -188,7 +188,7 @@ class UtilData {
if (route) {
U.Router.go(route, routeParam);
} else {
U.Space.openDashboard('route', routeParam);
U.Space.openDashboard(routeParam);
};
S.Common.redirectSet('');

View file

@ -582,7 +582,7 @@ class UtilMenu {
U.Data.createSubSpaceSubscriptions([ space ], () => {
if (openRoute) {
U.Space.openDashboard('route');
U.Space.openDashboard();
};
});
});

View file

@ -2,11 +2,10 @@ import { I, C, S, U, J, Storage, translate } from 'Lib';
class UtilSpace {
openDashboard (type: string, param?: any) {
openDashboard (param?: any) {
param = param || {};
const space = this.getSpaceview();
const fn = U.Common.toCamelCase(`open-${type}`);
if (!space || space._empty_ || space.isAccountDeleted || !space.isLocalOk) {
this.openFirstSpaceOrVoid(null, param);
@ -14,25 +13,14 @@ class UtilSpace {
};
let home = this.getDashboard();
if (home && (home.id == I.HomePredefinedId.Last)) {
home = Storage.getLastOpened(U.Common.getCurrentElectronWindowId());
// Invalid data protection
if (!home || !home.id) {
home = null;
};
if (home) {
home.spaceId = S.Common.space;
};
home = this.getLastObject();
};
if (!home) {
U.Object.openRoute({ layout: I.ObjectLayout.Empty }, param);
} else
if (U.Object[fn]) {
U.Object[fn](home, param);
} else {
U.Object.openRoute(home, param);
};
};
@ -98,6 +86,21 @@ class UtilSpace {
};
};
getLastObject () {
let home = Storage.getLastOpened(U.Common.getCurrentElectronWindowId());
// Invalid data protection
if (!home || !home.id) {
home = null;
};
if (home) {
home.spaceId = S.Common.space;
};
return home;
};
getChat () {
return {
id: S.Block.workspace,
@ -260,7 +263,7 @@ class UtilSpace {
if (!object._empty_) {
Storage.setLastOpened(U.Common.getCurrentElectronWindowId(), { id: object.id, layout: object.layout });
U.Space.openDashboard('route');
U.Space.openDashboard();
};
};
};