(null);
+ const cancelRef = useRef(false);
useEffect(() => {
- if (!object?.id || (object?.layout == I.ObjectLayout.SpaceView)) {
- objectRef.current = {};
- setDummy(dummy + 1);
- return;
+ cancelRef.current = false;
+ setDisplayObject(null);
+ setDisplayObjectType(null);
+ load();
+
+ return () => {
+ cancelRef.current = true;
};
+ }, [ object?.id, action, spaceview.targetSpaceId ]);
+
+ useEffect(position);
- let cancelled = false;
+ const load = () => {
+ const isChat = (object?.layout == I.ObjectLayout.SpaceView) && (spaceview.isOneToOne || spaceview.isChat);
- objectRef.current = object;
+ if (isChat) {
+ setDisplayObject({ layout: I.ObjectLayout.Chat, name: translate('commonMainChat') });
+ } else
+ if (action && name) {
+ objectByAction();
+ } else {
+ loadObject();
+ };
+ };
+
+ const objectByAction = () => {
+ const layouts = {
+ navigation: I.ObjectLayout.Navigation,
+ graph: I.ObjectLayout.Graph,
+ archive: I.ObjectLayout.Archive,
+ settings: I.ObjectLayout.Settings,
+ };
+ if (layouts[action]) {
+ setDisplayObject({ layout: layouts[action], name });
+ } else {
+ loadObject();
+ };
+ };
+
+ const loadObject = () => {
+ if (!object || !object.id) {
+ return;
+ };
U.Object.getById(object.id, { spaceId: spaceview.targetSpaceId }, (loaded: any) => {
- if (loaded && !cancelled) {
- objectRef.current = loaded;
- setDummy(dummy + 1);
+ if (loaded && !cancelRef.current) {
+ setDisplayObject(loaded);
+ loadType(loaded.type)
};
});
+ };
- return () => { cancelled = true; };
- }, [ object?.id ]);
-
- useEffect(position);
+ const loadType = (id: string) => {
+ U.Object.getById(id, { spaceId: spaceview.targetSpaceId }, (loaded: any) => {
+ if (loaded && !cancelRef.current) {
+ setDisplayObjectType(loaded);
+ };
+ });
+ };
return (
@@ -49,10 +89,15 @@ const PreviewTab = observer(forwardRef<{}, Props>((props, ref) => {
- {objectRef.current && objectRef.current.name ? (
+ {displayObject?.name ? (
-
-
+
+
+
+
+
+ {displayObjectType ? : ''}
+
) : null}
diff --git a/src/ts/interface/preview.ts b/src/ts/interface/preview.ts
index 24642e7249..6bece30f42 100644
--- a/src/ts/interface/preview.ts
+++ b/src/ts/interface/preview.ts
@@ -39,7 +39,7 @@ export interface Preview {
withPlural?: boolean;
typeX?: I.MenuDirection.Left | I.MenuDirection.Center | I.MenuDirection.Right;
noOffset?: boolean;
- relatedObject?: any;
+ relatedData?: any;
delay?: number;
x?: number;
y?: number;
diff --git a/src/ts/lib/keyboard.ts b/src/ts/lib/keyboard.ts
index ab45cef2ea..269842d086 100644
--- a/src/ts/lib/keyboard.ts
+++ b/src/ts/lib/keyboard.ts
@@ -1369,7 +1369,7 @@ class Keyboard {
if (title) {
U.Data.setWindowTitleText(title);
- U.Data.setTabTitleText(title);
+ U.Data.setTabTitleText(title, action);
} else {
U.Data.setWindowTitle(rootId, rootId);
U.Data.setTabTitle(rootId, rootId);
diff --git a/src/ts/lib/util/common.ts b/src/ts/lib/util/common.ts
index 75b8e986fa..3257f35409 100644
--- a/src/ts/lib/util/common.ts
+++ b/src/ts/lib/util/common.ts
@@ -1581,14 +1581,12 @@ class UtilCommon {
tabTooltipShow (data: any) {
const spaceview = U.Space.getSpaceviewBySpaceId(data.spaceId);
- const x = data.isPinned ? data.offsetLeft : data.offsetLeft + 6;
-
if (!spaceview) {
return;
};
Preview.previewShow({
- rect: { x, y: 2, width: data.width, height: 0 },
+ rect: { x: data.offsetLeft, y: 0, width: data.width, height: 0 },
classNameWrap: 'isTab',
object: spaceview,
target: spaceview.id,
@@ -1598,7 +1596,11 @@ class UtilCommon {
noAnimation: true,
noOffset: true,
typeX: I.MenuDirection.Left,
- relatedObject: data.objectData ? { ...data.objectData, name: data.title } : null,
+ relatedData: {
+ action: data?.action,
+ name: data?.objectName,
+ object: data?.objectData,
+ },
delay: 0,
type: I.PreviewType.Tab,
});
diff --git a/src/ts/lib/util/data.ts b/src/ts/lib/util/data.ts
index 90acdd45b3..79f1b231b9 100644
--- a/src/ts/lib/util/data.ts
+++ b/src/ts/lib/util/data.ts
@@ -866,8 +866,9 @@ class UtilData {
/**
* Sets the tab title text.
* @param {string} text - The text to set as the tab title.
+ * @param {string} action - Optional layout of the current object, useful for tab tooltips.
*/
- setTabTitleText(text: string) {
+ setTabTitleText(text: string, action?: string) {
const spaceview = U.Space.getSpaceview();
Renderer.send('updateTab', S.Common.tabId, {
@@ -876,6 +877,7 @@ class UtilData {
spaceIcon: U.Graph.imageSrc(spaceview) || U.Object.defaultIcon(spaceview?.layout, spaceview?.type, 100),
spaceId: spaceview.targetSpaceId || '',
layout: I.ObjectLayout.Page,
+ action,
});
};
diff --git a/src/ts/lib/util/object.ts b/src/ts/lib/util/object.ts
index 83b7b4766c..e0e14482b0 100644
--- a/src/ts/lib/util/object.ts
+++ b/src/ts/lib/util/object.ts
@@ -117,6 +117,7 @@ class UtilObject {
uxType: spaceview?.uxType,
objectData: { id: object.id, type: object.type, layout: object.layout },
route,
+ action: '',
};
};
@@ -973,6 +974,10 @@ class UtilObject {
case I.ObjectLayout.Date: id = 'date'; break;
case I.ObjectLayout.Type: id = 'type'; break;
case I.ObjectLayout.Bookmark: id = 'page'; break;
+ case I.ObjectLayout.Settings: id = 'settings'; break;
+ case I.ObjectLayout.Graph: id = 'graph'; break;
+ case I.ObjectLayout.Navigation: id = 'graph'; break;
+ case I.ObjectLayout.Archive: id = 'archive'; break;
};
src = U.Common.updateSvg(require(`img/icon/default/${id}.svg`), { id, size, fill: J.Theme[theme].iconDefault });
};