From 53f498b035ed2728583635f70ba2b2fc2d1d7cf7 Mon Sep 17 00:00:00 2001 From: hyochan Date: Tue, 7 Jun 2022 23:43:03 +0900 Subject: [PATCH] bugfix: Migrate new AppState subs --- client/package.json | 2 +- client/src/components/pages/Message.tsx | 10 ++++++---- client/src/hooks/useAppStateChangeHandler.tsx | 4 ++-- server/src/utils/jwt.ts | 17 +++++++++++++---- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/client/package.json b/client/package.json index 1e18fc0db..4b9e5618c 100644 --- a/client/package.json +++ b/client/package.json @@ -1,7 +1,7 @@ { "name": "hackatalk", "private": true, - "version": "2.1.0", + "version": "2.1.1", "main": "node_modules/expo/AppEntry.js", "description": "Opensource chat app", "author": "dooboolab", diff --git a/client/src/components/pages/Message.tsx b/client/src/components/pages/Message.tsx index 9a83a0ae2..dd95a38d6 100644 --- a/client/src/components/pages/Message.tsx +++ b/client/src/components/pages/Message.tsx @@ -41,7 +41,6 @@ import React, { FC, ReactElement, Suspense, - memo, useEffect, useLayoutEffect, useMemo, @@ -601,7 +600,8 @@ const ContentContainer: FC = ({searchArgs, channelId}) => { useLayoutEffect(() => { navigation.setOptions({ - headerTitle: memo((): ReactElement => { + // eslint-disable-next-line react/no-unstable-nested-components + headerTitle: (): ReactElement => { let title = channel?.name || ''; // Note that if the user exists, this is direct message which title should appear as user name or nickname @@ -633,7 +633,7 @@ const ContentContainer: FC = ({searchArgs, channelId}) => { {title} ); - }), + }, }); }, [auth?.id, channel?.name, navigation, users]); @@ -694,7 +694,9 @@ const MessageScreen: FC = () => { }); } - deleteSameChannelNotification(); + if (Platform.OS !== 'web') { + deleteSameChannelNotification(); + } }, [channelId]); const searchArgs: MessagesQuery$variables = { diff --git a/client/src/hooks/useAppStateChangeHandler.tsx b/client/src/hooks/useAppStateChangeHandler.tsx index f54bc582f..fc9b9763b 100644 --- a/client/src/hooks/useAppStateChangeHandler.tsx +++ b/client/src/hooks/useAppStateChangeHandler.tsx @@ -12,10 +12,10 @@ export default function useAppStateChangeHandler( handler: AppStateChangeHandler, ): void { useEffect(() => { - AppState.addEventListener('change', handler); + const subscription = AppState.addEventListener('change', handler); return (): void => { - AppState.removeEventListener('change', handler); + subscription.remove(); }; }, [handler]); } diff --git a/server/src/utils/jwt.ts b/server/src/utils/jwt.ts index 50a0ef0a4..6571c3460 100644 --- a/server/src/utils/jwt.ts +++ b/server/src/utils/jwt.ts @@ -88,6 +88,8 @@ export const getRefreshToken = async ( return !result.verified ? null : refreshToken; }; +const {NODE_ENV} = process.env; + export const refresh = async ( userId: string, prisma: PrismaClient, @@ -96,10 +98,17 @@ export const refresh = async ( expiresIn: REFRESH_TIME, }); - await prisma.profile.update({ - data: {refreshToken: newToken}, - where: {userId}, - }); + try { + await prisma.profile.update({ + data: {refreshToken: newToken}, + where: {userId}, + }); + } catch (err) { + if (NODE_ENV !== 'production') { + // eslint-disable-next-line no-console + console.log('profile update err', err); + } + } return newToken; };