[FIX] web_editor: use setValue instead of resetEdior when restore

Before this commit, when restoring a document was made, it would reset
the content of the editor without any consideration for the mechanism
that detect stale documents and without any consideration for the
collaboration.

This commit fixes 2 problems in one shot:

1) Any change made in the editor after a restore was impossible to
save. The reason is that the restored version would reset the wysiwyg
without the id `data-last-history-steps` of the version in database in
the historyIds of the odooEditor wich subsequently would trigger the
stale document detection, preventing the save.

2) The reset would be propagated to other peers in collaboration. The
reason is the same as the 1st problem, the wysiwyg would be reseted,
not informing other peers of that reset.

task-3675074

Part-of: odoo/odoo#148826
This commit is contained in:
Nicolas Bayet
2024-01-10 21:04:31 +00:00
parent 40dab4b5a3
commit 0e22763a85
@@ -247,16 +247,23 @@ export class Wysiwyg extends Component {
const newRecordInfo = newProps.options.recordInfo;
const newCollaborationChannel = newProps.options.collaborationChannel;
const isDifferentRecord =
JSON.stringify(lastRecordInfo) !== JSON.stringify(newRecordInfo) ||
JSON.stringify(lastCollaborationChannel) !== JSON.stringify(newCollaborationChannel);
if (
(
stripHistoryIds(newValue) !== stripHistoryIds(newProps.editingValue) &&
stripHistoryIds(lastValue) !== stripHistoryIds(newValue)
) ||
JSON.stringify(lastRecordInfo) !== JSON.stringify(newRecordInfo) ||
JSON.stringify(lastCollaborationChannel) !== JSON.stringify(newCollaborationChannel)
isDifferentRecord
)
{
this.resetEditor(newValue, newProps.options);
if (isDifferentRecord) {
this.resetEditor(newValue, newProps.options);
} else {
this.setValue(newValue);
}
this.env.onWysiwygReset && this.env.onWysiwygReset();
}
});