mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-09-09 20:27:05 +00:00
21 lines
777 B
TypeScript
21 lines
777 B
TypeScript
import { ConnectionStringParser } from "@vrtmrz/livesync-commonlib/compat/common/ConnectionString";
|
|
import {
|
|
REMOTE_P2P,
|
|
type ObsidianLiveSyncSettings,
|
|
} from "@vrtmrz/livesync-commonlib/compat/common/types";
|
|
|
|
/** Returns whether the selected main remote represents the P2P-only setup. */
|
|
export function isP2PMainRemote(settings: ObsidianLiveSyncSettings): boolean {
|
|
if (settings.remoteType === REMOTE_P2P) return true;
|
|
|
|
const activeId = settings.activeConfigurationId?.trim();
|
|
const activeConfiguration = activeId ? settings.remoteConfigurations?.[activeId] : undefined;
|
|
if (!activeConfiguration) return false;
|
|
|
|
try {
|
|
return ConnectionStringParser.parse(activeConfiguration.uri).type === "p2p";
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|