From afe60c27b00eb4511b16a50abd35fe60a260c579 Mon Sep 17 00:00:00 2001 From: teodorus-nathaniel Date: Mon, 22 Apr 2024 13:29:20 +0700 Subject: [PATCH 1/2] Use default data source as squid --- src/rtk/app/helpers.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rtk/app/helpers.ts b/src/rtk/app/helpers.ts index 848e4c59f..de7b9f53a 100644 --- a/src/rtk/app/helpers.ts +++ b/src/rtk/app/helpers.ts @@ -122,9 +122,12 @@ function toParamsAndIds({ id, ...params }: CommonFetchPropsAndId): CommonFetchPr } export function validateDataSource(dataSource: DataSourceTypes | undefined) { - if (!dataSource || !config.enableSquidDataSource) { + if (!config.enableSquidDataSource) { dataSource = DataSourceTypes.CHAIN } + if (!dataSource) { + dataSource = DataSourceTypes.SQUID + } return dataSource } From fb296ace446a02aa81688801f1381fed67b97b49 Mon Sep 17 00:00:00 2001 From: teodorus-nathaniel Date: Mon, 22 Apr 2024 13:41:31 +0700 Subject: [PATCH 2/2] Only render image or link instead of both --- src/components/posts/view-post/PostPage.tsx | 30 ++++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/components/posts/view-post/PostPage.tsx b/src/components/posts/view-post/PostPage.tsx index 696291398..6e5297a7f 100644 --- a/src/components/posts/view-post/PostPage.tsx +++ b/src/components/posts/view-post/PostPage.tsx @@ -32,7 +32,14 @@ import { useIsPostBlocked } from 'src/rtk/features/moderation/hooks' import { fetchPost, fetchPosts, selectPost } from 'src/rtk/features/posts/postsSlice' import { fetchPostsViewCount } from 'src/rtk/features/posts/postsViewCountSlice' import { useFetchMyReactionsByPostId } from 'src/rtk/features/reactions/myPostReactionsHooks' -import { asCommentStruct, DataSourceTypes, HasStatusCode, idToBn, PostData, PostWithSomeDetails } from 'src/types' +import { + asCommentStruct, + DataSourceTypes, + HasStatusCode, + idToBn, + PostData, + PostWithSomeDetails, +} from 'src/types' import { DfImage } from '../../utils/DfImage' import { DfMd } from '../../utils/DfMd' import Section from '../../utils/Section' @@ -205,12 +212,13 @@ const InnerPostPage: NextPage = props => { {titleMsg} )} - {image && ( + {image ? (
+ ) : ( + link && )} - {link && } {body && } @@ -290,13 +298,15 @@ export async function loadPostOnNextReq({ async function getPost() { const replyIds = await blockchain.getReplyIdsByPostId(idToBn(postId!)) const ids = replyIds.concat(postId!) - await dispatch(fetchPosts({ - api: subsocial, - ids, - reload: true, - eagerLoadHandles: true, - dataSource: source === 'chain' ? DataSourceTypes.CHAIN : DataSourceTypes.SQUID - })) + await dispatch( + fetchPosts({ + api: subsocial, + ids, + reload: true, + eagerLoadHandles: true, + dataSource: source === 'chain' ? DataSourceTypes.CHAIN : DataSourceTypes.SQUID, + }), + ) } await Promise.all([getPost(), dispatch(fetchBlockedResources({ appId }))]) const postData = selectPost(reduxStore.getState(), { id: postId })