-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle push tokens on new phones/installs
- Loading branch information
1 parent
63c1e5e
commit 33098f7
Showing
8 changed files
with
91 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,24 @@ | ||
import { APIHandler } from './helpers/endpoint' | ||
import { createSupabaseDirectClient } from 'shared/supabase/init' | ||
import { updatePrivateUser as updatePrivateUserData } from 'shared/supabase/users' | ||
import { | ||
updatePrivateUser as updatePrivateUserData, | ||
UpdateType, | ||
} from 'shared/supabase/users' | ||
import { FieldVal } from 'shared/supabase/utils' | ||
import { DELETE_PUSH_TOKEN } from 'common/notification' | ||
|
||
export const updatePrivateUser: APIHandler<'me/private/update'> = async ( | ||
props, | ||
auth | ||
) => { | ||
const db = createSupabaseDirectClient() | ||
await updatePrivateUserData(db, auth.uid, props) | ||
const pg = createSupabaseDirectClient() | ||
|
||
const updates = { | ||
...props, | ||
} as UpdateType | ||
if (props.pushToken === DELETE_PUSH_TOKEN) { | ||
updates.pushToken = FieldVal.delete() | ||
} | ||
|
||
await updatePrivateUserData(pg, auth.uid, updates) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters