Apply prettier formatting
This commit is contained in:
parent
1cac306093
commit
526645c791
1576 changed files with 65385 additions and 62478 deletions
|
@ -111,7 +111,7 @@ const STATE_EVENT_TILE_TYPES = new Map<string, Factory>([
|
|||
[EventType.RoomPinnedEvents, TextualEventFactory],
|
||||
[EventType.RoomServerAcl, TextualEventFactory],
|
||||
// TODO: Enable support for m.widget event type (https://github.com/vector-im/element-web/issues/13111)
|
||||
['im.vector.modular.widgets', TextualEventFactory], // note that Jitsi widgets are special in pickFactory()
|
||||
["im.vector.modular.widgets", TextualEventFactory], // note that Jitsi widgets are special in pickFactory()
|
||||
[WIDGET_LAYOUT_EVENT_TYPE, TextualEventFactory],
|
||||
[EventType.RoomTombstone, TextualEventFactory],
|
||||
[EventType.RoomJoinRules, TextualEventFactory],
|
||||
|
@ -167,9 +167,7 @@ export function pickFactory(
|
|||
return JSONEventFactory;
|
||||
}
|
||||
|
||||
const noEventFactoryFactory: (() => Optional<Factory>) = () => showHiddenEvents
|
||||
? JSONEventFactory
|
||||
: undefined; // just don't render things that we shouldn't render
|
||||
const noEventFactoryFactory: () => Optional<Factory> = () => (showHiddenEvents ? JSONEventFactory : undefined); // just don't render things that we shouldn't render
|
||||
|
||||
// We run all the event type checks first as they might override the factory entirely.
|
||||
|
||||
|
@ -184,7 +182,7 @@ export function pickFactory(
|
|||
const content = mxEvent.getContent();
|
||||
if (content?.msgtype === MsgType.KeyVerificationRequest) {
|
||||
const me = cli.getUserId();
|
||||
if (mxEvent.getSender() !== me && content['to'] !== me) {
|
||||
if (mxEvent.getSender() !== me && content["to"] !== me) {
|
||||
return noEventFactoryFactory(); // not for/from us
|
||||
} else {
|
||||
// override the factory
|
||||
|
@ -212,10 +210,10 @@ export function pickFactory(
|
|||
|
||||
// TODO: Enable support for m.widget event type (https://github.com/vector-im/element-web/issues/13111)
|
||||
if (evType === "im.vector.modular.widgets") {
|
||||
let type = mxEvent.getContent()['type'];
|
||||
let type = mxEvent.getContent()["type"];
|
||||
if (!type) {
|
||||
// deleted/invalid widget - try the past widget type
|
||||
type = mxEvent.getPrevContent()['type'];
|
||||
type = mxEvent.getPrevContent()["type"];
|
||||
}
|
||||
|
||||
if (WidgetType.JITSI.matches(type)) {
|
||||
|
@ -234,7 +232,7 @@ export function pickFactory(
|
|||
return MessageEventFactory;
|
||||
}
|
||||
|
||||
if (SINGULAR_STATE_EVENTS.has(evType) && mxEvent.getStateKey() !== '') {
|
||||
if (SINGULAR_STATE_EVENTS.has(evType) && mxEvent.getStateKey() !== "") {
|
||||
return noEventFactoryFactory(); // improper event type to render
|
||||
}
|
||||
|
||||
|
@ -392,7 +390,7 @@ export function renderReplyTile(
|
|||
// XXX: this'll eventually be dynamic based on the fields once we have extensible event types
|
||||
const messageTypes = [EventType.RoomMessage, EventType.Sticker];
|
||||
export function isMessageEvent(ev: MatrixEvent): boolean {
|
||||
return (messageTypes.includes(ev.getType() as EventType)) || M_POLL_START.matches(ev.getType());
|
||||
return messageTypes.includes(ev.getType() as EventType) || M_POLL_START.matches(ev.getType());
|
||||
}
|
||||
|
||||
export function haveRendererForEvent(mxEvent: MatrixEvent, showHiddenEvents: boolean): boolean {
|
||||
|
@ -410,12 +408,14 @@ export function haveRendererForEvent(mxEvent: MatrixEvent, showHiddenEvents: boo
|
|||
if (handler === TextualEventFactory) {
|
||||
return hasText(mxEvent, showHiddenEvents);
|
||||
} else if (handler === STATE_EVENT_TILE_TYPES.get(EventType.RoomCreate)) {
|
||||
return Boolean(mxEvent.getContent()['predecessor']);
|
||||
} else if (ElementCall.CALL_EVENT_TYPE.names.some(eventType => handler === STATE_EVENT_TILE_TYPES.get(eventType))) {
|
||||
const intent = mxEvent.getContent()['m.intent'];
|
||||
return Boolean(mxEvent.getContent()["predecessor"]);
|
||||
} else if (
|
||||
ElementCall.CALL_EVENT_TYPE.names.some((eventType) => handler === STATE_EVENT_TILE_TYPES.get(eventType))
|
||||
) {
|
||||
const intent = mxEvent.getContent()["m.intent"];
|
||||
const newlyStarted = Object.keys(mxEvent.getPrevContent()).length === 0;
|
||||
// Only interested in events that mark the start of a non-room call
|
||||
return newlyStarted && typeof intent === 'string' && intent !== GroupCallIntent.Room;
|
||||
return newlyStarted && typeof intent === "string" && intent !== GroupCallIntent.Room;
|
||||
} else if (handler === JSONEventFactory) {
|
||||
return false;
|
||||
} else {
|
||||
|
|
|
@ -34,9 +34,7 @@ interface EventMap {
|
|||
* Optionally receive the current events by calling emitCurrent().
|
||||
* Clean up everything by calling destroy().
|
||||
*/
|
||||
export class RelationsHelper
|
||||
extends TypedEventEmitter<RelationsHelperEvent, EventMap>
|
||||
implements IDestroyable {
|
||||
export class RelationsHelper extends TypedEventEmitter<RelationsHelperEvent, EventMap> implements IDestroyable {
|
||||
private relations?: Relations;
|
||||
private eventId: string;
|
||||
private roomId: string;
|
||||
|
@ -89,11 +87,9 @@ export class RelationsHelper
|
|||
|
||||
private setRelations(): void {
|
||||
const room = this.client.getRoom(this.event.getRoomId());
|
||||
this.relations = room?.getUnfilteredTimelineSet()?.relations?.getChildEventsForEvent(
|
||||
this.eventId,
|
||||
this.relationType,
|
||||
this.relationEventType,
|
||||
);
|
||||
this.relations = room
|
||||
?.getUnfilteredTimelineSet()
|
||||
?.relations?.getChildEventsForEvent(this.eventId, this.relationType, this.relationEventType);
|
||||
}
|
||||
|
||||
private onRelationsAdd = (event: MatrixEvent): void => {
|
||||
|
@ -101,7 +97,7 @@ export class RelationsHelper
|
|||
};
|
||||
|
||||
public emitCurrent(): void {
|
||||
this.relations?.getRelations()?.forEach(e => this.emit(RelationsHelperEvent.Add, e));
|
||||
this.relations?.getRelations()?.forEach((e) => this.emit(RelationsHelperEvent.Add, e));
|
||||
}
|
||||
|
||||
public getCurrent(): MatrixEvent[] {
|
||||
|
@ -126,7 +122,7 @@ export class RelationsHelper
|
|||
},
|
||||
);
|
||||
nextBatch = response?.nextBatch;
|
||||
response?.events.forEach(e => this.emit(RelationsHelperEvent.Add, e));
|
||||
response?.events.forEach((e) => this.emit(RelationsHelperEvent.Add, e));
|
||||
} while (nextBatch);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,4 +36,3 @@ export const getForwardableEvent = (event: MatrixEvent, cli: MatrixClient): Matr
|
|||
}
|
||||
return event;
|
||||
};
|
||||
|
||||
|
|
|
@ -25,9 +25,7 @@ export const getReferenceRelationsForEvent = (
|
|||
client: MatrixClient,
|
||||
): Relations | undefined => {
|
||||
const room = client.getRoom(event.getRoomId());
|
||||
return room?.getUnfilteredTimelineSet()?.relations?.getChildEventsForEvent(
|
||||
event.getId(),
|
||||
RelationType.Reference,
|
||||
messageType,
|
||||
);
|
||||
return room
|
||||
?.getUnfilteredTimelineSet()
|
||||
?.relations?.getChildEventsForEvent(event.getId(), RelationType.Reference, messageType);
|
||||
};
|
||||
|
|
|
@ -14,6 +14,6 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
export { getForwardableEvent } from './forward/getForwardableEvent';
|
||||
export { getShareableLocationEvent } from './location/getShareableLocationEvent';
|
||||
export { getForwardableEvent } from "./forward/getForwardableEvent";
|
||||
export { getShareableLocationEvent } from "./location/getShareableLocationEvent";
|
||||
export * from "./getReferenceRelationsForEvent";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue