Skip to content

Commit c9696e9

Browse files
comment and reformat
1 parent da9cb86 commit c9696e9

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

packages/base/src/widget.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -232,35 +232,35 @@ export class WidgetModel extends Backbone.Model {
232232
utils.put_buffers(state, buffer_paths, buffers);
233233
if (msg.parent_header && data.echo) {
234234
const msgId = (msg.parent_header as any).msg_id;
235-
// for echoed attributes we ignore old updates
236-
data.echo
237-
.filter((attrName: string) =>
238-
Object.keys(this.attrLastUpdateMsgId).includes(attrName)
239-
)
240-
.forEach((attrName: string) => {
241-
// we don't care about the old messages, only the one send with the
242-
// last msgId
243-
const isOldMessage =
244-
this.attrLastUpdateMsgId[attrName] !== msgId;
245-
if (isOldMessage) {
246-
// get rid of old updates
235+
// we may have echos coming from other clients, we only care about
236+
// dropping echos for which we expected a reply
237+
const expectedEcho = data.echo.filter((attrName: string) =>
238+
Object.keys(this.attrLastUpdateMsgId).includes(attrName)
239+
);
240+
expectedEcho.forEach((attrName: string) => {
241+
// we don't care about the old messages, only the one send with the
242+
// last msgId
243+
const isOldMessage =
244+
this.attrLastUpdateMsgId[attrName] !== msgId;
245+
if (isOldMessage) {
246+
// get rid of old updates
247+
delete state[attrName];
248+
} else {
249+
// we got our confirmation, from now on we accept everything
250+
delete this.attrLastUpdateMsgId[attrName];
251+
// except, we plan to send out a new state for this soon, so we will
252+
// also ignore the update for this property
253+
if (
254+
this._msg_buffer !== null &&
255+
Object.prototype.hasOwnProperty.call(
256+
this._msg_buffer,
257+
attrName
258+
)
259+
) {
247260
delete state[attrName];
248-
} else {
249-
// we got our confirmation, from now on we accept everything
250-
delete this.attrLastUpdateMsgId[attrName];
251-
// except, we plan to send out a new state for this soon, so we will
252-
// also ignore the update for this property
253-
if (
254-
this._msg_buffer !== null &&
255-
Object.prototype.hasOwnProperty.call(
256-
this._msg_buffer,
257-
attrName
258-
)
259-
) {
260-
delete state[attrName];
261-
}
262261
}
263-
});
262+
}
263+
});
264264
}
265265
return (this.constructor as typeof WidgetModel)._deserialize_state(
266266
state,

0 commit comments

Comments
 (0)