Explorar o código

Wait on `chatBoxesFetched` in API

Otherwise we can run into race conditions when using IndexedDB with
mergebounce
JC Brand %!s(int64=4) %!d(string=hai) anos
pai
achega
4c804fcf2d
Modificáronse 2 ficheiros con 4 adicións e 0 borrados
  1. 2 0
      src/headless/plugins/chat/api.js
  2. 2 0
      src/headless/plugins/muc/api.js

+ 2 - 0
src/headless/plugins/chat/api.js

@@ -120,6 +120,8 @@ export default {
          *
          */
         async get (jids, attrs={}, create=false) {
+            await api.waitUntil('chatBoxesFetched');
+
             async function _get (jid) {
                 let model = await api.chatboxes.get(jid);
                 if (!model && create) {

+ 2 - 0
src/headless/plugins/muc/api.js

@@ -137,6 +137,8 @@ export default {
          * });
          */
         async get (jids, attrs = {}, create = false) {
+            await api.waitUntil('chatBoxesFetched');
+
             async function _get (jid) {
                 jid = u.getJIDFromURI(jid);
                 let model = await api.chatboxes.get(jid);