You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-06 10:22:45 +03:00
Fix issues around up arrow event edit shortcut (#9645)
This commit is contained in:
committed by
GitHub
parent
09282d9f36
commit
d341c56b1f
@@ -25,7 +25,6 @@ import { logger } from "matrix-js-sdk/src/logger";
|
|||||||
import { EventTimeline } from 'matrix-js-sdk/src/models/event-timeline';
|
import { EventTimeline } from 'matrix-js-sdk/src/models/event-timeline';
|
||||||
import { EventType } from 'matrix-js-sdk/src/@types/event';
|
import { EventType } from 'matrix-js-sdk/src/@types/event';
|
||||||
import { RoomState, RoomStateEvent } from 'matrix-js-sdk/src/models/room-state';
|
import { RoomState, RoomStateEvent } from 'matrix-js-sdk/src/models/room-state';
|
||||||
import { EventTimelineSet } from "matrix-js-sdk/src/models/event-timeline-set";
|
|
||||||
import { CallState, MatrixCall } from "matrix-js-sdk/src/webrtc/call";
|
import { CallState, MatrixCall } from "matrix-js-sdk/src/webrtc/call";
|
||||||
import { throttle } from "lodash";
|
import { throttle } from "lodash";
|
||||||
import { MatrixError } from 'matrix-js-sdk/src/http-api';
|
import { MatrixError } from 'matrix-js-sdk/src/http-api';
|
||||||
@@ -1211,10 +1210,14 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private onRoomTimelineReset = (room: Room, timelineSet: EventTimelineSet) => {
|
private onRoomTimelineReset = (room?: Room): void => {
|
||||||
if (!room || room.roomId !== this.state.room?.roomId) return;
|
if (room &&
|
||||||
logger.log(`Live timeline of ${room.roomId} was reset`);
|
room.roomId === this.state.room?.roomId &&
|
||||||
this.setState({ liveTimeline: timelineSet.getLiveTimeline() });
|
room.getLiveTimeline() !== this.state.liveTimeline
|
||||||
|
) {
|
||||||
|
logger.log(`Live timeline of ${room.roomId} was reset`);
|
||||||
|
this.setState({ liveTimeline: room.getLiveTimeline() });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private getRoomTombstone(room = this.state.room) {
|
private getRoomTombstone(room = this.state.room) {
|
||||||
|
@@ -110,7 +110,8 @@ export function findEditableEvent({
|
|||||||
events: MatrixEvent[];
|
events: MatrixEvent[];
|
||||||
isForward: boolean;
|
isForward: boolean;
|
||||||
fromEventId?: string;
|
fromEventId?: string;
|
||||||
}): MatrixEvent {
|
}): MatrixEvent | undefined {
|
||||||
|
if (!events.length) return;
|
||||||
const maxIdx = events.length - 1;
|
const maxIdx = events.length - 1;
|
||||||
const inc = isForward ? 1 : -1;
|
const inc = isForward ? 1 : -1;
|
||||||
const beginIdx = isForward ? 0 : maxIdx;
|
const beginIdx = isForward ? 0 : maxIdx;
|
||||||
|
@@ -34,6 +34,7 @@ import {
|
|||||||
canEditContent,
|
canEditContent,
|
||||||
canEditOwnEvent,
|
canEditOwnEvent,
|
||||||
fetchInitialEvent,
|
fetchInitialEvent,
|
||||||
|
findEditableEvent,
|
||||||
isContentActionable,
|
isContentActionable,
|
||||||
isLocationEvent,
|
isLocationEvent,
|
||||||
isVoiceMessage,
|
isVoiceMessage,
|
||||||
@@ -430,4 +431,13 @@ describe('EventUtils', () => {
|
|||||||
expect(room.getThread(THREAD_ROOT)).toBeInstanceOf(Thread);
|
expect(room.getThread(THREAD_ROOT)).toBeInstanceOf(Thread);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("findEditableEvent", () => {
|
||||||
|
it("should not explode when given empty events array", () => {
|
||||||
|
expect(findEditableEvent({
|
||||||
|
events: [],
|
||||||
|
isForward: true,
|
||||||
|
})).toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user