Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
fix(renderer/api/nt): don't throw error when no message available
Browse files Browse the repository at this point in the history
  • Loading branch information
FlysoftBeta committed Jun 18, 2023
1 parent 34b6e39 commit 373eb23
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/renderer/api/nt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,23 +251,27 @@ class NT extends (EventEmitter as new () => TypedEmitter<NTEvents>) {
}

async getPreviousMessages(peer: Peer, count: number = 20, startMsgId = "0") {
const msgs = await ntCall(
"ns-ntApi-2",
"nodeIKernelMsgService/getMsgsIncludeSelf",
[
{
peer: destructPeer(peer),
msgId: startMsgId,
cnt: count,
queryOrder: true,
},
undefined,
]
);
const messages = (msgs[1][0].msgList as any[]).map((msg) =>
constructMessage(msg, this.pendingMediaDownloads)
);
return messages;
try {
const msgs = await ntCall(
"ns-ntApi-2",
"nodeIKernelMsgService/getMsgsIncludeSelf",
[
{
peer: destructPeer(peer),
msgId: startMsgId,
cnt: count,
queryOrder: true,
},
undefined,
]
);
const messages = (msgs.msgList as any[]).map((msg) =>
constructMessage(msg, this.pendingMediaDownloads)
);
return messages;
} catch {
return [];
}
}
}

Expand Down

0 comments on commit 373eb23

Please sign in to comment.