Fixed the channel file transfer side bar

master
WolverinDEV 2021-06-10 16:43:30 +02:00
parent 57d5faa151
commit 4e01d1e6e0
8 changed files with 38 additions and 25 deletions

View File

@ -9,12 +9,11 @@ import {initializeConnectionListController} from "tc-shared/ui/frames/connection
import * as loader from "tc-loader"; import * as loader from "tc-loader";
import {Stage} from "tc-loader"; import {Stage} from "tc-loader";
import {server_connections} from "tc-shared/ConnectionManager"; 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 {ConnectionHandler} from "tc-shared/ConnectionHandler";
import {SideBarController} from "tc-shared/ui/frames/SideBarController"; import {SideBarController} from "tc-shared/ui/frames/SideBarController";
import {ServerEventLogController} from "tc-shared/ui/frames/log/Controller"; import {ServerEventLogController} from "tc-shared/ui/frames/log/Controller";
import {HostBannerController} from "tc-shared/ui/frames/HostBannerController"; 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"; import {createIpcUiVariableProvider, IpcUiVariableProvider} from "tc-shared/ui/utils/IpcVariable";
export class AppController { export class AppController {

View File

@ -59,6 +59,6 @@ export class ChannelFileBrowserController {
} }
private notifyEvents() { 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 });
} }
} }

View File

@ -1,11 +1,11 @@
import {FileBrowserEvents} from "tc-shared/ui/modal/transfer/FileDefinitions"; import {FileBrowserEvents} from "tc-shared/ui/modal/transfer/FileDefinitions";
import {Registry} from "tc-shared/events"; import {IpcRegistryDescription} from "tc-shared/events";
export interface ChannelFileBrowserUiEvents { export interface ChannelFileBrowserUiEvents {
query_events: {}, query_events: {},
notify_events: { notify_events: {
browserEvents: Registry<FileBrowserEvents>, browserEvents: IpcRegistryDescription<FileBrowserEvents>,
channelId: number channelId: number
}, },
} }

View File

@ -6,7 +6,7 @@
height: 100%; height: 100%;
width: 100%; width: 100%;
color: #999; color: #999!important;
.navbar { .navbar {
flex-shrink: 0; flex-shrink: 0;
@ -17,13 +17,13 @@
} }
.fileTable { .fileTable {
border: none; border: none!important;
border-radius: 0; border-radius: 0!important;
background-color: var(--chat-background); background-color: var(--chat-background)!important;
.header { .header {
background-color: var(--chat-background); background-color: var(--chat-background)!important;
} }
} }
@ -36,10 +36,10 @@
} }
.boxedInput { .boxedInput {
background-color: var(--side-info-background); background-color: var(--side-info-background)!important;
border-color: #212121; border-color: #212121!important;
&:focus-within { &:focus-within {
background-color: #242424; background-color: #242424!important;
} }
} }

View File

@ -1,5 +1,5 @@
import * as React from "react"; import * as React from "react";
import {useState} from "react"; import {useEffect, useState} from "react";
import {Registry} from "tc-shared/events"; import {Registry} from "tc-shared/events";
import {ChannelFileBrowserUiEvents} from "tc-shared/ui/frames/side/ChannelFileBrowserDefinitions"; import {ChannelFileBrowserUiEvents} from "tc-shared/ui/frames/side/ChannelFileBrowserDefinitions";
import {channelPathPrefix, FileBrowserEvents} from "tc-shared/ui/modal/transfer/FileDefinitions"; 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"); props.events.fire("query_events");
return undefined; return undefined;
}); });
props.events.reactUse("notify_events", event => setEvents({ props.events.reactUse("notify_events", event => setEvents({
events: event.browserEvents, events: Registry.fromIpcDescription(event.browserEvents),
channelId: event.channelId channelId: event.channelId
})); }));
useEffect(() => () => events?.events?.destroy(), [ events?.events ]);
if(!events) { if(!events) {
return null; return null;
} }

View File

@ -80,16 +80,14 @@ export function initializeRemoteFileBrowserController(connection: ConnectionHand
events.on("action_navigate_to", event => { events.on("action_navigate_to", event => {
try { try {
const info = parsePath(event.path, connection);
currentPathInfo = info; currentPathInfo = parsePath(event.path, connection);
currentPath = event.path; currentPath = event.path;
selection = []; selection = [];
events.fire_react("notify_current_path", { events.fire_react("notify_current_path", {
path: event.path || "/", path: event.path || "/",
status: "success", status: "success",
pathInfo: info
}); });
} catch (error) { } catch (error) {
events.fire_react("notify_current_path", { 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", { events.on("query_current_path", () => events.fire_react("notify_current_path", {
status: "success", status: "success",
path: currentPath, path: currentPath,
pathInfo: currentPathInfo
})); }));
events.on("action_rename_file_result", result => { events.on("action_rename_file_result", result => {

View File

@ -132,7 +132,6 @@ export interface FileBrowserEvents {
path: string, path: string,
status: "success" | "timeout" | "error"; status: "success" | "timeout" | "error";
error?: string; error?: string;
pathInfo?: PathInfo
}, },
notify_transfer_start: { notify_transfer_start: {

View File

@ -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> { export class IpcUiVariableProvider<Variables extends UiVariableMap> extends UiVariableProvider<Variables> {
readonly ipcChannelId: string; readonly ipcChannelId: string;
private readonly bundleMaxSize: number; private readonly bundleMaxSize: number;
@ -72,7 +87,7 @@ export class IpcUiVariableProvider<Variables extends UiVariableMap> extends UiVa
const sendResult = (error?: any) => { const sendResult = (error?: any) => {
if(source) { if(source) {
// @ts-ignore // @ts-ignore
source.postMessage({ savePostMessage(source, {
type: "edit-result", type: "edit-result",
token, token,
error error
@ -124,7 +139,7 @@ export class IpcUiVariableProvider<Variables extends UiVariableMap> extends UiVa
*/ */
private broadcastIpcMessage(message: any) { private broadcastIpcMessage(message: any) {
if(this.bundleMaxSize <= 0) { if(this.bundleMaxSize <= 0) {
this.broadcastChannel.postMessage(message); savePostMessage(this.broadcastChannel, message);
return; return;
} }
@ -145,7 +160,7 @@ export class IpcUiVariableProvider<Variables extends UiVariableMap> extends UiVa
return; return;
} }
this.broadcastChannel.postMessage({ savePostMessage(this.broadcastChannel, {
type: "bundled", type: "bundled",
messages: this.enqueuedMessages messages: this.enqueuedMessages
}); });
@ -253,7 +268,7 @@ class IpcUiVariableConsumer<Variables extends UiVariableMap> extends UiVariableC
*/ */
private sendIpcMessage(message: any) { private sendIpcMessage(message: any) {
if(this.bundleMaxSize <= 0) { if(this.bundleMaxSize <= 0) {
this.broadcastChannel.postMessage(message); savePostMessage(this.broadcastChannel, message);
return; return;
} }
@ -274,7 +289,7 @@ class IpcUiVariableConsumer<Variables extends UiVariableMap> extends UiVariableC
return; return;
} }
this.broadcastChannel.postMessage({ savePostMessage(this.broadcastChannel, {
type: "bundled", type: "bundled",
messages: this.enqueuedMessages messages: this.enqueuedMessages
}); });