@monterosa/sdk-interact-kit 0.18.5 → 0.18.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -2354,7 +2354,14 @@ function handleCreateMessage(message) {
2354
2354
  }
2355
2355
  if (!elements.has(options.id)) return [3 /*break*/, 2];
2356
2356
  element = elements.get(options.id);
2357
- if (options.updated_at > element.updatedAt) {
2357
+ if (options.updated_at > element.updatedAt ||
2358
+ // This is a workaround to handle a Studio issue when two /create/ messages
2359
+ // are sent upon correct option reveal. The first /create/ message contains
2360
+ // the same duration but a different updated_at timestamp. The second /create/
2361
+ // message contains the same updated_at timestamp but a different duration.
2362
+ // Therefore, we need to check if the duration is different to ensure that
2363
+ // the element is updated correctly.
2364
+ options.duration !== element.duration) {
2358
2365
  element.update(options);
2359
2366
  event.emit('update', element);
2360
2367
  }
@@ -2415,8 +2422,10 @@ function handleRevealMessage(message) {
2415
2422
  if (!element) {
2416
2423
  return;
2417
2424
  }
2418
- element.correctOption = correctOption;
2419
- element.context.event.emit('update', element);
2425
+ if (element.correctOption !== correctOption) {
2426
+ element.correctOption = correctOption;
2427
+ element.context.event.emit('update', element);
2428
+ }
2420
2429
  }
2421
2430
  function handleEventHistory(history) {
2422
2431
  var e_1, _a;