aboutsummaryrefslogtreecommitdiff
path: root/src/store/actions/taggUsers.ts
blob: bcb39cc56aba6ff47d6477c83c0aa2aaf061fddb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import {Action, ThunkAction} from '@reduxjs/toolkit';
import {loadRecentlySearchedUsers} from '../../services';
import {taggUsersFetched} from '../reducers';
import {RootState} from '../rootReducer';

export const loadRecentlySearched =
  (): ThunkAction<Promise<void>, RootState, unknown, Action<string>> =>
  async (dispatch) => {
    try {
      const recentSearches = await loadRecentlySearchedUsers();
      dispatch({
        type: taggUsersFetched.type,
        payload: {recentSearches},
      });
    } catch (error) {
      console.log(error);
    }
  };