mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-15 20:54:59 +08:00
Live location sharing: don't group beacon info with room creation summary (#8468)
* dont group beacon info with room creation summary Signed-off-by: Kerry Archibald <kerrya@element.io> * remove debugs Signed-off-by: Kerry Archibald <kerrya@element.io> * add comment Signed-off-by: Kerry Archibald <kerrya@element.io> * update comment Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
parent
3b1e715854
commit
c5633a24fe
@ -23,6 +23,7 @@ import { MatrixEvent } from 'matrix-js-sdk/src/models/event';
|
|||||||
import { Relations } from "matrix-js-sdk/src/models/relations";
|
import { Relations } from "matrix-js-sdk/src/models/relations";
|
||||||
import { logger } from 'matrix-js-sdk/src/logger';
|
import { logger } from 'matrix-js-sdk/src/logger';
|
||||||
import { RoomStateEvent } from "matrix-js-sdk/src/models/room-state";
|
import { RoomStateEvent } from "matrix-js-sdk/src/models/room-state";
|
||||||
|
import { M_BEACON_INFO } from 'matrix-js-sdk/src/@types/beacon';
|
||||||
|
|
||||||
import shouldHideEvent from '../../shouldHideEvent';
|
import shouldHideEvent from '../../shouldHideEvent';
|
||||||
import { wantsDateSeparator } from '../../DateUtils';
|
import { wantsDateSeparator } from '../../DateUtils';
|
||||||
@ -1079,7 +1080,7 @@ abstract class BaseGrouper {
|
|||||||
|
|
||||||
// Wrap initial room creation events into a GenericEventListSummary
|
// Wrap initial room creation events into a GenericEventListSummary
|
||||||
// Grouping only events sent by the same user that sent the `m.room.create` and only until
|
// Grouping only events sent by the same user that sent the `m.room.create` and only until
|
||||||
// the first non-state event or membership event which is not regarding the sender of the `m.room.create` event
|
// the first non-state event, beacon_info event or membership event which is not regarding the sender of the `m.room.create` event
|
||||||
class CreationGrouper extends BaseGrouper {
|
class CreationGrouper extends BaseGrouper {
|
||||||
static canStartGroup = function(panel: MessagePanel, ev: MatrixEvent): boolean {
|
static canStartGroup = function(panel: MessagePanel, ev: MatrixEvent): boolean {
|
||||||
return ev.getType() === EventType.RoomCreate;
|
return ev.getType() === EventType.RoomCreate;
|
||||||
@ -1098,9 +1099,15 @@ class CreationGrouper extends BaseGrouper {
|
|||||||
&& (ev.getStateKey() !== createEvent.getSender() || ev.getContent()["membership"] !== "join")) {
|
&& (ev.getStateKey() !== createEvent.getSender() || ev.getContent()["membership"] !== "join")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// beacons are not part of room creation configuration
|
||||||
|
// should be shown in timeline
|
||||||
|
if (M_BEACON_INFO.matches(ev.getType())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (ev.isState() && ev.getSender() === createEvent.getSender()) {
|
if (ev.isState() && ev.getSender() === createEvent.getSender()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,11 @@ import * as TestUtilsMatrix from "../../test-utils";
|
|||||||
import EventListSummary from "../../../src/components/views/elements/EventListSummary";
|
import EventListSummary from "../../../src/components/views/elements/EventListSummary";
|
||||||
import GenericEventListSummary from "../../../src/components/views/elements/GenericEventListSummary";
|
import GenericEventListSummary from "../../../src/components/views/elements/GenericEventListSummary";
|
||||||
import DateSeparator from "../../../src/components/views/messages/DateSeparator";
|
import DateSeparator from "../../../src/components/views/messages/DateSeparator";
|
||||||
|
import { makeBeaconInfoEvent } from '../../test-utils';
|
||||||
|
|
||||||
|
jest.mock('../../../src/utils/beacon', () => ({
|
||||||
|
useBeacon: jest.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
let client;
|
let client;
|
||||||
const room = new Matrix.Room("!roomId:server_name");
|
const room = new Matrix.Room("!roomId:server_name");
|
||||||
@ -481,6 +486,27 @@ describe('MessagePanel', function() {
|
|||||||
expect(summaryEventTiles.length).toEqual(tiles.length - 3);
|
expect(summaryEventTiles.length).toEqual(tiles.length - 3);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not collapse beacons as part of creation events', function() {
|
||||||
|
const [creationEvent] = mkCreationEvents();
|
||||||
|
const beaconInfoEvent = makeBeaconInfoEvent(
|
||||||
|
creationEvent.getSender(),
|
||||||
|
creationEvent.getRoomId(),
|
||||||
|
{ isLive: true },
|
||||||
|
);
|
||||||
|
const combinedEvents = [creationEvent, beaconInfoEvent];
|
||||||
|
TestUtilsMatrix.upsertRoomStateEvents(room, combinedEvents);
|
||||||
|
const res = mount(
|
||||||
|
<WrappedMessagePanel className="cls" events={combinedEvents} />,
|
||||||
|
);
|
||||||
|
|
||||||
|
const summaryTiles = res.find(GenericEventListSummary);
|
||||||
|
const summaryTile = summaryTiles.at(0);
|
||||||
|
|
||||||
|
const summaryEventTiles = summaryTile.find(UnwrappedEventTile);
|
||||||
|
// nothing in the summary
|
||||||
|
expect(summaryEventTiles.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
it('should hide read-marker at the end of creation event summary', function() {
|
it('should hide read-marker at the end of creation event summary', function() {
|
||||||
const events = mkCreationEvents();
|
const events = mkCreationEvents();
|
||||||
TestUtilsMatrix.upsertRoomStateEvents(room, events);
|
TestUtilsMatrix.upsertRoomStateEvents(room, events);
|
||||||
|
Loading…
Reference in New Issue
Block a user