To fix the Redaction error and a few improvements

This commit is contained in:
Ayush PS 2021-04-24 18:09:34 +05:30
parent 09af2a8891
commit 9a11b346c9

View File

@ -562,7 +562,7 @@ export default class MessagePanel extends React.Component {
return ret; return ret;
} }
_getTilesForEvent(prevEvent, mxEv, last, nextEvent, nextEventWithTile) { _getTilesForEvent(prevEvent, mxEv, last, isGrouped=false, nextEvent, nextEventWithTile) {
const TileErrorBoundary = sdk.getComponent('messages.TileErrorBoundary'); const TileErrorBoundary = sdk.getComponent('messages.TileErrorBoundary');
const EventTile = sdk.getComponent('rooms.EventTile'); const EventTile = sdk.getComponent('rooms.EventTile');
const DateSeparator = sdk.getComponent('messages.DateSeparator'); const DateSeparator = sdk.getComponent('messages.DateSeparator');
@ -582,7 +582,7 @@ export default class MessagePanel extends React.Component {
// do we need a date separator since the last event? // do we need a date separator since the last event?
const wantsDateSeparator = this._wantsDateSeparator(prevEvent, eventDate); const wantsDateSeparator = this._wantsDateSeparator(prevEvent, eventDate);
if (wantsDateSeparator) { if (wantsDateSeparator && !isGrouped) {
const dateSeparator = <li key={ts1}><DateSeparator key={ts1} ts={ts1} /></li>; const dateSeparator = <li key={ts1}><DateSeparator key={ts1} ts={ts1} /></li>;
ret.push(dateSeparator); ret.push(dateSeparator);
} }
@ -966,7 +966,7 @@ class CreationGrouper {
const DateSeparator = sdk.getComponent('messages.DateSeparator'); const DateSeparator = sdk.getComponent('messages.DateSeparator');
const EventListSummary = sdk.getComponent('views.elements.EventListSummary'); const EventListSummary = sdk.getComponent('views.elements.EventListSummary');
const isGrouped=true;
const panel = this.panel; const panel = this.panel;
const ret = []; const ret = [];
const createEvent = this.createEvent; const createEvent = this.createEvent;
@ -982,7 +982,7 @@ class CreationGrouper {
// If this m.room.create event should be shown (room upgrade) then show it before the summary // If this m.room.create event should be shown (room upgrade) then show it before the summary
if (panel._shouldShowEvent(createEvent)) { if (panel._shouldShowEvent(createEvent)) {
// pass in the createEvent as prevEvent as well so no extra DateSeparator is rendered // pass in the createEvent as prevEvent as well so no extra DateSeparator is rendered
ret.push(...panel._getTilesForEvent(createEvent, createEvent, false)); ret.push(...panel._getTilesForEvent(createEvent, createEvent));
} }
for (const ejected of this.ejectedEvents) { for (const ejected of this.ejectedEvents) {
@ -1052,6 +1052,7 @@ class RedactionGrouper {
this.lastShownEvent = lastShownEvent; this.lastShownEvent = lastShownEvent;
this.nextEvent = nextEvent; this.nextEvent = nextEvent;
this.nextEventTile = nextEventTile; this.nextEventTile = nextEventTile;
} }
shouldGroup(ev) { shouldGroup(ev) {
@ -1081,7 +1082,7 @@ class RedactionGrouper {
const DateSeparator = sdk.getComponent('messages.DateSeparator'); const DateSeparator = sdk.getComponent('messages.DateSeparator');
const EventListSummary = sdk.getComponent('views.elements.EventListSummary'); const EventListSummary = sdk.getComponent('views.elements.EventListSummary');
const isGrouped=true;
const panel = this.panel; const panel = this.panel;
const ret = []; const ret = [];
const lastShownEvent = this.lastShownEvent; const lastShownEvent = this.lastShownEvent;
@ -1098,10 +1099,11 @@ class RedactionGrouper {
); );
const senders = new Set(); const senders = new Set();
let eventTiles = this.events.map((e, i) => { let eventTiles = this.events.map((e, i) => {
senders.add(e.sender); senders.add(e.sender);
const prevEvent = i === 0 ? this.prevEvent : this.events[i - 1]; const prevEvent = i === 0 ? this.prevEvent : this.events[i - 1];
return panel._getTilesForEvent(prevEvent, e, e === lastShownEvent, this.nextEvent, this.nextEventTile); return panel._getTilesForEvent(prevEvent, e, e === lastShownEvent,isGrouped, this.nextEvent, this.nextEventTile);
}).reduce((a, b) => a.concat(b), []); }).reduce((a, b) => a.concat(b), []);
if (eventTiles.length === 0) { if (eventTiles.length === 0) {
@ -1180,7 +1182,7 @@ class MemberGrouper {
const DateSeparator = sdk.getComponent('messages.DateSeparator'); const DateSeparator = sdk.getComponent('messages.DateSeparator');
const MemberEventListSummary = sdk.getComponent('views.elements.MemberEventListSummary'); const MemberEventListSummary = sdk.getComponent('views.elements.MemberEventListSummary');
const isGrouped=true;
const panel = this.panel; const panel = this.panel;
const lastShownEvent = this.lastShownEvent; const lastShownEvent = this.lastShownEvent;
const ret = []; const ret = [];
@ -1213,7 +1215,7 @@ class MemberGrouper {
// of MemberEventListSummary, render each member event as if the previous // of MemberEventListSummary, render each member event as if the previous
// one was itself. This way, the timestamp of the previous event === the // one was itself. This way, the timestamp of the previous event === the
// timestamp of the current event, and no DateSeparator is inserted. // timestamp of the current event, and no DateSeparator is inserted.
return panel._getTilesForEvent(e, e, e === lastShownEvent); return panel._getTilesForEvent(e, e, e === lastShownEvent,isGrouped);
}).reduce((a, b) => a.concat(b), []); }).reduce((a, b) => a.concat(b), []);
if (eventTiles.length === 0) { if (eventTiles.length === 0) {