You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Add debug logging to figure out missing reactions in main timeline (#3494)
* Fix debug logging not working * Add debug logging to figure out missing reactions in main timeline
This commit is contained in:
committed by
GitHub
parent
ca00094e67
commit
8b9672ba43
@@ -38,7 +38,11 @@ log.methodFactory = function (methodName, logLevel, loggerName) {
|
|||||||
}
|
}
|
||||||
/* eslint-enable @typescript-eslint/no-invalid-this */
|
/* eslint-enable @typescript-eslint/no-invalid-this */
|
||||||
const supportedByConsole =
|
const supportedByConsole =
|
||||||
methodName === "error" || methodName === "warn" || methodName === "trace" || methodName === "info";
|
methodName === "error" ||
|
||||||
|
methodName === "warn" ||
|
||||||
|
methodName === "trace" ||
|
||||||
|
methodName === "info" ||
|
||||||
|
methodName === "debug";
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
if (supportedByConsole) {
|
if (supportedByConsole) {
|
||||||
return console[methodName](...args);
|
return console[methodName](...args);
|
||||||
|
|||||||
@@ -2103,6 +2103,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
threadId?: string;
|
threadId?: string;
|
||||||
} {
|
} {
|
||||||
if (!this.client?.supportsThreads()) {
|
if (!this.client?.supportsThreads()) {
|
||||||
|
logger.debug(`Room::eventShouldLiveIn: eventId=${event.getId()} client does not support threads`);
|
||||||
return {
|
return {
|
||||||
shouldLiveInRoom: true,
|
shouldLiveInRoom: true,
|
||||||
shouldLiveInThread: false,
|
shouldLiveInThread: false,
|
||||||
@@ -2111,6 +2112,11 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
|
|
||||||
// A thread root is always shown in both timelines
|
// A thread root is always shown in both timelines
|
||||||
if (event.isThreadRoot || roots?.has(event.getId()!)) {
|
if (event.isThreadRoot || roots?.has(event.getId()!)) {
|
||||||
|
if (event.isThreadRoot) {
|
||||||
|
logger.debug(`Room::eventShouldLiveIn: eventId=${event.getId()} isThreadRoot is true`);
|
||||||
|
} else {
|
||||||
|
logger.debug(`Room::eventShouldLiveIn: eventId=${event.getId()} is a known thread root`);
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
shouldLiveInRoom: true,
|
shouldLiveInRoom: true,
|
||||||
shouldLiveInThread: true,
|
shouldLiveInThread: true,
|
||||||
@@ -2121,6 +2127,9 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
// A thread relation (1st and 2nd order) is always only shown in a thread
|
// A thread relation (1st and 2nd order) is always only shown in a thread
|
||||||
const threadRootId = event.threadRootId;
|
const threadRootId = event.threadRootId;
|
||||||
if (threadRootId != undefined) {
|
if (threadRootId != undefined) {
|
||||||
|
logger.debug(
|
||||||
|
`Room::eventShouldLiveIn: eventId=${event.getId()} threadRootId=${threadRootId} is part of a thread`,
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
shouldLiveInRoom: false,
|
shouldLiveInRoom: false,
|
||||||
shouldLiveInThread: true,
|
shouldLiveInThread: true,
|
||||||
@@ -2132,6 +2141,9 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
let parentEvent: MatrixEvent | undefined;
|
let parentEvent: MatrixEvent | undefined;
|
||||||
if (parentEventId) {
|
if (parentEventId) {
|
||||||
parentEvent = this.findEventById(parentEventId) ?? events?.find((e) => e.getId() === parentEventId);
|
parentEvent = this.findEventById(parentEventId) ?? events?.find((e) => e.getId() === parentEventId);
|
||||||
|
logger.debug(
|
||||||
|
`Room::eventShouldLiveIn: eventId=${event.getId()} parentEventId=${parentEventId} found=${!!parentEvent}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Treat relations and redactions as extensions of their parents so evaluate parentEvent instead
|
// Treat relations and redactions as extensions of their parents so evaluate parentEvent instead
|
||||||
@@ -2140,6 +2152,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!event.isRelation()) {
|
if (!event.isRelation()) {
|
||||||
|
logger.debug(`Room::eventShouldLiveIn: eventId=${event.getId()} not a relation`);
|
||||||
return {
|
return {
|
||||||
shouldLiveInRoom: true,
|
shouldLiveInRoom: true,
|
||||||
shouldLiveInThread: false,
|
shouldLiveInThread: false,
|
||||||
@@ -2148,6 +2161,11 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
|
|
||||||
// Edge case where we know the event is a relation but don't have the parentEvent
|
// Edge case where we know the event is a relation but don't have the parentEvent
|
||||||
if (roots?.has(event.relationEventId!)) {
|
if (roots?.has(event.relationEventId!)) {
|
||||||
|
logger.debug(
|
||||||
|
`Room::eventShouldLiveIn: eventId=${event.getId()} relationEventId=${
|
||||||
|
event.relationEventId
|
||||||
|
} is a known root`,
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
shouldLiveInRoom: true,
|
shouldLiveInRoom: true,
|
||||||
shouldLiveInThread: true,
|
shouldLiveInThread: true,
|
||||||
@@ -2158,6 +2176,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
|||||||
// We've exhausted all scenarios,
|
// We've exhausted all scenarios,
|
||||||
// we cannot assume that it lives in the main timeline as this may be a relation for an unknown thread
|
// we cannot assume that it lives in the main timeline as this may be a relation for an unknown thread
|
||||||
// adding the event in the wrong timeline causes stuck notifications and can break ability to send read receipts
|
// adding the event in the wrong timeline causes stuck notifications and can break ability to send read receipts
|
||||||
|
logger.debug(`Room::eventShouldLiveIn: eventId=${event.getId()} belongs to an unknown timeline`);
|
||||||
return {
|
return {
|
||||||
shouldLiveInRoom: false,
|
shouldLiveInRoom: false,
|
||||||
shouldLiveInThread: false,
|
shouldLiveInThread: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user