Skip to content

Commit

Permalink
fix: username badge
Browse files Browse the repository at this point in the history
  • Loading branch information
mariojsnunes committed Nov 26, 2024
1 parent 1025b86 commit 922a06c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
13 changes: 9 additions & 4 deletions functions/src/supabaseSync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,18 @@ async function insertOrUpdateProfile(
const { client } = createSupabaseServerClient()
const user = docSnapshot.data() as IUser

const { data } = await client
const profileRequest = await client
.from('profiles')
.select()
.eq('firebase_auth_id', user._authID)
.single()

if (data) {
if (profileRequest.error) {
functions.logger.log(profileRequest.error)
return
}

if (profileRequest.data) {
// Update
const { error } = await client
.from('profiles')
Expand All @@ -81,7 +86,7 @@ async function insertOrUpdateProfile(
.eq('firebase_auth_id', user._authID)

if (error) {
console.log({ ...error })
functions.logger.log({ ...error })
}
} else {
// Insert
Expand All @@ -99,7 +104,7 @@ async function insertOrUpdateProfile(
.eq('firebase_auth_id', user._authID)

if (error) {
console.log({ ...error })
functions.logger.log({ ...error })
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/models/comment.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export class DBCommentAuthor {
id: number
firebase_auth_id: string
display_name: string
username: string
photo_url: string
country: string
is_verified: boolean
Expand All @@ -14,6 +15,7 @@ export class DBCommentAuthor {
return new DBCommentAuthor({
id: obj.id,
display_name: obj.name,
username: obj.username,
firebase_auth_id: obj.firebaseAuthId,
photo_url: obj.photoUrl,
is_verified: obj.isVerified,
Expand All @@ -25,6 +27,7 @@ export class DBCommentAuthor {
export class CommentAuthor {
id: number
name: string
username: string
firebaseAuthId: string
photoUrl: string
country: string
Expand All @@ -38,6 +41,7 @@ export class CommentAuthor {
return new CommentAuthor({
id: obj.id,
name: obj.display_name,
username: obj.username,
firebaseAuthId: obj.firebase_auth_id,
photoUrl: obj.photo_url,
isVerified: obj.is_verified,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/common/CommentsV2/CommentItemV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const CommentItemV2 = observer(
>
<Username
user={{
userName: comment.createdBy?.name || '',
userName: comment.createdBy?.username || '',
countryCode: comment.createdBy?.country,
isVerified: comment.createdBy?.isVerified,
// TODO: isSupporter
Expand Down
2 changes: 1 addition & 1 deletion src/pages/common/CommentsV2/CommentReply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const CommentReply = observer(
>
<Username
user={{
userName: comment.createdBy?.name || '',
userName: comment.createdBy?.username || '',
countryCode: comment.createdBy?.country,
isVerified: comment.createdBy?.isVerified,
// TODO: isSupporter
Expand Down
4 changes: 2 additions & 2 deletions src/routes/api.discussions.$sourceId.comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
source_type,
parent_id,
created_by,
profiles(id, firebase_auth_id, display_name, is_verified, photo_url, country)
profiles(id, firebase_auth_id, display_name, username, is_verified, photo_url, country)
`,
)
.eq(sourceParam, sourceId)
Expand Down Expand Up @@ -140,7 +140,7 @@ export async function action({ params, request }: LoaderFunctionArgs) {
parent_id,
source_type,
created_by,
profiles(id, firebase_auth_id, display_name, is_verified, photo_url, country)
profiles(id, firebase_auth_id, display_name, username, is_verified, photo_url, country)
`,
)
.single()
Expand Down
2 changes: 1 addition & 1 deletion supabase/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ verify_enabled = true
# Use an external OAuth provider. The full list of providers are: `apple`, `azure`, `bitbucket`,
# `discord`, `facebook`, `github`, `gitlab`, `google`, `keycloak`, `linkedin_oidc`, `notion`, `twitch`,
# `twitter`, `slack`, `spotify`, `workos`, `zoom`.
[auth.external.apple]
# [auth.external.apple]
enabled = false
client_id = ""
# DO NOT commit your OAuth provider secret to git. Use environment variable substitution instead:
Expand Down

0 comments on commit 922a06c

Please sign in to comment.