Edit message: Don't allow send unless message contents changed
This commit is contained in:
parent
5987350dbe
commit
f53e956810
5 changed files with 70 additions and 8 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
|
||||
import { isNumber, omit, partition } from 'lodash';
|
||||
import { isEqual, isNumber, omit, orderBy, partition } from 'lodash';
|
||||
|
||||
import { SignalService as Proto } from '../protobuf';
|
||||
import * as log from '../logging/log';
|
||||
|
@ -849,3 +849,27 @@ export function applyRangesToText(
|
|||
|
||||
return state;
|
||||
}
|
||||
|
||||
// For ease of working with draft mentions in Quill, a conversationID field is present.
|
||||
function normalizeBodyRanges(bodyRanges: DraftBodyRanges) {
|
||||
return orderBy(bodyRanges, ['start', 'length']).map(item => {
|
||||
if (BodyRange.isMention(item)) {
|
||||
return { ...item, conversationID: undefined };
|
||||
}
|
||||
return item;
|
||||
});
|
||||
}
|
||||
|
||||
export function areBodyRangesEqual(
|
||||
left: DraftBodyRanges,
|
||||
right: DraftBodyRanges
|
||||
): boolean {
|
||||
const normalizedLeft = normalizeBodyRanges(left);
|
||||
const sortedRight = normalizeBodyRanges(right);
|
||||
|
||||
if (normalizedLeft.length !== sortedRight.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isEqual(normalizedLeft, sortedRight);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue