-
-
Notifications
You must be signed in to change notification settings - Fork 833
Hide ignored invites #9255
Hide ignored invites #9255
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ import LegacyCallHandler from "../../../LegacyCallHandler"; | |
import { RoomListCustomisations } from "../../../customisations/RoomList"; | ||
import { isLocalRoom } from "../../../utils/localRoom/isLocalRoom"; | ||
import VoipUserMapper from "../../../VoipUserMapper"; | ||
import { MatrixClientPeg } from "../../../MatrixClientPeg"; | ||
|
||
export class VisibilityProvider { | ||
private static internalInstance: VisibilityProvider; | ||
|
@@ -38,7 +39,7 @@ export class VisibilityProvider { | |
await VoipUserMapper.sharedInstance().onNewInvitedRoom(room); | ||
} | ||
|
||
public isRoomVisible(room?: Room): boolean { | ||
public async isRoomVisible(room?: Room): Promise<boolean> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a breaking change, existing customisations will fail to compile with this change due to the return type changing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would you suggest? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move it into the js-sdk as a background operation, so consumers don't have to make all their APIs async. Feels a bit strange for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It also looks like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You're right, I should at least lock it to avoid that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That was the design at some point but I dropped it because it felt like I would be reimplementing a non-trivial subset of the state event store. On the other hand, it is probably needed to achieve any kind of performance anyway, so now might be the right time to revisit this. I'll think this over. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case someone else reads this, this conversation has spawned a patch in matrix-js-sdk: matrix-org/matrix-js-sdk#2653 . |
||
if (!room) { | ||
return false; | ||
} | ||
|
@@ -50,6 +51,21 @@ export class VisibilityProvider { | |
return false; | ||
} | ||
|
||
if (room.getMyMembership() === "invite") { | ||
// Find out whether the invite should be hidden. | ||
const cli = MatrixClientPeg.get(); | ||
const myUserId = cli.getUserId(); | ||
const inviter = room.currentState.getMember(myUserId); | ||
if (inviter?.events?.member) { | ||
const inviterUserId = inviter.events.member.getSender(); | ||
const rule = await cli.ignoredInvites.getRuleForInvite({ roomId: room.roomId, sender: inviterUserId }); | ||
if (rule) { | ||
// Indeed, there is a rule that specifies we should hide the invite. | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
// hide space rooms as they'll be shown in the SpacePanel | ||
if (room.isSpaceRoom()) { | ||
return false; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These cannot be async, this causes race conditions, please see git history around this file. You would need to introduce a semaphore to prevent updates racing with each other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g. #6391
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch. Will do, thanks!