How to use the @rematch/core.dispatch.messages function in @rematch/core

To help you get started, we’ve selected a few @rematch/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EvanBacon / pro-chat / client / src / rematch / chats.js View on Github external
console.log('Add Message', message.key);

      const messages = {
        ...chats[groupId],
        [message.key]: transformMessageForGiftedChat({ message, user }),
      };

      dispatch.chats.addMessages({
        groupId,
        messages,
      });

      // / UGH

      const sortedMessages = Object.values(messages).sort((a, b) => a.timestamp < b.timestamp);
      dispatch.messages.updateWithMessage({
        groupId,
        message: sortedMessages[0],
      });
    },
    startChatting: async ({ uids, callback, groupId }, { chats }) => {
github EvanBacon / pro-chat / client / src / Fire.js View on Github external
const idx = memberUids.indexOf(uid);
      if (idx > -1) memberUids.splice(idx, 1);

      // TODO: Evan: Promise.all([])
      const { data } = await this.getLastMessageForChatGroup({ groupId });
      const message = data[0] || {};
      const group = memberUids;
      // TODO: Evan: Handle groups yolo
      const sender =  group[0]; //message.uid ||
      const user = await (new Promise(res => dispatch.users.ensureUserIsLoadedAsync({ uid: sender, callback: res }) ));
      const previewMessage = this.formatMessageForPreview(message, groupId, user, group);
      previewMessages[groupId] = previewMessage;
    }
    
    if (force) {
      dispatch.messages.clear();
    }
    
    dispatch.messages.update(previewMessages);
    return previewMessages;
  };
  // TODO: dont get all data for each user
github EvanBacon / pro-chat / client / src / rematch / models.js View on Github external
updateWithMessage: ({ groupId, message }) => {
      dispatch.messages.update({
        [groupId]: Fire.shared.formatMessageForPreview(message, groupId),
      });
    },
  },