Show & clear your own on-a-call status (#34613)
* Show & clear your own on-a-call status The user menu / settings now reflects your own on-a-call status and pressing the 'clear' button will clear both m.status and m.call, whichever are set. * Update function name * Fix tests And make the clear status function simpler by just throwing if either fails. * Fix more tests
This commit is contained in:
@@ -110,6 +110,20 @@ describe("OwnProfileStore", () => {
|
||||
expect(ownProfileStore.userStatus).toEqual({ emoji: "🏝️", text: "On a tropical holiday" });
|
||||
});
|
||||
|
||||
it("should reflect our own on-a-call status if no other status is set", async () => {
|
||||
jest.spyOn(SettingsStore, "getValue").mockReturnValue(true);
|
||||
client.getExtendedProfileProperty.mockImplementation(async (_userId, key) =>
|
||||
key === "org.matrix.msc4426.call" ? { call_joined_ts: 12345 } : undefined,
|
||||
);
|
||||
await ownProfileStore.start();
|
||||
|
||||
expect(client.getExtendedProfileProperty).toHaveBeenCalledWith(
|
||||
client.getSafeUserId(),
|
||||
"org.matrix.msc4426.call",
|
||||
);
|
||||
expect(ownProfileStore.userStatus).toEqual({ emoji: "📞", text: "On a call" });
|
||||
});
|
||||
|
||||
it("should update the user status when a UserProfileUpdate event is received for the current user", async () => {
|
||||
jest.spyOn(SettingsStore, "getValue").mockReturnValue(true);
|
||||
client.getExtendedProfileProperty.mockResolvedValue({ emoji: "🏝️", text: "On a tropical holiday" });
|
||||
|
||||
@@ -32,6 +32,7 @@ describe("UserMenuViewModel", () => {
|
||||
...mockClientMethodsUser(),
|
||||
...mockClientMethodsServer(),
|
||||
getAuthMetadata: jest.fn().mockRejectedValue(new MatrixError({ errcode: "M_UNRECOGNIZED" }, 404)),
|
||||
getExtendedProfileProperty: jest.fn().mockResolvedValue(undefined),
|
||||
setExtendedProfileProperty: jest.fn().mockResolvedValue(undefined),
|
||||
});
|
||||
sdkContext = new TestSDKContext();
|
||||
@@ -178,6 +179,7 @@ describe("UserMenuViewModel", () => {
|
||||
});
|
||||
|
||||
it("can clear a user status", async () => {
|
||||
client.getExtendedProfileProperty.mockResolvedValue({ emoji: "🧪", text: "Testing" });
|
||||
const vm = new UserMenuViewModel({ ownProfileStore: mockOwnProfileStore }, dispatcher, client, true);
|
||||
vm.setOpen(true);
|
||||
vm.clearStatus();
|
||||
|
||||
Reference in New Issue
Block a user