use isLocationEvent util everywhere (#8551)
Signed-off-by: Kerry Archibald <kerrya@element.io>pull/28788/head^2
parent
38f34c3d6a
commit
3c5942aa35
|
@ -29,7 +29,6 @@ import {
|
||||||
M_POLL_END,
|
M_POLL_END,
|
||||||
PollStartEvent,
|
PollStartEvent,
|
||||||
} from "matrix-events-sdk";
|
} from "matrix-events-sdk";
|
||||||
import { M_LOCATION } from "matrix-js-sdk/src/@types/location";
|
|
||||||
|
|
||||||
import { _t } from './languageHandler';
|
import { _t } from './languageHandler';
|
||||||
import * as Roles from './Roles';
|
import * as Roles from './Roles';
|
||||||
|
@ -46,6 +45,7 @@ import AccessibleButton from './components/views/elements/AccessibleButton';
|
||||||
import RightPanelStore from './stores/right-panel/RightPanelStore';
|
import RightPanelStore from './stores/right-panel/RightPanelStore';
|
||||||
import UserIdentifierCustomisations from './customisations/UserIdentifier';
|
import UserIdentifierCustomisations from './customisations/UserIdentifier';
|
||||||
import { ViewRoomPayload } from "./dispatcher/payloads/ViewRoomPayload";
|
import { ViewRoomPayload } from "./dispatcher/payloads/ViewRoomPayload";
|
||||||
|
import { isLocationEvent } from './utils/EventUtils';
|
||||||
|
|
||||||
export function getSenderName(event: MatrixEvent): string {
|
export function getSenderName(event: MatrixEvent): string {
|
||||||
return event.sender?.name ?? event.getSender() ?? _t("Someone");
|
return event.sender?.name ?? event.getSender() ?? _t("Someone");
|
||||||
|
@ -305,11 +305,7 @@ function textForServerACLEvent(ev: MatrixEvent): () => string | null {
|
||||||
}
|
}
|
||||||
|
|
||||||
function textForMessageEvent(ev: MatrixEvent): () => string | null {
|
function textForMessageEvent(ev: MatrixEvent): () => string | null {
|
||||||
const type = ev.getType();
|
if (isLocationEvent(ev)) {
|
||||||
const content = ev.getContent();
|
|
||||||
const msgtype = content.msgtype;
|
|
||||||
|
|
||||||
if (M_LOCATION.matches(type) || M_LOCATION.matches(msgtype)) {
|
|
||||||
return textForLocationEvent(ev);
|
return textForLocationEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,12 @@ limitations under the License.
|
||||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||||
import { EventType, MsgType } from "matrix-js-sdk/src/@types/event";
|
import { EventType, MsgType } from "matrix-js-sdk/src/@types/event";
|
||||||
import { M_POLL_START } from "matrix-events-sdk";
|
import { M_POLL_START } from "matrix-events-sdk";
|
||||||
import { M_LOCATION } from "matrix-js-sdk/src/@types/location";
|
|
||||||
import { M_BEACON_INFO } from "matrix-js-sdk/src/@types/beacon";
|
import { M_BEACON_INFO } from "matrix-js-sdk/src/@types/beacon";
|
||||||
|
|
||||||
import SettingsStore from "../settings/SettingsStore";
|
import SettingsStore from "../settings/SettingsStore";
|
||||||
import { haveRendererForEvent, JitsiEventFactory, JSONEventFactory, pickFactory } from "../events/EventTileFactory";
|
import { haveRendererForEvent, JitsiEventFactory, JSONEventFactory, pickFactory } from "../events/EventTileFactory";
|
||||||
import { MatrixClientPeg } from "../MatrixClientPeg";
|
import { MatrixClientPeg } from "../MatrixClientPeg";
|
||||||
import { getMessageModerationState, MessageModerationState } from "./EventUtils";
|
import { getMessageModerationState, isLocationEvent, MessageModerationState } from "./EventUtils";
|
||||||
|
|
||||||
export function getEventDisplayInfo(mxEvent: MatrixEvent, showHiddenEvents: boolean, hideEvent?: boolean): {
|
export function getEventDisplayInfo(mxEvent: MatrixEvent, showHiddenEvents: boolean, hideEvent?: boolean): {
|
||||||
isInfoMessage: boolean;
|
isInfoMessage: boolean;
|
||||||
|
@ -80,12 +79,8 @@ export function getEventDisplayInfo(mxEvent: MatrixEvent, showHiddenEvents: bool
|
||||||
const noBubbleEvent = (
|
const noBubbleEvent = (
|
||||||
(eventType === EventType.RoomMessage && msgtype === MsgType.Emote) ||
|
(eventType === EventType.RoomMessage && msgtype === MsgType.Emote) ||
|
||||||
M_POLL_START.matches(eventType) ||
|
M_POLL_START.matches(eventType) ||
|
||||||
M_LOCATION.matches(eventType) ||
|
|
||||||
M_BEACON_INFO.matches(eventType) ||
|
M_BEACON_INFO.matches(eventType) ||
|
||||||
(
|
isLocationEvent(mxEvent)
|
||||||
eventType === EventType.RoomMessage &&
|
|
||||||
M_LOCATION.matches(msgtype)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// If we're showing hidden events in the timeline, we should use the
|
// If we're showing hidden events in the timeline, we should use the
|
||||||
|
|
Loading…
Reference in New Issue