How to use the @rematch/core.dispatch.users 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 / user.js View on Github external
...nextFirebaseAuthData,
      };
      const updates = {};
      for (const key of Object.keys(combinedUserData)) {
        if (
          combinedUserData[key] !== undefined &&
          combinedUserData[key] !== nextLocalUserData[key]
        ) {
          updates[key] = combinedUserData[key];
        }
      }
      if (Object.keys(updates).length > 0) {
        dispatch.user.update(updates);
      }
      // dispatch.dailyStreak.compareDaily();
      dispatch.users.update({
        uid: combinedUserData.uid,
        user: combinedUserData,
      });
      console.log('Main:userdata:', combinedUserData);
      if (Settings.isCacheProfileUpdateActive) {
        const shouldUpdateKey = '@Bute/shouldUpdateProfile';
        const something = await PantryStorage.getItemWithExpiration(shouldUpdateKey);
        if (!something) {
          const some = await PantryStorage.setItemWithExpiration(
            shouldUpdateKey,
            { update: true },
            Settings.shouldDelayFirebaseProfileSyncInMinutes,
          );
          dispatch.user.syncLocalToFirebase();
        } else {
          console.log('Prevent: syncLocalToFirebase');
github EvanBacon / pro-chat / client / src / screens / ProfileScreen.js View on Github external
updateWithUID = async (uid, update) => {
    if (!uid) return;
    const {
      image, name, about, likes, rating, relationship,
    } = this.props;
    if (!image || update) {
      dispatch.users.getProfileImage({ uid });
    }
    if (!name || update) {
      dispatch.users.getPropertyForUser({ uid, property: 'first_name' });
    }
    if (!about || update) {
      dispatch.users.getPropertyForUser({ uid, property: 'about' });
    }
    if (!likes || update) {
      dispatch.users.getPropertyForUser({ uid, property: 'likes' });
    }
    if (!rating || update) {
      dispatch.users.getPropertyForUser({ uid, property: 'rating' });
    }
    if (!relationship || update) {
      dispatch.relationships.getAsync({ uid });
    }

    const isMatched = await new Promise(res =>
      dispatch.relationships.isMatched({ uid, callback: res }));

    // this.props.navigation.setParams({ isMatched, name, uid });
    LayoutAnimation.easeInEaseOut();
github EvanBacon / pro-chat / client / src / rematch / chats.js View on Github external
const user = await new Promise(res =>
        dispatch.users.ensureUserIsLoadedAsync({ uid, callback: res }));
      console.log('_parseMessage: has user', !!user, uid);
github EvanBacon / pro-chat / client / src / rematch / users.js View on Github external
const userData = snapshot.data();
      if (userData) {
        const nextUser = {
          ...filterUser(userData),
          ensured: Date.now(),
        };
        console.log('ensureUserIsLoadedAsync: C: userData', nextUser);

        dispatch.users.update({
          uid,
          user: nextUser,
        });
        return { isUpdated: true, user: nextUser };
      }
      console.log('REMOVED USER', uid);
      dispatch.users.remove({ uid });
      return { isUpdated: true, isRemoved: true };
    } catch ({ message }) {
      throw new Error(`getPropForUser ${message}`);
    }
  }
  return { isUpdated: false, user: storedUser };
}
github EvanBacon / pro-chat / client / src / rematch / user.js View on Github external
function uploadEntryInLocalDatabase(updates) {
  dispatch.users.update({ uid: Fire.shared.uid, user: updates });
}
const user = {
github EvanBacon / pro-chat / client / src / components / MatchesList.js View on Github external
handleLoadMore = () => {
    dispatch.users.getPaged({ size: 5 });
  };
  render() {
github EvanBacon / pro-chat / client / src / navigation / NavigationService.js View on Github external
function navigateToUserSpecificScreen(routeName, uid, params = {}) {
  dispatch.users.ensureUserIsLoadedAsync({ uid });

  let groupId;
  if (IdManager.isInteractable(uid)) groupId = IdManager.getGroupId(uid);

  navigate(routeName, { groupId, ...params, uid });
}
github EvanBacon / pro-chat / client / src / screens / ProfileScreen.js View on Github external
          onImageUpdated={async () => dispatch.users.getProfileImage({ uid })}
          onRatingPressed={dispatch.user.changeRating}
github EvanBacon / pro-chat / client / src / Fire.js View on Github external
      const user = await (new Promise(res => dispatch.users.ensureUserIsLoadedAsync({ uid: sender, callback: res }) ));
      const previewMessage = this.formatMessageForPreview(message, groupId, user, group);
github EvanBacon / pro-chat / client / src / rematch / users.js View on Github external
    clearUser: ({ uid }) => dispatch.users.set({ uid, user: null }),
    getProfileImage: ({ uid, forceUpdate }) => {