[FIX] web_editor: generate client id when saving new record

The issue #128847 broke the fix of #124802.

Wysiwyg._generateClientId must be called before `Wysiwyg.resetValue`
as `Wysiwyg.resetValue` will call `Wysiwyg.odooEditor.historyReset`
which need to have the client id set to consider the collaboration
active and serialize the node accordingly.

task-3457120

closes odoo/odoo#138442

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
Nicolas Bayet
2023-10-12 14:44:53 +00:00
parent 1c781669b3
commit 44266e757e
@@ -356,6 +356,7 @@ export class Wysiwyg extends Component {
let editorCollaborationOptions;
if (this._isCollaborationEnabled(options)) {
this._currentClientId = this._generateClientId();
editorCollaborationOptions = this.setupCollaboration(options.collaborationChannel);
if (this.options.collaborativeTrigger === 'start') {
this._joinPeerToPeer();
@@ -692,7 +693,6 @@ export class Wysiwyg extends Component {
this.busService.deleteChannel(this._collaborationChannelName);
}
this._currentClientId = this._generateClientId();
this._startCollaborationTime = new Date().getTime();
this._checkConnectionChange = () => {
@@ -3165,12 +3165,14 @@ export class Wysiwyg extends Component {
this._rulesCache = undefined; // Reset the cache of rules.
// If there is no collaborationResId, the record has been deleted.
if (!this._isCollaborationEnabled(this.options)) {
this._currentClientId = undefined;
this.resetValue(value);
return;
}
this._currentClientId = this._generateClientId();
this.odooEditor.collaborationSetClientId(this._currentClientId);
this.resetValue(value);
this.setupCollaboration(collaborationChannel);
this.odooEditor.collaborationSetClientId(this._currentClientId);
if (this.options.collaborativeTrigger === 'start') {
this._joinPeerToPeer();
} else if (this.options.collaborativeTrigger === 'focus') {