Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit b40cde3

Browse files
committed
Tidy
1 parent f63923d commit b40cde3

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/events/EventTileFactory.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export function pickFactory(mxEvent: MatrixEvent, cli: MatrixClient, asHiddenEv?
153153
return JSONEventFactory;
154154
}
155155

156-
const noEventFactoryFactory: (() => Optional<Factory>) = () => SettingsStore.getValue("showHiddenEventsInTimeline")
156+
const noEventFactory: Optional<Factory> = SettingsStore.getValue("showHiddenEventsInTimeline")
157157
? JSONEventFactory
158158
: undefined; // just don't render things that we shouldn't render
159159

@@ -171,7 +171,7 @@ export function pickFactory(mxEvent: MatrixEvent, cli: MatrixClient, asHiddenEv?
171171
if (content?.msgtype === MsgType.KeyVerificationRequest) {
172172
const me = cli.getUserId();
173173
if (mxEvent.getSender() !== me && content['to'] !== me) {
174-
return noEventFactoryFactory(); // not for/from us
174+
return noEventFactory; // not for/from us
175175
} else {
176176
// override the factory
177177
return VerificationReqFactory;
@@ -182,7 +182,7 @@ export function pickFactory(mxEvent: MatrixEvent, cli: MatrixClient, asHiddenEv?
182182
// tile once the verification concludes, so filter out the one from the other party.
183183
const me = cli.getUserId();
184184
if (mxEvent.getSender() !== me) {
185-
return noEventFactoryFactory();
185+
return noEventFactory;
186186
}
187187
}
188188

@@ -192,7 +192,7 @@ export function pickFactory(mxEvent: MatrixEvent, cli: MatrixClient, asHiddenEv?
192192
// XXX: This is extremely a hack. Possibly these components should have an interface for
193193
// declining to render?
194194
if (!MKeyVerificationConclusion.shouldRender(mxEvent, mxEvent.verificationRequest)) {
195-
return noEventFactoryFactory();
195+
return noEventFactory;
196196
}
197197
}
198198

@@ -220,18 +220,18 @@ export function pickFactory(mxEvent: MatrixEvent, cli: MatrixClient, asHiddenEv?
220220
}
221221

222222
if (SINGULAR_STATE_EVENTS.has(evType) && mxEvent.getStateKey() !== '') {
223-
return noEventFactoryFactory(); // improper event type to render
223+
return noEventFactory; // improper event type to render
224224
}
225225

226-
return STATE_EVENT_TILE_TYPES[evType] ?? noEventFactoryFactory();
226+
return STATE_EVENT_TILE_TYPES[evType] ?? noEventFactory;
227227
}
228228

229229
// Blanket override for all events. The MessageEvent component handles redacted states for us.
230230
if (mxEvent.isRedacted()) {
231231
return MessageEventFactory;
232232
}
233233

234-
return EVENT_TILE_TYPES[evType] ?? noEventFactoryFactory();
234+
return EVENT_TILE_TYPES[evType] ?? noEventFactory;
235235
}
236236

237237
/**

src/shouldHideEvent.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
18+
import { EventType, RelationType } from "matrix-js-sdk/src/@types/event";
1819

1920
import SettingsStore from "./settings/SettingsStore";
2021
import { IRoomState } from "./components/structures/RoomView";
@@ -29,7 +30,7 @@ interface IDiff {
2930

3031
function memberEventDiff(ev: MatrixEvent): IDiff {
3132
const diff: IDiff = {
32-
isMemberEvent: ev.getType() === 'm.room.member',
33+
isMemberEvent: ev.getType() === EventType.RoomMember,
3334
};
3435

3536
// If is not a Member Event then the other checks do not apply, so bail early.
@@ -67,7 +68,7 @@ export default function shouldHideEvent(ev: MatrixEvent, ctx?: IRoomState): bool
6768
if (ev.isRedacted() && !isEnabled('showRedactions') && !ev.getThread()) return true;
6869

6970
// Hide replacement events since they update the original tile (if enabled)
70-
if (ev.isRelation("m.replace")) return true;
71+
if (ev.isRelation(RelationType.Replace)) return true;
7172

7273
const eventDiff = memberEventDiff(ev);
7374

0 commit comments

Comments
 (0)