Fixed the channel file transfer side bar
parent
57d5faa151
commit
4e01d1e6e0
|
@ -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 {
|
||||
|
|
|
@ -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 });
|
||||
}
|
||||
}
|
|
@ -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<FileBrowserEvents>,
|
||||
browserEvents: IpcRegistryDescription<FileBrowserEvents>,
|
||||
channelId: number
|
||||
},
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<ChannelFileBrowserU
|
|||
props.events.fire("query_events");
|
||||
return undefined;
|
||||
});
|
||||
|
||||
props.events.reactUse("notify_events", event => setEvents({
|
||||
events: event.browserEvents,
|
||||
events: Registry.fromIpcDescription(event.browserEvents),
|
||||
channelId: event.channelId
|
||||
}));
|
||||
|
||||
useEffect(() => () => events?.events?.destroy(), [ events?.events ]);
|
||||
|
||||
if(!events) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -132,7 +132,6 @@ export interface FileBrowserEvents {
|
|||
path: string,
|
||||
status: "success" | "timeout" | "error";
|
||||
error?: string;
|
||||
pathInfo?: PathInfo
|
||||
},
|
||||
|
||||
notify_transfer_start: {
|
||||
|
|
|
@ -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<Variables extends UiVariableMap> extends UiVariableProvider<Variables> {
|
||||
readonly ipcChannelId: string;
|
||||
private readonly bundleMaxSize: number;
|
||||
|
@ -72,7 +87,7 @@ export class IpcUiVariableProvider<Variables extends UiVariableMap> 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<Variables extends UiVariableMap> 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<Variables extends UiVariableMap> extends UiVa
|
|||
return;
|
||||
}
|
||||
|
||||
this.broadcastChannel.postMessage({
|
||||
savePostMessage(this.broadcastChannel, {
|
||||
type: "bundled",
|
||||
messages: this.enqueuedMessages
|
||||
});
|
||||
|
@ -253,7 +268,7 @@ class IpcUiVariableConsumer<Variables extends UiVariableMap> 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<Variables extends UiVariableMap> extends UiVariableC
|
|||
return;
|
||||
}
|
||||
|
||||
this.broadcastChannel.postMessage({
|
||||
savePostMessage(this.broadcastChannel, {
|
||||
type: "bundled",
|
||||
messages: this.enqueuedMessages
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue