Skip to content

Commit

Permalink
undo changes to client
Browse files Browse the repository at this point in the history
  • Loading branch information
germain-gg committed Jan 6, 2023
1 parent 435f485 commit 2eef226
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,9 @@ interface IJoinRequestBody {
third_party_signed?: IThirdPartySigned;
}

export interface ITagMetadata {
interface ITagMetadata {
[key: string]: any;
order?: number;
order: number;
}

interface IMessagesResponse {
Expand Down
24 changes: 12 additions & 12 deletions src/models/thread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,19 +517,19 @@ export class Thread extends ReadReceipt<EmittedEvents, EventHandlerMap> {

const readUpToId = super.getEventReadUpTo(userId, ignoreSynthesized);

// Checking whether the unthreaded read receipt for that user is more recent
// than the read receipt inside that thread.
if (this.lastReply()) {
if (!this.room.unthreadedReceipts.has(userId)) {
return readUpToId;
}
const isLastTimelineEvent = readUpToId === this.timeline.at(-1)?.getId();
const hasAnUnthreadedReceipt = this.room.unthreadedReceipts.has(userId);
if (isLastTimelineEvent && !hasAnUnthreadedReceipt) {
return readUpToId;
}

const unthreadedReceiptTs = this.room.unthreadedReceipts.get(userId)!.ts;
for (let i = this.timeline?.length - 1; i >= 0; --i) {
const ev = this.timeline[i];
if (ev.getId() === readUpToId) return readUpToId;
if (ev.getTs() < unthreadedReceiptTs) return ev.getId() ?? readUpToId;
}
// Check whether the unthreaded receipt finds a more recent `readUpToId`
// If so, return that value.
const unthreadedReceiptTs = this.room.unthreadedReceipts.get(userId)!.ts;
for (let i = this.timeline?.length - 1; i >= 0; --i) {
const ev = this.timeline[i];
if (ev.getId() === readUpToId) return readUpToId;
if (ev.getTs() < unthreadedReceiptTs) return ev.getId() ?? readUpToId;
}

return readUpToId;
Expand Down

0 comments on commit 2eef226

Please sign in to comment.