Skip to content
This repository has been archived by the owner on May 7, 2023. It is now read-only.

Commit

Permalink
bugfix: Migrate new AppState subs
Browse files Browse the repository at this point in the history
  • Loading branch information
hyochan committed Jun 7, 2022
1 parent 078aa84 commit 53f498b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 6 additions & 4 deletions client/src/components/pages/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import React, {
FC,
ReactElement,
Suspense,
memo,
useEffect,
useLayoutEffect,
useMemo,
Expand Down Expand Up @@ -601,7 +600,8 @@ const ContentContainer: FC<ContentProps> = ({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
Expand Down Expand Up @@ -633,7 +633,7 @@ const ContentContainer: FC<ContentProps> = ({searchArgs, channelId}) => {
{title}
</Text>
);
}),
},
});
}, [auth?.id, channel?.name, navigation, users]);

Expand Down Expand Up @@ -694,7 +694,9 @@ const MessageScreen: FC = () => {
});
}

deleteSameChannelNotification();
if (Platform.OS !== 'web') {
deleteSameChannelNotification();
}
}, [channelId]);

const searchArgs: MessagesQuery$variables = {
Expand Down
4 changes: 2 additions & 2 deletions client/src/hooks/useAppStateChangeHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
17 changes: 13 additions & 4 deletions server/src/utils/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
};
Expand Down

0 comments on commit 53f498b

Please sign in to comment.