Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: fix web rz failed #1541

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ declare module 'nora-zmodemjs/src/zmodem_browser' {
export class Browser {
static send_files(
session: ZmodemSession,
files: File,
files: File[],
opts?: {
on_offer_response?: (obj: any, xfer: ZmodemTransfer) => void;
on_file_complete?: (obj: any) => void;
Expand Down
13 changes: 3 additions & 10 deletions ui/src/hooks/useZsentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,9 @@ export const useSentry = (lastSendTime?: Ref<Date>, t?: any): IUseSentry => {
}

if (!zmodeSession.value) return;

ZmodemBrowser.Browser.send_files(zmodeSession.value, selectFile.file as File, {
const files = fileList.value.map(item => item.file as File);
ZmodemBrowser.Browser.send_files(zmodeSession.value, files, {
on_offer_response: (_obj: any, xfer: ZmodemTransfer) => {
console.log('_obj', _obj);
console.log('xfer', xfer);

if (xfer) {
xfer.on('send_progress', (percent: number) => {
updateSendProgress(xfer, percent);
Expand All @@ -87,7 +84,7 @@ export const useSentry = (lastSendTime?: Ref<Date>, t?: any): IUseSentry => {
}
})
.then(() => {
console.log('then');
zmodeSession.value?.close();
})
.catch((e: Error) => {
console.log(e);
Expand Down Expand Up @@ -168,7 +165,6 @@ export const useSentry = (lastSendTime?: Ref<Date>, t?: any): IUseSentry => {
zmodeSession.value = zsession;

zsession.on('session_end', () => {
console.log('end');
zmodeSession.value = null;
fileList.value = [];
terminal.write('\r\n');
Expand Down Expand Up @@ -242,8 +238,6 @@ export const useSentry = (lastSendTime?: Ref<Date>, t?: any): IUseSentry => {
return debug('WebSocket Closed');
}

console.log(wsIsActivated(ws));

try {
lastSendTime && (lastSendTime.value = new Date());
ws.send(new Uint8Array(octets));
Expand All @@ -261,7 +255,6 @@ export const useSentry = (lastSendTime?: Ref<Date>, t?: any): IUseSentry => {

// @ts-ignore
if (!zsession._accepted_offer) {
console.log('2', zsession);
handleSendSession(zsession, terminal);
} else {
handleReceiveSession(zsession, terminal);
Expand Down