فهرست منبع

fix(screenshot): unable to resubscribe when the instance is not fully released

Casper Dai 2 سال پیش
والد
کامیت
5a75cc94ce
1فایلهای تغییر یافته به همراه4 افزوده شده و 2 حذف شده
  1. 4 2
      src/utils/cache/screenshot.js

+ 4 - 2
src/utils/cache/screenshot.js

@@ -16,12 +16,14 @@ export function watch ({ productId, id }, cb, expired) {
     listening = true
   }
   let inst = cache.get(id)
+  if (!inst || !inst.cb) {
+    subscribe(`${productId}/${id}/screenshot/reply`)
+    console.log('screenshot subscribe', id, '-> success')
+  }
   if (inst) {
     inst.cb = cb
   } else {
-    subscribe(`${productId}/${id}/screenshot/reply`)
     cache.set(id, inst = createInst(productId, id, cb))
-    console.log('screenshot subscribe', id, '-> success')
   }
   if (retry(inst, expired)) {
     screenshot(id, true)