Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(desktop/setup): display port in desktop-to-desktop sync
Elian Doran8eb45e28144f
diff --git a/apps/client/src/setup.css b/apps/client/src/setup.cssindex a6bcc24cba..1f678d383b 100644--- a/apps/client/src/setup.css+++ b/apps/client/src/setup.css@@ -304,6 +304,26 @@ body.setup {}}+.page.sync-from-desktop {+ &> main {+ flex-direction: row !important;+ gap: 1.5rem;+ }++ .ip-addresses {+ min-width: 200px;+ user-select: text;+ display: flex;+ flex-direction: column;+ font-family: var(--monospace-font-family);++ .tn-card-body {+ overflow: auto;+ padding-bottom: 0.5em;+ }+ }+}+.page.sync-in-progress {.sync-progress {margin-top: 0.5rem;diff --git a/apps/client/src/setup.tsx b/apps/client/src/setup.tsxindex 1ff3cef43a..1904faf74f 100644--- a/apps/client/src/setup.tsx+++ b/apps/client/src/setup.tsx@@ -51,7 +51,7 @@ function renderState(state: State, setState: (state: State) => void) {}function App() {- const [state, setState] = useState<State>("selectLanguage");+ const [state, setState] = useState<State>("syncFromDesktop");const [prevState, setPrevState] = useState<State | null>(null);const [transitioning, setTransitioning] = useState(false);const prevStateRef = useRef<State>(state);@@ -355,6 +355,8 @@ function SyncFromServer({ setState }: { setState: (state: State) => void }) {}function SyncFromDesktop({ setState }: { setState: (state: State) => void }) {+ const networkAddresses = getNetworkAddresses();+return (<SetupPageclassName="sync-from-desktop"@@ -372,6 +374,14 @@ function SyncFromDesktop({ setState }: { setState: (state: State) => void }) {{t("setup.sync-from-desktop-final")}</Card>++ {networkAddresses.length > 0 && (+ <Card heading={t("setup.your-ip-addresses")} className="ip-addresses">+ {networkAddresses.map((addr) => (+ <CardSection key={addr}>{addr}</CardSection>+ ))}+ </Card>+ )}</SetupPage>);}@@ -455,4 +465,26 @@ function SetupPage({ title, description, className, illustration, children, foot);}+function getNetworkAddresses(): string[] {+ if (!isElectron()) {+ return [];+ }++ // eslint-disable-next-line @typescript-eslint/no-require-imports+ const os = require("os") as typeof import("os");+ const interfaces = os.networkInterfaces();+ const addresses: string[] = [];++ for (const nets of Object.values(interfaces)) {+ if (!nets) continue;+ for (const net of nets) {+ if (net.internal) continue;+ if (net.family === "IPv6" && net.scopeid !== 0) continue;+ addresses.push(net.address);+ }+ }++ return addresses;+}+main();diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 95d056bd86..d511ed5dc2 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -2279,6 +2279,7 @@"dismiss-error": "Dismiss error","wrong-password": "Incorrect password. Please try again.","language": "Language",- "continue": "Continue"+ "continue": "Continue",+ "your-ip-addresses": "Your IP addresses"}}