make sure in the future arrow up/down only goes through own events
This commit is contained in:
parent
25e2c747ed
commit
918de849c7
1 changed files with 11 additions and 1 deletions
|
@ -52,6 +52,16 @@ export function canEditContent(mxEvent) {
|
||||||
mxEvent.getSender() === MatrixClientPeg.get().getUserId();
|
mxEvent.getSender() === MatrixClientPeg.get().getUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function canEditOwnEvent(mxEvent) {
|
||||||
|
// for now we only allow editing
|
||||||
|
// your own events. So this just call through
|
||||||
|
// In the future though, moderators will be able to
|
||||||
|
// edit other people's messages as well but we don't
|
||||||
|
// want findEditableEvent to return other people's events
|
||||||
|
// hence this method.
|
||||||
|
return canEditContent(mxEvent);
|
||||||
|
}
|
||||||
|
|
||||||
export function findEditableEvent(room, isForward, fromEventId = undefined) {
|
export function findEditableEvent(room, isForward, fromEventId = undefined) {
|
||||||
const liveTimeline = room.getLiveTimeline();
|
const liveTimeline = room.getLiveTimeline();
|
||||||
const events = liveTimeline.getEvents();
|
const events = liveTimeline.getEvents();
|
||||||
|
@ -71,7 +81,7 @@ export function findEditableEvent(room, isForward, fromEventId = undefined) {
|
||||||
// don't look further than 100 events from `fromEventId`
|
// don't look further than 100 events from `fromEventId`
|
||||||
// to not iterate potentially 1000nds of events on key up/down
|
// to not iterate potentially 1000nds of events on key up/down
|
||||||
endIdx = Math.min(Math.max(0, i + (inc * 100)), maxIdx);
|
endIdx = Math.min(Math.max(0, i + (inc * 100)), maxIdx);
|
||||||
} else if (foundFromEventId && !shouldHideEvent(e) && canEditContent(e)) {
|
} else if (foundFromEventId && !shouldHideEvent(e) && canEditOwnEvent(e)) {
|
||||||
// otherwise look for editable event
|
// otherwise look for editable event
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue