diff options
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/common.ts | 2 | ||||
-rw-r--r-- | src/utils/users.ts | 16 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/utils/common.ts b/src/utils/common.ts index dbe8f270..6314cc13 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -1,5 +1,5 @@ import moment from 'moment'; -import {Linking} from 'react-native'; +import {AsyncStorage, Linking} from 'react-native'; import {BROWSABLE_SOCIAL_URLS, TOGGLE_BUTTON_TYPE} from '../constants'; export const getToggleButtonText: ( diff --git a/src/utils/users.ts b/src/utils/users.ts index d4aaebe3..ca917ae4 100644 --- a/src/utils/users.ts +++ b/src/utils/users.ts @@ -1,6 +1,6 @@ import AsyncStorage from '@react-native-community/async-storage'; import {INTEGRATED_SOCIAL_LIST} from '../constants'; -import {loadSocialPosts} from '../services'; +import {isUserBlocked, loadSocialPosts} from '../services'; import { loadAllSocials, loadBlockedList, @@ -9,6 +9,7 @@ import { loadUserData, loadUserMoments, loadUserNotifications, + logout, } from '../store/actions'; import {NO_SOCIAL_ACCOUNTS} from '../store/initialStates'; import {userLoggedIn} from '../store/reducers'; @@ -145,3 +146,16 @@ export const getUserAsProfilePreviewType = ( last_name: fullName[1], }; }; + +export const checkIfUserIsBlocked = async ( + userId: string, + dispatch: Function, + loggedInUser: UserType, +) => { + const token = await AsyncStorage.getItem('token'); + if (!token) { + dispatch(logout()); + return false; + } + return await isUserBlocked(userId, loggedInUser.userId, token); +}; |