diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-04-07 16:36:34 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-07 16:36:34 -0400 |
| commit | 4cf3bc720ebcc0b16d158caf60fbdf091621c327 (patch) | |
| tree | 97d8db434060a7bf8579bb2975f9be25331ecb73 /src/store | |
| parent | a3abb3abe322ea84306e1a12cec46972a81a37de (diff) | |
| parent | 6db092b4b88a71c53088a14e330ec73e208ad958 (diff) | |
Merge pull request #354 from TaggiD-Inc/chat-poc
[POC] Chat
Diffstat (limited to 'src/store')
| -rw-r--r-- | src/store/actions/user.ts | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/store/actions/user.ts b/src/store/actions/user.ts index e7d985ac..3ebd4190 100644 --- a/src/store/actions/user.ts +++ b/src/store/actions/user.ts @@ -1,4 +1,5 @@ import AsyncStorage from '@react-native-community/async-storage'; +import {StreamChat} from 'stream-chat'; import {Action, ThunkAction} from '@reduxjs/toolkit'; import { getProfilePic, @@ -164,13 +165,16 @@ export const updateReplyPosted = ( } }; -export const logout = (): ThunkAction< - Promise<void>, - RootState, - unknown, - Action<string> -> => async (dispatch) => { +export const logout = ( + client?: StreamChat, +): ThunkAction<Promise<void>, RootState, unknown, Action<string>> => async ( + dispatch, +) => { try { + // do our best effort here to gracefully disconnect the user + if (client) { + client.disconnectUser(); + } await AsyncStorage.clear(); dispatch({type: userLoggedIn.type, payload: {userId: '', username: ''}}); } catch (error) { |
