mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 06:05:24 +00:00
fix: add a neutral linked desktop hook for plugins (#1580)
This commit is contained in:
1 parent
b0f2213b15
commit
e284c95891
4 files changed
+23
-1
No files matched your search
@@ -584,6 +584,7 @@ useChooseTheme (value): () => (themeId: string) => void
|
|||||||
useConfirm (value): () => (options: ConfirmOptions) => Promise<boolean>
|
useConfirm (value): () => (options: ConfirmOptions) => Promise<boolean>
|
||||||
useConnectionGate (value): () => ConnectionGateController
|
useConnectionGate (value): () => ConnectionGateController
|
||||||
useConnectionLog (value): () => ConnectionLogContextType
|
useConnectionLog (value): () => ConnectionLogContextType
|
||||||
|
useDesktopLinked (value): () => boolean
|
||||||
useDesktopUpdate (value): () => DesktopUpdateState
|
useDesktopUpdate (value): () => DesktopUpdateState
|
||||||
useEditorDefaultKeys (value): () => Map<string, EditorDefaultKey>
|
useEditorDefaultKeys (value): () => Map<string, EditorDefaultKey>
|
||||||
useHostActions (value): () => HostActionDef[]
|
useHostActions (value): () => HostActionDef[]
|
||||||
|
|||||||
@@ -605,6 +605,7 @@ const ALLOWED = [
|
|||||||
"useConfirm",
|
"useConfirm",
|
||||||
"useConnectionGate",
|
"useConnectionGate",
|
||||||
"useConnectionLog",
|
"useConnectionLog",
|
||||||
|
"useDesktopLinked",
|
||||||
"useDesktopUpdate",
|
"useDesktopUpdate",
|
||||||
"useEditorDefaultKeys",
|
"useEditorDefaultKeys",
|
||||||
"useHostActions",
|
"useHostActions",
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { useEffect, useState } from "react";
|
||||||
import { isElectron } from "@/lib/electron";
|
import { isElectron } from "@/lib/electron";
|
||||||
import { authApi } from "@/main-axios";
|
import { authApi } from "@/main-axios";
|
||||||
import { SYNC_CHANGED_EVENT } from "@/lib/sync-events";
|
import { SYNC_CHANGED_EVENT } from "@/lib/sync-events";
|
||||||
@@ -48,3 +49,22 @@ export function notifySyncChanged(): void {
|
|||||||
cached = null;
|
cached = null;
|
||||||
window.dispatchEvent(new CustomEvent(SYNC_CHANGED_EVENT));
|
window.dispatchEvent(new CustomEvent(SYNC_CHANGED_EVENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Whether this desktop is linked to a server, kept current as it changes. */
|
||||||
|
export function useDesktopLinked(): boolean {
|
||||||
|
const [linked, setLinked] = useState(false);
|
||||||
|
useEffect(() => {
|
||||||
|
let live = true;
|
||||||
|
const read = () =>
|
||||||
|
void getLinkedSession().then((session) => {
|
||||||
|
if (live) setLinked(!!session);
|
||||||
|
});
|
||||||
|
read();
|
||||||
|
window.addEventListener(SYNC_CHANGED_EVENT, read);
|
||||||
|
return () => {
|
||||||
|
live = false;
|
||||||
|
window.removeEventListener(SYNC_CHANGED_EVENT, read);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
return linked;
|
||||||
|
}
|
||||||
@@ -574,7 +574,7 @@ export {
|
|||||||
invalidateServerStatusCache,
|
invalidateServerStatusCache,
|
||||||
} from "@/lib/hosts-request-cache";
|
} from "@/lib/hosts-request-cache";
|
||||||
export { reportBetaFeedbackUrl, reportCoreIssueUrl } from "@/lib/issue-url";
|
export { reportBetaFeedbackUrl, reportCoreIssueUrl } from "@/lib/issue-url";
|
||||||
export { notifySyncChanged } from "@/lib/linked-server";
|
export { notifySyncChanged, useDesktopLinked } from "@/lib/linked-server";
|
||||||
export {
|
export {
|
||||||
clearLocalAdaptivePreferences,
|
clearLocalAdaptivePreferences,
|
||||||
getPreferredHostAction,
|
getPreferredHostAction,
|
||||||
|
|||||||
Reference in new issue
Block a user