import {createErrorModal} from "tc-shared/ui/elements/Modal"; import * as electron from "electron"; import {tr, tra} from "tc-shared/i18n/localize"; import {server_connections} from "tc-shared/ui/frames/connection_handlers"; import {handle_connect_request} from "tc-shared/main"; electron.ipcRenderer.on('connect', (event, url) => handle_native_connect_request(url)); function handle_native_connect_request(url_string: string) { console.log(tr("Received connect event to %s"), url_string); if(!url_string.toLowerCase().startsWith("teaclient://")) { createErrorModal(tr("Failed to parse connect URL"), tra("Failed to parse connect URL (Unknown protocol).{:br:}URL: {}", url_string)).open(); return; } let url: URL; try { url = new URL("https://" + url_string.substring(10)); } catch(error) { createErrorModal(tr("Failed to parse connect URL"), tra("Failed to parse connect URL.{:br:}URL: {}", url_string)).open(); return; } let connection = server_connections.active_connection_handler(); if(connection.connected) connection = server_connections.spawn_server_connection_handler(); handle_connect_request({ address: url.host, password: { value: url.password, hashed: (url.searchParams.get("password_raw") || "0") == "0" }, profile: url.searchParams.get("profile"), username: url.searchParams.get("username") }, connection) }