Render poll end events in timeline (#10027)
* wip * remove dupe * use poll model relations in all cases * update mpollbody tests to use poll instance * update poll fetching login in pinned messages card * add pinned polls to room polls state * add spinner while relations are still loading * handle no poll in end poll dialog * strict errors * render a poll body that errors for poll end events * add fetching logic to pollend tile * extract poll testing utilities * test mpollend * strict fix * more strict fix * strict fix for forwardref * update poll test utils * implicit anys * tidy and add jsdoc
This commit is contained in:
parent
013fd0a343
commit
583050c8c0
14 changed files with 572 additions and 89 deletions
|
@ -18,7 +18,7 @@ import React from "react";
|
|||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||
import { EventType, MsgType, RelationType } from "matrix-js-sdk/src/@types/event";
|
||||
import { Optional } from "matrix-events-sdk";
|
||||
import { M_POLL_START } from "matrix-js-sdk/src/@types/polls";
|
||||
import { M_POLL_END, M_POLL_START } from "matrix-js-sdk/src/@types/polls";
|
||||
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||
import { GroupCallIntent } from "matrix-js-sdk/src/webrtc/groupCall";
|
||||
|
||||
|
@ -99,6 +99,8 @@ const EVENT_TILE_TYPES = new Map<string, Factory>([
|
|||
[EventType.Sticker, MessageEventFactory],
|
||||
[M_POLL_START.name, MessageEventFactory],
|
||||
[M_POLL_START.altName, MessageEventFactory],
|
||||
[M_POLL_END.name, MessageEventFactory],
|
||||
[M_POLL_END.altName, MessageEventFactory],
|
||||
[EventType.KeyVerificationCancel, KeyVerificationConclFactory],
|
||||
[EventType.KeyVerificationDone, KeyVerificationConclFactory],
|
||||
[EventType.CallInvite, LegacyCallEventFactory], // note that this requires a special factory type
|
||||
|
@ -412,7 +414,11 @@ 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()) ||
|
||||
M_POLL_END.matches(ev.getType())
|
||||
);
|
||||
}
|
||||
|
||||
export function haveRendererForEvent(mxEvent: MatrixEvent, showHiddenEvents: boolean): boolean {
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { M_POLL_START } from "matrix-js-sdk/src/@types/polls";
|
||||
import { M_POLL_END, M_POLL_START } from "matrix-js-sdk/src/@types/polls";
|
||||
import { M_BEACON_INFO } from "matrix-js-sdk/src/@types/beacon";
|
||||
import { MatrixEvent, MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
|
@ -26,7 +26,7 @@ import { VoiceBroadcastInfoEventType } from "../../voice-broadcast/types";
|
|||
* If an event is not forwardable return null
|
||||
*/
|
||||
export const getForwardableEvent = (event: MatrixEvent, cli: MatrixClient): MatrixEvent | null => {
|
||||
if (M_POLL_START.matches(event.getType())) {
|
||||
if (M_POLL_START.matches(event.getType()) || M_POLL_END.matches(event.getType())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue