Skip to content

Commit 5e59d2c

Browse files
authored
fix: change query rpc to instance, fix opengraph post (#1702)
* feat: change query param from rpc to instance * fix: opengraph post
1 parent 451f65a commit 5e59d2c

14 files changed

Lines changed: 165 additions & 49 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"express": "^4.17.3",
7575
"firebase": "^8.6.2",
7676
"global": "^4.4.0",
77-
"html-react-parser": "^1.4.9",
77+
"html-react-parser": "^3.0.8",
7878
"http-proxy-middleware": "^2.0.4",
7979
"i18next": "^21.6.7",
8080
"i18next-browser-languagedetector": "^6.1.2",

pages/experience/[experienceId]/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export const getServerSideProps = wrapper.getServerSideProps(store => async cont
158158

159159
if (anonymous) {
160160
const username = session?.user?.name ?? generateAnonymousUser();
161-
const queryInstanceURL = query.rpc;
161+
const queryInstanceURL = query.instance;
162162

163163
apiURL = queryInstanceURL ?? cookiesInstanceURL ?? defaultInstanceURL;
164164
res.setHeader('set-cookie', [`${COOKIE_INSTANCE_URL}=${apiURL}`]);

pages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export const getServerSideProps = wrapper.getServerSideProps(store => async cont
120120

121121
if (anonymous) {
122122
const username = generateAnonymousUser();
123-
const queryInstanceURL = query.rpc;
123+
const queryInstanceURL = query.instance;
124124

125125
apiURL = queryInstanceURL ?? cookiesInstanceURL ?? defaultInstanceURL;
126126
res.setHeader('set-cookie', [`${COOKIE_INSTANCE_URL}=${apiURL}`]);

pages/login.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const getServerSideProps = wrapper.getServerSideProps(store => async cont
7171

7272
const dispatch = store.dispatch as ThunkDispatchAction;
7373

74-
const queryInstanceURL = query.rpc;
74+
const queryInstanceURL = query.instance;
7575
const cookiesInstanceURL = cookies[COOKIE_INSTANCE_URL];
7676
const defaultInstanceURL = serverRuntimeConfig.myriadAPIURL;
7777
const apiURL = queryInstanceURL ?? cookiesInstanceURL ?? defaultInstanceURL;

pages/post/[postId].tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ import axios from 'axios';
1414
import {stringify} from 'components/PostCreate/formatter';
1515
import {PostDetailContainer} from 'components/PostDetail/PostDetail.container';
1616
import {COOKIE_INSTANCE_URL} from 'components/SelectServer';
17+
import parse from 'html-react-parser';
1718
import {TopNavbarComponent} from 'src/components/atoms/TopNavbar';
1819
import {TippingSuccess} from 'src/components/common/Tipping/render/Tipping.success';
1920
import {DefaultLayout} from 'src/components/template/Default/DefaultLayout';
2021
import {generateAnonymousUser} from 'src/helpers/auth';
22+
import {htmlToJson, isJson} from 'src/helpers/string';
2123
import {Post} from 'src/interfaces/post';
2224
import {User} from 'src/interfaces/user';
2325
import {initialize} from 'src/lib/api/base';
@@ -179,7 +181,7 @@ export const getServerSideProps = wrapper.getServerSideProps(store => async cont
179181

180182
if (anonymous) {
181183
const username = generateAnonymousUser();
182-
const queryInstanceURL = query.rpc;
184+
const queryInstanceURL = query.instance;
183185

184186
apiURL = queryInstanceURL ?? cookiesInstanceURL ?? defaultInstanceURL;
185187
res.setHeader('set-cookie', [`${COOKIE_INSTANCE_URL}=${apiURL}`]);
@@ -219,9 +221,16 @@ export const getServerSideProps = wrapper.getServerSideProps(store => async cont
219221

220222
if (post?.platform === 'myriad') {
221223
const {text, image: imageData} = stringify(post);
224+
const isHtmlContent = !isJson(text);
225+
if (isHtmlContent) {
226+
description = htmlToJson(parse(post.text)).text;
227+
image = htmlToJson(parse(post.text)).img[0] ?? '';
228+
} else {
229+
description = text;
230+
image = imageData;
231+
}
232+
222233
title = post?.title ?? `${post.user.name} on ${publicRuntimeConfig.appName}`;
223-
description = text;
224-
image = imageData;
225234
}
226235

227236
if (post?.platform !== 'myriad') {

pages/profile/[id].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export const getServerSideProps = wrapper.getServerSideProps(store => async cont
124124

125125
if (anonymous) {
126126
const username = generateAnonymousUser();
127-
const queryInstanceURL = query.rpc;
127+
const queryInstanceURL = query.instance;
128128

129129
apiURL = queryInstanceURL ?? cookiesInstanceURL ?? defaultInstanceURL;
130130
res.setHeader('set-cookie', [`${COOKIE_INSTANCE_URL}=${apiURL}`]);

src/components/ExperiencePreview/ExperienceSignIn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const ExperienceSignIn: React.FC<ExperienceSignInProps> = props => {
2626

2727
const handleSignIn = async () => {
2828
onClose();
29-
router.push(`/login?rpc=${cookies[COOKIE_INSTANCE_URL]}`);
29+
router.push(`/login?instance=${cookies[COOKIE_INSTANCE_URL]}`);
3030
};
3131

3232
return (

src/components/Mobile/MenuDrawer/MenuDrawer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ export const MenuDrawerComponent: React.FC = () => {
118118
};
119119

120120
const handleSignOut = async () => {
121-
await logout(`/?rpc=${cookies[COOKIE_INSTANCE_URL]}`);
121+
await logout(`/?instance=${cookies[COOKIE_INSTANCE_URL]}`);
122122
};
123123

124124
const handleLoginOrCreateAccount = () => {
125-
router.push({pathname: '/login', query: {rpc: cookies[COOKIE_INSTANCE_URL]}});
125+
router.push({pathname: '/login', query: {instance: cookies[COOKIE_INSTANCE_URL]}});
126126
};
127127

128128
const openMenu = (item: MenuDetail) => () => {

src/components/ProfileCard/ProfileCard.container.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ export const ProfileCardContainer: React.FC<Props> = ({toggleNotification}) => {
3737
};
3838

3939
const handleSignOut = async () => {
40-
await logout(`/?rpc=${cookies[COOKIE_INSTANCE_URL]}`);
40+
await logout(`/?instance=${cookies[COOKIE_INSTANCE_URL]}`);
4141
};
4242

4343
const handleLoginOrCreateAccount = () => {
44-
router.push({pathname: '/login', query: {rpc: cookies[COOKIE_INSTANCE_URL]}});
44+
router.push({pathname: '/login', query: {instance: cookies[COOKIE_INSTANCE_URL]}});
4545
};
4646

4747
const handleShowNotificationList = () => {

src/components/SelectServer/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const SelectServer = ({
9696
setSelectedServer(server);
9797

9898
if (page === 'login') {
99-
const query = {...router.query, rpc: server.apiUrl};
99+
const query = {...router.query, instance: server.apiUrl};
100100
await router.replace({query}, undefined, {shallow: true});
101101
setCookies(COOKIE_INSTANCE_URL, server.apiUrl);
102102

@@ -124,7 +124,7 @@ const SelectServer = ({
124124
const query = session?.user?.email
125125
? `&email=${session.user.email}`
126126
: `&network=${currentWallet.networkId}`;
127-
await logout(`/login?rpc=${server.apiUrl}${query}`);
127+
await logout(`/login?instance=${server.apiUrl}${query}`);
128128
};
129129

130130
const isMobile = useMediaQuery(theme.breakpoints.down('xs'));

0 commit comments

Comments
 (0)