diff --git a/shared/js/ui/AppController.ts b/shared/js/ui/AppController.ts index c58eed9f..8b2d9710 100644 --- a/shared/js/ui/AppController.ts +++ b/shared/js/ui/AppController.ts @@ -9,12 +9,11 @@ import {initializeConnectionListController} from "tc-shared/ui/frames/connection import * as loader from "tc-loader"; import {Stage} from "tc-loader"; import {server_connections} from "tc-shared/ConnectionManager"; -import {AppUiEvents, AppUiVariables} from "tc-shared/ui/AppDefinitions"; +import {AppUiVariables} from "tc-shared/ui/AppDefinitions"; import {ConnectionHandler} from "tc-shared/ConnectionHandler"; import {SideBarController} from "tc-shared/ui/frames/SideBarController"; import {ServerEventLogController} from "tc-shared/ui/frames/log/Controller"; import {HostBannerController} from "tc-shared/ui/frames/HostBannerController"; -import {UiVariableProvider} from "tc-shared/ui/utils/Variable"; import {createIpcUiVariableProvider, IpcUiVariableProvider} from "tc-shared/ui/utils/IpcVariable"; export class AppController { diff --git a/shared/js/ui/frames/side/ChannelFileBrowserController.ts b/shared/js/ui/frames/side/ChannelFileBrowserController.ts index 49de6cd2..a8c37913 100644 --- a/shared/js/ui/frames/side/ChannelFileBrowserController.ts +++ b/shared/js/ui/frames/side/ChannelFileBrowserController.ts @@ -59,6 +59,6 @@ export class ChannelFileBrowserController { } private notifyEvents() { - this.uiEvents.fire_react("notify_events", { browserEvents: this.remoteBrowseEvents, channelId: this.currentChannel?.channelId }); + this.uiEvents.fire_react("notify_events", { browserEvents: this.remoteBrowseEvents.generateIpcDescription(), channelId: this.currentChannel?.channelId }); } } \ No newline at end of file diff --git a/shared/js/ui/frames/side/ChannelFileBrowserDefinitions.ts b/shared/js/ui/frames/side/ChannelFileBrowserDefinitions.ts index aba7fb8d..b3c7fd5b 100644 --- a/shared/js/ui/frames/side/ChannelFileBrowserDefinitions.ts +++ b/shared/js/ui/frames/side/ChannelFileBrowserDefinitions.ts @@ -1,11 +1,11 @@ import {FileBrowserEvents} from "tc-shared/ui/modal/transfer/FileDefinitions"; -import {Registry} from "tc-shared/events"; +import {IpcRegistryDescription} from "tc-shared/events"; export interface ChannelFileBrowserUiEvents { query_events: {}, notify_events: { - browserEvents: Registry, + browserEvents: IpcRegistryDescription, channelId: number }, } \ No newline at end of file diff --git a/shared/js/ui/frames/side/ChannelFileBrowserRenderer.scss b/shared/js/ui/frames/side/ChannelFileBrowserRenderer.scss index 063bb556..8415200a 100644 --- a/shared/js/ui/frames/side/ChannelFileBrowserRenderer.scss +++ b/shared/js/ui/frames/side/ChannelFileBrowserRenderer.scss @@ -6,7 +6,7 @@ height: 100%; width: 100%; - color: #999; + color: #999!important; .navbar { flex-shrink: 0; @@ -17,13 +17,13 @@ } .fileTable { - border: none; - border-radius: 0; + border: none!important; + border-radius: 0!important; - background-color: var(--chat-background); + background-color: var(--chat-background)!important; .header { - background-color: var(--chat-background); + background-color: var(--chat-background)!important; } } @@ -36,10 +36,10 @@ } .boxedInput { - background-color: var(--side-info-background); - border-color: #212121; + background-color: var(--side-info-background)!important; + border-color: #212121!important; &:focus-within { - background-color: #242424; + background-color: #242424!important; } } \ No newline at end of file diff --git a/shared/js/ui/frames/side/ChannelFileBrowserRenderer.tsx b/shared/js/ui/frames/side/ChannelFileBrowserRenderer.tsx index 48fe6e83..5607a607 100644 --- a/shared/js/ui/frames/side/ChannelFileBrowserRenderer.tsx +++ b/shared/js/ui/frames/side/ChannelFileBrowserRenderer.tsx @@ -1,5 +1,5 @@ import * as React from "react"; -import {useState} from "react"; +import {useEffect, useState} from "react"; import {Registry} from "tc-shared/events"; import {ChannelFileBrowserUiEvents} from "tc-shared/ui/frames/side/ChannelFileBrowserDefinitions"; import {channelPathPrefix, FileBrowserEvents} from "tc-shared/ui/modal/transfer/FileDefinitions"; @@ -32,11 +32,14 @@ export const ChannelFileBrowser = (props: { events: Registry setEvents({ - events: event.browserEvents, + events: Registry.fromIpcDescription(event.browserEvents), channelId: event.channelId })); + useEffect(() => () => events?.events?.destroy(), [ events?.events ]); + if(!events) { return null; } diff --git a/shared/js/ui/modal/transfer/FileBrowserControllerRemote.ts b/shared/js/ui/modal/transfer/FileBrowserControllerRemote.ts index 6dd9d5bf..dd7485b2 100644 --- a/shared/js/ui/modal/transfer/FileBrowserControllerRemote.ts +++ b/shared/js/ui/modal/transfer/FileBrowserControllerRemote.ts @@ -80,16 +80,14 @@ export function initializeRemoteFileBrowserController(connection: ConnectionHand events.on("action_navigate_to", event => { try { - const info = parsePath(event.path, connection); - currentPathInfo = info; + currentPathInfo = parsePath(event.path, connection); currentPath = event.path; selection = []; events.fire_react("notify_current_path", { path: event.path || "/", status: "success", - pathInfo: info }); } catch (error) { events.fire_react("notify_current_path", { @@ -382,7 +380,6 @@ export function initializeRemoteFileBrowserController(connection: ConnectionHand events.on("query_current_path", () => events.fire_react("notify_current_path", { status: "success", path: currentPath, - pathInfo: currentPathInfo })); events.on("action_rename_file_result", result => { diff --git a/shared/js/ui/modal/transfer/FileDefinitions.ts b/shared/js/ui/modal/transfer/FileDefinitions.ts index 7342c624..9710dd78 100644 --- a/shared/js/ui/modal/transfer/FileDefinitions.ts +++ b/shared/js/ui/modal/transfer/FileDefinitions.ts @@ -132,7 +132,6 @@ export interface FileBrowserEvents { path: string, status: "success" | "timeout" | "error"; error?: string; - pathInfo?: PathInfo }, notify_transfer_start: { diff --git a/shared/js/ui/utils/IpcVariable.ts b/shared/js/ui/utils/IpcVariable.ts index e2c8e602..181e40a4 100644 --- a/shared/js/ui/utils/IpcVariable.ts +++ b/shared/js/ui/utils/IpcVariable.ts @@ -28,6 +28,21 @@ function registerInvokeCallback(callback: () => void) { } } +function savePostMessage(channel: BroadcastChannel | MessageEventSource, message: any) { + try { + // @ts-ignore + channel.postMessage(message); + } catch (error) { + if(error instanceof Error) { + debugger; + console.error(error); + return; + } + + throw error; + } +} + export class IpcUiVariableProvider extends UiVariableProvider { readonly ipcChannelId: string; private readonly bundleMaxSize: number; @@ -72,7 +87,7 @@ export class IpcUiVariableProvider extends UiVa const sendResult = (error?: any) => { if(source) { // @ts-ignore - source.postMessage({ + savePostMessage(source, { type: "edit-result", token, error @@ -124,7 +139,7 @@ export class IpcUiVariableProvider extends UiVa */ private broadcastIpcMessage(message: any) { if(this.bundleMaxSize <= 0) { - this.broadcastChannel.postMessage(message); + savePostMessage(this.broadcastChannel, message); return; } @@ -145,7 +160,7 @@ export class IpcUiVariableProvider extends UiVa return; } - this.broadcastChannel.postMessage({ + savePostMessage(this.broadcastChannel, { type: "bundled", messages: this.enqueuedMessages }); @@ -253,7 +268,7 @@ class IpcUiVariableConsumer extends UiVariableC */ private sendIpcMessage(message: any) { if(this.bundleMaxSize <= 0) { - this.broadcastChannel.postMessage(message); + savePostMessage(this.broadcastChannel, message); return; } @@ -274,7 +289,7 @@ class IpcUiVariableConsumer extends UiVariableC return; } - this.broadcastChannel.postMessage({ + savePostMessage(this.broadcastChannel, { type: "bundled", messages: this.enqueuedMessages });