From c70868c9c8aec4315187ff94590d0fd3b8dbc691 Mon Sep 17 00:00:00 2001 From: Anna Beddow Date: Wed, 28 Feb 2024 17:35:32 +0000 Subject: [PATCH 01/10] Add bridget snapshot --- dotcom-rendering/package.json | 2 +- pnpm-lock.yaml | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dotcom-rendering/package.json b/dotcom-rendering/package.json index 5245b501b3b..4ea7eecae52 100644 --- a/dotcom-rendering/package.json +++ b/dotcom-rendering/package.json @@ -45,7 +45,7 @@ "@emotion/server": "11.11.0", "@guardian/ab-core": "7.0.1", "@guardian/braze-components": "18.1.0", - "@guardian/bridget": "2.6.0", + "@guardian/bridget": "v0.0.0-2024-02-28-SNAPSHOT-DISC", "@guardian/browserslist-config": "6.1.0", "@guardian/cdk": "50.13.0", "@guardian/commercial": "17.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cca7cf97fb1..6907a3823c4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -345,8 +345,8 @@ importers: specifier: 18.1.0 version: 18.1.0(@emotion/react@11.11.1)(@guardian/libs@16.0.1)(@guardian/source-foundations@14.1.4)(@guardian/source-react-components-development-kitchen@19.0.0)(@guardian/source-react-components@22.0.1)(react@18.2.0) '@guardian/bridget': - specifier: 2.6.0 - version: 2.6.0 + specifier: v0.0.0-2024-02-28-SNAPSHOT-DISC + version: 0.0.0-2024-02-28-SNAPSHOT-DISC '@guardian/browserslist-config': specifier: 6.1.0 version: 6.1.0(browserslist@4.21.9)(tslib@2.6.2) @@ -4241,6 +4241,10 @@ packages: react: 18.2.0 dev: false + /@guardian/bridget@0.0.0-2024-02-28-SNAPSHOT-DISC: + resolution: {integrity: sha512-W+cxY6oMbU2ldJgbm/ADmBFC1YRjoKcoftmDte4oVqtYthJaR/z9BcYEAtHx0skss+P/05Bphg28bs/dEo7Msg==} + dev: false + /@guardian/bridget@2.6.0: resolution: {integrity: sha512-kYlRZC5/9ImY2wQJfnteanjfLclmSU0wcsyt2CWl5YXHmc3gGnxZM+H/Y6KVqwxj0v5cGrvUuFJ7Zvk570dchQ==} dev: false From 7f8c9e8cf56f7caad676d8ae230d8353fc8e5a84 Mon Sep 17 00:00:00 2001 From: Anna Beddow Date: Wed, 28 Feb 2024 17:35:42 +0000 Subject: [PATCH 02/10] implement onrecommend for apps --- .../components/Discussion/RecommendationCount.tsx | 2 +- .../src/components/DiscussionApps.importable.tsx | 13 +++++++++++-- dotcom-rendering/src/lib/bridgetApi.ts | 1 + dotcom-rendering/src/lib/discussionApi.tsx | 10 +++------- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/dotcom-rendering/src/components/Discussion/RecommendationCount.tsx b/dotcom-rendering/src/components/Discussion/RecommendationCount.tsx index b1b269a4fbc..78e5d7b9621 100644 --- a/dotcom-rendering/src/components/Discussion/RecommendationCount.tsx +++ b/dotcom-rendering/src/components/Discussion/RecommendationCount.tsx @@ -63,7 +63,7 @@ export const RecommendationCount = ({ setCount(newCount); setRecommended(true); - user.onRecommend(commentId) + user.onRecommend(commentId.toString()) .then((accepted) => { if (!accepted) { setCount(newCount - 1); diff --git a/dotcom-rendering/src/components/DiscussionApps.importable.tsx b/dotcom-rendering/src/components/DiscussionApps.importable.tsx index d362e58e494..8e5006b7c0c 100644 --- a/dotcom-rendering/src/components/DiscussionApps.importable.tsx +++ b/dotcom-rendering/src/components/DiscussionApps.importable.tsx @@ -18,8 +18,17 @@ const onReply = async (): Promise => { return { kind: 'error', error: 'ApiError' }; }; -const onRecommend = async (commentId: number): Promise => { - return getdiscussionClient().recommend(commentId); +const onRecommend = async (commentId: string): Promise => { + return getdiscussionClient() + .recommend(commentId) + .then((response) => { + if (response.__type === 'error') { + return false; + } else { + if (response.response.statusCode === 200) return true; + return false; + } + }); }; const addUsername = async (): Promise> => { console.log('addUsername'); diff --git a/dotcom-rendering/src/lib/bridgetApi.ts b/dotcom-rendering/src/lib/bridgetApi.ts index 5cddaad3901..37819d7e8b0 100644 --- a/dotcom-rendering/src/lib/bridgetApi.ts +++ b/dotcom-rendering/src/lib/bridgetApi.ts @@ -11,6 +11,7 @@ import * as Notifications from '@guardian/bridget/Notifications'; import * as Tag from '@guardian/bridget/Tag'; import * as User from '@guardian/bridget/User'; import * as Video from '@guardian/bridget/Videos'; +import * as DiscussionResponse from '@guardian/bridget/DiscussionResponse'; import { createAppClient } from './thrift/nativeConnection'; let environmentClient: Environment.Client | undefined = undefined; diff --git a/dotcom-rendering/src/lib/discussionApi.tsx b/dotcom-rendering/src/lib/discussionApi.tsx index 9df1fde9e52..e82992443d8 100644 --- a/dotcom-rendering/src/lib/discussionApi.tsx +++ b/dotcom-rendering/src/lib/discussionApi.tsx @@ -306,14 +306,10 @@ export const reportAbuse = export const recommend = (authStatus: SignedInWithCookies | SignedInWithOkta) => - async (commentId: number): Promise => { + async (commentId: string): Promise => { const url = - joinUrl( - options.baseUrl, - 'comment', - commentId.toString(), - 'recommend', - ) + objAsParams(defaultParams); + joinUrl(options.baseUrl, 'comment', commentId, 'recommend') + + objAsParams(defaultParams); const authOptions = getOptionsHeadersWithOkta(authStatus); From e28a1750e741d99e929297241be1e0f9b43718ec Mon Sep 17 00:00:00 2001 From: Anna Beddow Date: Wed, 28 Feb 2024 17:37:51 +0000 Subject: [PATCH 03/10] remove unused import --- dotcom-rendering/src/lib/bridgetApi.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/dotcom-rendering/src/lib/bridgetApi.ts b/dotcom-rendering/src/lib/bridgetApi.ts index 37819d7e8b0..5cddaad3901 100644 --- a/dotcom-rendering/src/lib/bridgetApi.ts +++ b/dotcom-rendering/src/lib/bridgetApi.ts @@ -11,7 +11,6 @@ import * as Notifications from '@guardian/bridget/Notifications'; import * as Tag from '@guardian/bridget/Tag'; import * as User from '@guardian/bridget/User'; import * as Video from '@guardian/bridget/Videos'; -import * as DiscussionResponse from '@guardian/bridget/DiscussionResponse'; import { createAppClient } from './thrift/nativeConnection'; let environmentClient: Environment.Client | undefined = undefined; From 1ea3e577f6ddcb5115b43ab6b477334a372a6828 Mon Sep 17 00:00:00 2001 From: Ioanna Kokkini Date: Mon, 4 Mar 2024 16:49:47 +0000 Subject: [PATCH 04/10] Implement comment method in DiscussionApps --- .../components/DiscussionApps.importable.tsx | 28 ++++++++++++++++--- dotcom-rendering/src/lib/discussionApi.tsx | 1 + 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/dotcom-rendering/src/components/DiscussionApps.importable.tsx b/dotcom-rendering/src/components/DiscussionApps.importable.tsx index 8e5006b7c0c..52107651575 100644 --- a/dotcom-rendering/src/components/DiscussionApps.importable.tsx +++ b/dotcom-rendering/src/components/DiscussionApps.importable.tsx @@ -3,14 +3,34 @@ import { getdiscussionClient } from '../lib/bridgetApi'; import type { Reader, UserProfile } from '../lib/discussion'; import type { CommentResponse } from '../lib/discussionApi'; import { reportAbuse as reportAbuseWeb } from '../lib/discussionApi'; -import type { Result } from '../lib/result'; +import { ok, type Result } from '../lib/result'; import { Discussion, type Props as DiscussionProps } from './Discussion'; type Props = Omit; -const onComment = async (): Promise => { - console.log('onComment'); - return { kind: 'error', error: 'ApiError' }; +const onComment = async ( + shortUrl: string, + body: string, +): Promise => { + return getdiscussionClient() + .comment(shortUrl, body) + .then((response) => { + if (response.__type == 'error') { + return { + kind: 'error', + error: 'NativeError', + }; + } else { + if (response.response.errorCode) { + return { + kind: 'error', + error: 'ApiError', + }; + } + + return ok(Number(response.response.message)); + } + }); }; const onReply = async (): Promise => { diff --git a/dotcom-rendering/src/lib/discussionApi.tsx b/dotcom-rendering/src/lib/discussionApi.tsx index e82992443d8..ac33ef904cb 100644 --- a/dotcom-rendering/src/lib/discussionApi.tsx +++ b/dotcom-rendering/src/lib/discussionApi.tsx @@ -162,6 +162,7 @@ export const preview = async ( export type CommentResponse = Result< | 'NetworkError' | 'ApiError' + | 'NativeError' | (ReturnType & { kind: 'error' })['error'], number >; From 263e8beb060b05015e0be838f55fd4d72c311a1d Mon Sep 17 00:00:00 2001 From: Ioanna Kokkini Date: Mon, 4 Mar 2024 17:58:24 +0000 Subject: [PATCH 05/10] Implement reply in DiscussionApps --- .../src/components/Discussion/CommentForm.tsx | 6 ++++- .../components/DiscussionApps.importable.tsx | 27 ++++++++++++++++--- dotcom-rendering/src/lib/discussionApi.tsx | 4 +-- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/dotcom-rendering/src/components/Discussion/CommentForm.tsx b/dotcom-rendering/src/components/Discussion/CommentForm.tsx index 92797fada4f..f8fd2148ef8 100644 --- a/dotcom-rendering/src/components/Discussion/CommentForm.tsx +++ b/dotcom-rendering/src/components/Discussion/CommentForm.tsx @@ -330,7 +330,11 @@ export const CommentForm = ({ if (body) { const response = commentBeingRepliedTo - ? await user.onReply(shortUrl, body, commentBeingRepliedTo.id) + ? await user.onReply( + shortUrl, + body, + commentBeingRepliedTo.id.toString(), + ) : await user.onComment(shortUrl, body); // Check response message for error states if (response.kind === 'error') { diff --git a/dotcom-rendering/src/components/DiscussionApps.importable.tsx b/dotcom-rendering/src/components/DiscussionApps.importable.tsx index 52107651575..55dc011efa8 100644 --- a/dotcom-rendering/src/components/DiscussionApps.importable.tsx +++ b/dotcom-rendering/src/components/DiscussionApps.importable.tsx @@ -33,9 +33,30 @@ const onComment = async ( }); }; -const onReply = async (): Promise => { - console.log('onReply'); - return { kind: 'error', error: 'ApiError' }; +const onReply = async ( + shortUrl: string, + body: string, + parentCommentId: string, +): Promise => { + return getdiscussionClient() + .reply(shortUrl, body, parentCommentId) + .then((response) => { + if (response.__type == 'error') { + return { + kind: 'error', + error: 'NativeError', + }; + } else { + if (response.response.errorCode) { + return { + kind: 'error', + error: 'ApiError', + }; + } + + return ok(Number(response.response.message)); + } + }); }; const onRecommend = async (commentId: string): Promise => { diff --git a/dotcom-rendering/src/lib/discussionApi.tsx b/dotcom-rendering/src/lib/discussionApi.tsx index ac33ef904cb..2af7743ed5a 100644 --- a/dotcom-rendering/src/lib/discussionApi.tsx +++ b/dotcom-rendering/src/lib/discussionApi.tsx @@ -199,7 +199,7 @@ export const reply = async ( shortUrl: string, body: string, - parentCommentId: number, + parentCommentId: string, ): Promise => { const url = joinUrl( @@ -207,7 +207,7 @@ export const reply = 'discussion', shortUrl, 'comment', - parentCommentId.toString(), + parentCommentId, 'reply', ) + objAsParams(defaultParams); const data = new URLSearchParams(); From 92753b4bfa467208536f95b43db994d74d8e73d3 Mon Sep 17 00:00:00 2001 From: Ioanna Kokkini Date: Tue, 5 Mar 2024 15:38:12 +0000 Subject: [PATCH 06/10] Use bridget SNAPSHOT version --- dotcom-rendering/package.json | 2 +- pnpm-lock.yaml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dotcom-rendering/package.json b/dotcom-rendering/package.json index 4ea7eecae52..596e85f9df2 100644 --- a/dotcom-rendering/package.json +++ b/dotcom-rendering/package.json @@ -45,7 +45,7 @@ "@emotion/server": "11.11.0", "@guardian/ab-core": "7.0.1", "@guardian/braze-components": "18.1.0", - "@guardian/bridget": "v0.0.0-2024-02-28-SNAPSHOT-DISC", + "@guardian/bridget": "0.0.0-2024-02-28-SNAPSHOT-DISC", "@guardian/browserslist-config": "6.1.0", "@guardian/cdk": "50.13.0", "@guardian/commercial": "17.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6907a3823c4..d82ccf9f399 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,9 +1,5 @@ lockfileVersion: '6.0' -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - importers: .: @@ -345,7 +341,7 @@ importers: specifier: 18.1.0 version: 18.1.0(@emotion/react@11.11.1)(@guardian/libs@16.0.1)(@guardian/source-foundations@14.1.4)(@guardian/source-react-components-development-kitchen@19.0.0)(@guardian/source-react-components@22.0.1)(react@18.2.0) '@guardian/bridget': - specifier: v0.0.0-2024-02-28-SNAPSHOT-DISC + specifier: 0.0.0-2024-02-28-SNAPSHOT-DISC version: 0.0.0-2024-02-28-SNAPSHOT-DISC '@guardian/browserslist-config': specifier: 6.1.0 @@ -11924,7 +11920,7 @@ packages: debug: 4.3.4(supports-color@8.1.1) enhanced-resolve: 5.15.0 eslint: 8.56.0 - eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.61.0)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.5.5)(eslint@8.56.0) + eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.18.0)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.56.0) eslint-plugin-import: 2.26.0(@typescript-eslint/parser@5.61.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.56.0) get-tsconfig: 4.7.2 globby: 13.2.2 @@ -20600,3 +20596,7 @@ packages: name: babel-plugin-px-to-rem version: 0.1.0 dev: false + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false From 0cb005a49e8e0b0255190c89e557f61f7e86b207 Mon Sep 17 00:00:00 2001 From: Ioanna Kokkini Date: Tue, 5 Mar 2024 15:53:38 +0000 Subject: [PATCH 07/10] Implement `addUsername` method in `DiscussionApps` --- .../components/DiscussionApps.importable.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/dotcom-rendering/src/components/DiscussionApps.importable.tsx b/dotcom-rendering/src/components/DiscussionApps.importable.tsx index 55dc011efa8..f12ab53eb6e 100644 --- a/dotcom-rendering/src/components/DiscussionApps.importable.tsx +++ b/dotcom-rendering/src/components/DiscussionApps.importable.tsx @@ -3,7 +3,7 @@ import { getdiscussionClient } from '../lib/bridgetApi'; import type { Reader, UserProfile } from '../lib/discussion'; import type { CommentResponse } from '../lib/discussionApi'; import { reportAbuse as reportAbuseWeb } from '../lib/discussionApi'; -import { ok, type Result } from '../lib/result'; +import { ok, error, type Result } from '../lib/result'; import { Discussion, type Props as DiscussionProps } from './Discussion'; type Props = Omit; @@ -71,9 +71,19 @@ const onRecommend = async (commentId: string): Promise => { } }); }; -const addUsername = async (): Promise> => { - console.log('addUsername'); - return { kind: 'error', error: 'ApiError' }; +const addUsername = async (username: string): Promise> => { + return getdiscussionClient() + .addUsername(username) + .then((response) => { + if (response.__type === 'error') { + return error('NativeError'); + } else { + if (response.response.errorCode) { + return error('ApiError'); + } + return ok(true); + } + }); }; /*** From bf35f2f623b5fbe3fa8c8f90417ac913197a53dc Mon Sep 17 00:00:00 2001 From: Ioanna Kokkini Date: Tue, 5 Mar 2024 18:12:29 +0000 Subject: [PATCH 08/10] Implement `getUser` in `DiscussionApps` --- .../components/DiscussionApps.importable.tsx | 47 +++++++++++++++---- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/dotcom-rendering/src/components/DiscussionApps.importable.tsx b/dotcom-rendering/src/components/DiscussionApps.importable.tsx index f12ab53eb6e..85dc0f2e85a 100644 --- a/dotcom-rendering/src/components/DiscussionApps.importable.tsx +++ b/dotcom-rendering/src/components/DiscussionApps.importable.tsx @@ -3,7 +3,7 @@ import { getdiscussionClient } from '../lib/bridgetApi'; import type { Reader, UserProfile } from '../lib/discussion'; import type { CommentResponse } from '../lib/discussionApi'; import { reportAbuse as reportAbuseWeb } from '../lib/discussionApi'; -import { ok, error, type Result } from '../lib/result'; +import { error, ok, type Result } from '../lib/result'; import { Discussion, type Props as DiscussionProps } from './Discussion'; type Props = Omit; @@ -106,15 +106,42 @@ const mockedProfile: UserProfile = { }; const getUser = async (): Promise => { - return { - kind: 'Reader', - onComment, - onReply, - onRecommend, - addUsername, - reportAbuse: reportAbuseWeb(undefined), - profile: mockedProfile, - }; + return getdiscussionClient() + .getUserProfile() + .then((response) => { + if (response.__type === 'profile') { + const profile = response.profile; + const userProfile = { + userId: profile.userId, + displayName: profile.displayName, + webUrl: profile.webUrl, + apiUrl: profile.apiUrl, + avatar: profile.avatar, + secureAvatarUrl: profile.secureAvatarUrl, + badge: [], + } as UserProfile; + + return { + kind: 'Reader', + onComment, + onReply, + onRecommend, + addUsername, + reportAbuse: reportAbuseWeb(undefined), + profile: userProfile, + }; + } else { + return { + kind: 'Reader', + onComment, + onReply, + onRecommend, + addUsername, + reportAbuse: reportAbuseWeb(undefined), + profile: mockedProfile, + }; + } + }); }; export const DiscussionApps = (props: Props) => { From 6429f718ebb556c7227179c2a6ab023e1c78dd5a Mon Sep 17 00:00:00 2001 From: Ioanna Kokkini Date: Thu, 7 Mar 2024 11:21:40 +0000 Subject: [PATCH 09/10] Implement `reportAbuse` in `DiscussionApps` Co-authored-by: Anna Beddow --- .../components/Discussion/AbuseReportForm.tsx | 4 +- .../components/DiscussionApps.importable.tsx | 38 ++++++++++++++----- dotcom-rendering/src/lib/discussionApi.tsx | 16 +++----- 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/dotcom-rendering/src/components/Discussion/AbuseReportForm.tsx b/dotcom-rendering/src/components/Discussion/AbuseReportForm.tsx index 8fee58a8f9c..7e5732f36a6 100644 --- a/dotcom-rendering/src/components/Discussion/AbuseReportForm.tsx +++ b/dotcom-rendering/src/components/Discussion/AbuseReportForm.tsx @@ -159,10 +159,10 @@ export const AbuseReportForm = ({ } reportAbuse({ - categoryId, + categoryId: categoryId.toString(), reason, email, - commentId, + commentId: commentId.toString(), }) .then((response) => { if (response.kind === 'error') { diff --git a/dotcom-rendering/src/components/DiscussionApps.importable.tsx b/dotcom-rendering/src/components/DiscussionApps.importable.tsx index 85dc0f2e85a..45acdca95ed 100644 --- a/dotcom-rendering/src/components/DiscussionApps.importable.tsx +++ b/dotcom-rendering/src/components/DiscussionApps.importable.tsx @@ -86,14 +86,31 @@ const addUsername = async (username: string): Promise> => { }); }; -/*** - * Currently we are using the web handler for both authenticated and unauthenticated users. - * Once we have knowlege of if the user is authenticated from bridget, we can implement an apps-specific function below, to allow us to send user data to analytics. - */ -// const reportAbuse = async (): Promise> => { -// console.log('reportAbuse'); -// return { kind: 'error', error: 'ApiError' }; -// }; +const reportAbuse = async ({ + commentId, + categoryId, + reason, + email, +}: { + commentId: string; + categoryId: string; + reason?: string; + email?: string; +}): Promise> => { + return getdiscussionClient() + .reportAbuse({ commentId, categoryId, reason, email }) + .then((response) => { + if (response.__type == 'error') { + return error('NativeError'); + } else { + if (response.response.errorCode) { + return error('ApiError'); + } + + return ok(true); + } + }); +}; const mockedProfile: UserProfile = { userId: 'userId', @@ -127,17 +144,18 @@ const getUser = async (): Promise => { onReply, onRecommend, addUsername, - reportAbuse: reportAbuseWeb(undefined), + reportAbuse, profile: userProfile, }; } else { + // TODO: Handle the error properly return { kind: 'Reader', onComment, onReply, onRecommend, addUsername, - reportAbuse: reportAbuseWeb(undefined), + reportAbuse, profile: mockedProfile, }; } diff --git a/dotcom-rendering/src/lib/discussionApi.tsx b/dotcom-rendering/src/lib/discussionApi.tsx index 2af7743ed5a..8d071916cb7 100644 --- a/dotcom-rendering/src/lib/discussionApi.tsx +++ b/dotcom-rendering/src/lib/discussionApi.tsx @@ -265,22 +265,18 @@ export const reportAbuse = email, reason, }: { - commentId: number; - categoryId: number; + commentId: string; + categoryId: string; reason?: string; email?: string; }): Promise> => { const url = - joinUrl( - options.baseUrl, - 'comment', - commentId.toString(), - 'reportAbuse', - ) + objAsParams(defaultParams); + joinUrl(options.baseUrl, 'comment', commentId, 'reportAbuse') + + objAsParams(defaultParams); const data = new URLSearchParams(); - data.append('categoryId', categoryId.toString()); - email && data.append('email', email.toString()); + data.append('categoryId', categoryId); + email && data.append('email', email); reason && data.append('reason', reason); const authOptions = authStatus From e8a526f7b4f42978691c71bc537c9671a7e64064 Mon Sep 17 00:00:00 2001 From: Ioanna Kokkini Date: Thu, 7 Mar 2024 16:41:16 +0000 Subject: [PATCH 10/10] Temporarily throw exception in `getUser` in `DiscussionApps` We will have to handle this properly onve we finalise the Bridget API. Co-authored-by: George B <705427+georgeblahblah@users.noreply.github.com> --- .../components/DiscussionApps.importable.tsx | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/dotcom-rendering/src/components/DiscussionApps.importable.tsx b/dotcom-rendering/src/components/DiscussionApps.importable.tsx index 45acdca95ed..3321bcc5ee7 100644 --- a/dotcom-rendering/src/components/DiscussionApps.importable.tsx +++ b/dotcom-rendering/src/components/DiscussionApps.importable.tsx @@ -112,20 +112,13 @@ const reportAbuse = async ({ }); }; -const mockedProfile: UserProfile = { - userId: 'userId', - displayName: 'displayName', - webUrl: 'webUrl', - apiUrl: 'apiUrl', - avatar: 'avatar', - secureAvatarUrl: 'secureAvatarUrl', - badge: [], -}; - const getUser = async (): Promise => { return getdiscussionClient() .getUserProfile() .then((response) => { + // TODO: I don't think we're handling a discussion API + // error for this request in the Bridget API + if (response.__type === 'profile') { const profile = response.profile; const userProfile = { @@ -149,15 +142,7 @@ const getUser = async (): Promise => { }; } else { // TODO: Handle the error properly - return { - kind: 'Reader', - onComment, - onReply, - onRecommend, - addUsername, - reportAbuse, - profile: mockedProfile, - }; + throw error('NativeError'); } }); };