mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-08 07:28:26 +00:00
Live location sharing - set replaces relation when stopping beacon (#8266)
* set replaces relation on stopping beacon Signed-off-by: Kerry Archibald <kerrya@element.io> * update tests for stopBeacon Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
|||||||
BeaconIdentifier,
|
BeaconIdentifier,
|
||||||
BeaconEvent,
|
BeaconEvent,
|
||||||
MatrixEvent,
|
MatrixEvent,
|
||||||
|
RelationType,
|
||||||
Room,
|
Room,
|
||||||
RoomMember,
|
RoomMember,
|
||||||
RoomState,
|
RoomState,
|
||||||
@@ -447,11 +448,20 @@ export class OwnBeaconStore extends AsyncStoreWithClient<OwnBeaconStoreState> {
|
|||||||
...update,
|
...update,
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateContent = makeBeaconInfoContent(timeout,
|
const newContent = makeBeaconInfoContent(timeout,
|
||||||
live,
|
live,
|
||||||
description,
|
description,
|
||||||
assetType,
|
assetType,
|
||||||
timestamp);
|
timestamp,
|
||||||
|
);
|
||||||
|
const updateContent = {
|
||||||
|
...newContent,
|
||||||
|
"m.new_content": newContent,
|
||||||
|
"m.relates_to": {
|
||||||
|
"rel_type": RelationType.Replace,
|
||||||
|
"event_id": beacon.beaconInfoId,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
await this.matrixClient.unstable_setLiveBeacon(beacon.roomId, updateContent);
|
await this.matrixClient.unstable_setLiveBeacon(beacon.roomId, updateContent);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
BeaconEvent,
|
BeaconEvent,
|
||||||
getBeaconInfoIdentifier,
|
getBeaconInfoIdentifier,
|
||||||
MatrixEvent,
|
MatrixEvent,
|
||||||
|
RelationType,
|
||||||
RoomStateEvent,
|
RoomStateEvent,
|
||||||
RoomMember,
|
RoomMember,
|
||||||
} from "matrix-js-sdk/src/matrix";
|
} from "matrix-js-sdk/src/matrix";
|
||||||
@@ -472,6 +473,14 @@ describe('OwnBeaconStore', () => {
|
|||||||
const expectedUpdateContent = {
|
const expectedUpdateContent = {
|
||||||
...prevEventContent,
|
...prevEventContent,
|
||||||
live: false,
|
live: false,
|
||||||
|
["m.new_content"]: {
|
||||||
|
...prevEventContent,
|
||||||
|
live: false,
|
||||||
|
},
|
||||||
|
["m.relates_to"]: {
|
||||||
|
event_id: alicesRoom1BeaconInfo.getId(),
|
||||||
|
rel_type: RelationType.Replace,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
expect(mockClient.unstable_setLiveBeacon).toHaveBeenCalledWith(
|
expect(mockClient.unstable_setLiveBeacon).toHaveBeenCalledWith(
|
||||||
room1Id,
|
room1Id,
|
||||||
@@ -641,6 +650,14 @@ describe('OwnBeaconStore', () => {
|
|||||||
const expectedUpdateContent = {
|
const expectedUpdateContent = {
|
||||||
...prevEventContent,
|
...prevEventContent,
|
||||||
live: false,
|
live: false,
|
||||||
|
["m.new_content"]: {
|
||||||
|
...prevEventContent,
|
||||||
|
live: false,
|
||||||
|
},
|
||||||
|
["m.relates_to"]: {
|
||||||
|
event_id: alicesRoom1BeaconInfo.getId(),
|
||||||
|
rel_type: RelationType.Replace,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
expect(mockClient.unstable_setLiveBeacon).toHaveBeenCalledWith(
|
expect(mockClient.unstable_setLiveBeacon).toHaveBeenCalledWith(
|
||||||
room1Id,
|
room1Id,
|
||||||
@@ -666,6 +683,14 @@ describe('OwnBeaconStore', () => {
|
|||||||
const expectedUpdateContent = {
|
const expectedUpdateContent = {
|
||||||
...prevEventContent,
|
...prevEventContent,
|
||||||
live: false,
|
live: false,
|
||||||
|
["m.new_content"]: {
|
||||||
|
...prevEventContent,
|
||||||
|
live: false,
|
||||||
|
},
|
||||||
|
["m.relates_to"]: {
|
||||||
|
event_id: alicesRoom1BeaconInfo.getId(),
|
||||||
|
rel_type: RelationType.Replace,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
expect(mockClient.unstable_setLiveBeacon).toHaveBeenCalledWith(
|
expect(mockClient.unstable_setLiveBeacon).toHaveBeenCalledWith(
|
||||||
room1Id,
|
room1Id,
|
||||||
|
|||||||
Reference in New Issue
Block a user