@subiz/widget-v4 4.1.212 → 4.1.213

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.
Files changed (26) hide show
  1. package/compiled_src/store/store.js +16 -0
  2. package/dist/{1a0f6f3ff1a.27.js → 1a1101c351b.27.js} +1 -1
  3. package/dist/{1a0f6f3ff1a.339.js → 1a1101c351b.339.js} +1 -1
  4. package/dist/{1a0f6f3ff1a.459.js → 1a1101c351b.459.js} +1 -1
  5. package/dist/{1a0f6f3ff1a.app.js → 1a1101c351b.app.js} +1 -1
  6. package/dist/{1a0f6f3ff1a.chat.html → 1a1101c351b.chat.html} +1 -1
  7. package/dist/{1a0f6f3ff1a.chat.js → 1a1101c351b.chat.js} +1 -1
  8. package/dist/{1a0f6f3ff1a.form.html → 1a1101c351b.form.html} +1 -1
  9. package/dist/{1a0f6f3ff1a.form.js → 1a1101c351b.form.js} +1 -1
  10. package/dist/{1a0f6f3ff1a.index.html → 1a1101c351b.index.html} +1 -1
  11. package/dist/{1a0f6f3ff1a.library.html → 1a1101c351b.library.html} +1 -1
  12. package/dist/{1a0f6f3ff1a.library.js → 1a1101c351b.library.js} +1 -1
  13. package/dist/{1a0f6f3ff1a.preview.html → 1a1101c351b.preview.html} +1 -1
  14. package/dist/{1a0f6f3ff1a.preview.js → 1a1101c351b.preview.js} +1 -1
  15. package/dist/{1a0f6f3ff1a.webview.js → 1a1101c351b.webview.js} +1 -1
  16. package/dist/27.js +1 -1
  17. package/dist/459.js +1 -1
  18. package/dist/HASH +1 -1
  19. package/dist/screenshoot.js +16 -0
  20. package/package.json +3 -3
  21. package/src/store/store.js +18 -0
  22. /package/dist/{1a0f6f3ff1a.127.js → 1a1101c351b.127.js} +0 -0
  23. /package/dist/{1a0f6f3ff1a.132.js → 1a1101c351b.132.js} +0 -0
  24. /package/dist/{1a0f6f3ff1a.185.js → 1a1101c351b.185.js} +0 -0
  25. /package/dist/{1a0f6f3ff1a.278.js → 1a1101c351b.278.js} +0 -0
  26. /package/dist/{1a0f6f3ff1a.490.js → 1a1101c351b.490.js} +0 -0
@@ -15,6 +15,9 @@ cookie.defaults.expires = 3650 // 10 year
15
15
  let memlocalStorage = require('./inmem_localstorage.js')
16
16
  const MAX_CONVO = 20
17
17
  const page_loaded = sb.Date.now()
18
+ const CHAT_STATE_RESET_AFTER_MS = 24 * 60 * 60 * 1000
19
+ const CHAT_STATE_CYCLE_STARTED_AT = 'chat_state_cycle_started_at'
20
+ const RESETTABLE_CHAT_STATE_KEYS = ['lastview', 'light_convos', 'bot_run_logs', 'close_preview_at']
18
21
 
19
22
  // available localstorage key mask, user, hasManuallyClosed, isopen, close_preview_at, lastview, bot_run_logs, plugin_run_logs
20
23
  export default class Store {
@@ -740,6 +743,20 @@ export default class Store {
740
743
  this.kv.put('lastview', lastView)
741
744
  }
742
745
 
746
+ resetChatStateIfExpired() {
747
+ const now = this.now()
748
+ const cycleStartedAt = this.kv.match(CHAT_STATE_CYCLE_STARTED_AT)
749
+ if (!Number.isFinite(cycleStartedAt) || cycleStartedAt <= 0 || cycleStartedAt > now) {
750
+ this.kv.put(CHAT_STATE_CYCLE_STARTED_AT, now)
751
+ return false
752
+ }
753
+ if (now - cycleStartedAt < CHAT_STATE_RESET_AFTER_MS) return false
754
+
755
+ sb.map(RESETTABLE_CHAT_STATE_KEYS, (key) => this.kv.del(key))
756
+ this.kv.put(CHAT_STATE_CYCLE_STARTED_AT, now)
757
+ return true
758
+ }
759
+
743
760
  async _initResource(accid, auth, realtimep) {
744
761
  this.g_sync = {}
745
762
 
@@ -752,6 +769,7 @@ export default class Store {
752
769
 
753
770
  this.readyGate.close()
754
771
  accid = (accid || '').trim()
772
+ this.resetChatStateIfExpired()
755
773
  let lightConvos = this.kv.match('light_convos') || {}
756
774
  this.lightConvos = {}
757
775
  sb.map(lightConvos, (convo) => {
File without changes
File without changes
File without changes
File without changes
File without changes