Skip to content
This repository has been archived by the owner on Sep 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #440 from skoleapp/multiple-fcm-devices
Browse files Browse the repository at this point in the history
  • Loading branch information
ruohola authored Apr 11, 2021
2 parents daac4c8 + f8b87ab commit 77ca90e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions __generated__/src/graphql/common.graphql.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cypress/fixtures/userMe.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/context/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface UseAuthContext extends AuthContextType {
verified: boolean | null;
verifiedBackupEmail: boolean;
unreadActivityCount: number;
fcmToken: string;
fcmTokens: string[];
username: string;
email: string;
backupEmail: string;
Expand Down Expand Up @@ -47,7 +47,7 @@ export const useAuthContext = (): UseAuthContext => {
const unreadActivityCount = R.propOr(0, 'unreadActivityCount', userMe);
const id = R.prop('id', userMe);
const slug = R.prop('slug', userMe);
const fcmToken = R.prop('fcmToken', userMe);
const fcmTokens = R.prop('fcmTokens', userMe);
const username = R.prop('username', userMe);
const email = R.prop('email', userMe);
const backupEmail = R.prop('backupEmail', userMe);
Expand Down Expand Up @@ -77,7 +77,7 @@ export const useAuthContext = (): UseAuthContext => {
verified,
verifiedBackupEmail,
unreadActivityCount,
fcmToken,
fcmTokens,
username,
email,
backupEmail,
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/common.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ fragment userFields on UserObjectType {
commentCount
created
modified
fcmToken
fcmTokens
commentReplyEmailPermission
threadCommentEmailPermission
newBadgeEmailPermission
Expand Down
6 changes: 3 additions & 3 deletions src/graphql/common.graphql.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/hocs/withUserMe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const withUserMe = <T extends Record<string, unknown>>(
): NextPage<T> => {
const WithUserMe: NextPage<T> = (pageProps: T) => {
const { authLoading, authNetworkError } = useUserMe();
const { fcmToken } = useAuthContext();
const { fcmTokens } = useAuthContext();
const context = useLanguageHeaderContext();
const [registerFcmToken] = useRegisterFcmTokenMutation({ context });
const [markSingleActivityRead] = useMarkActivityAsReadMutation({ context });
Expand All @@ -35,7 +35,7 @@ export const withUserMe = <T extends Record<string, unknown>>(
case 'REGISTER_FCM_TOKEN': {
const { token } = json;

if (token !== fcmToken) {
if (!!fcmTokens && !fcmTokens.includes(token)) {
await registerFcmToken({ variables: { token } });
}

Expand Down Expand Up @@ -77,7 +77,7 @@ export const withUserMe = <T extends Record<string, unknown>>(
}
}
},
[fcmToken, registerFcmToken, markSingleActivityRead],
[fcmTokens, registerFcmToken, markSingleActivityRead],
);

useEffect(() => {
Expand Down

0 comments on commit 77ca90e

Please sign in to comment.