Live location sharing - add configs to render beacon_info in timeline (#8251)

* add configs to render beacon_info in timeline

Signed-off-by: Kerry Archibald <kerrya@element.io>

* fix copyright

Signed-off-by: Kerry Archibald <kerrya@element.io>

* one more comment

Signed-off-by: Kerry Archibald <kerrya@element.io>

* update beacon identifier

Signed-off-by: Kerry Archibald <kerrya@element.io>

* use special case for beacon_info tile mapper

Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
Kerry 2022-04-08 11:05:26 +02:00 committed by GitHub
parent 03d0969ae3
commit f63923d60f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 71 additions and 1 deletions

View file

@ -19,6 +19,7 @@ import { MatrixEvent } from "matrix-js-sdk/src/models/event";
import { EventType, MsgType, RelationType } from "matrix-js-sdk/src/@types/event";
import { M_POLL_START, Optional } from "matrix-events-sdk";
import { MatrixClient } from "matrix-js-sdk/src/client";
import { M_BEACON_INFO } from "matrix-js-sdk/src/@types/beacon";
import EditorStateTransfer from "../utils/EditorStateTransfer";
import { RoomPermalinkCreator } from "../utils/permalinks/Permalinks";
@ -211,9 +212,17 @@ export function pickFactory(mxEvent: MatrixEvent, cli: MatrixClient, asHiddenEv?
// Try and pick a state event factory, if we can.
if (mxEvent.isState()) {
if (
M_BEACON_INFO.matches(evType) &&
SettingsStore.getValue("feature_location_share_live")
) {
return MessageEventFactory;
}
if (SINGULAR_STATE_EVENTS.has(evType) && mxEvent.getStateKey() !== '') {
return noEventFactoryFactory(); // improper event type to render
}
return STATE_EVENT_TILE_TYPES[evType] ?? noEventFactoryFactory();
}