fix(web): exception from destructing undefined property (#8374)

This commit is contained in:
Yat Ho
2026-02-06 10:43:09 +08:00
committed by GitHub
parent 80a379f713
commit a628033637

View File

@@ -21,6 +21,10 @@ export const RPC = {
_UpSpeedLimited: 'speed_limit_up_enabled',
};
function getResponseParams(response) {
return response.result ?? response.error.data.result;
}
export class Remote {
_connection_alert = null;
_session_id = '';
@@ -163,8 +167,8 @@ export class Remote {
o.params.ids = torrentIds;
}
this.sendRequest(o, (response) => {
const { torrents, removed } = response.result;
callback.call(context, torrents, removed);
const res = getResponseParams(response);
callback.call(context, res.torrents, res.removed);
});
}
@@ -176,8 +180,8 @@ export class Remote {
params: { path: dir },
};
this.sendRequest(o, (response) => {
const { path, size_bytes } = response.result;
callback.call(context, path, size_bytes);
const res = getResponseParams(response);
callback.call(context, res.path, res.size_bytes);
});
}