Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate redirect-hard message to fix suggest feature redirect issue #329

Merged
merged 4 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/components/profile-selector/MyAccountMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useRouter } from 'next/router'
import React, { createContext, FC, useContext, useEffect, useRef, useState } from 'react'
import { getCurrentUrlOrigin } from 'src/utils/url'
import { InfoDetails } from '../profiles/address-views'
Expand Down Expand Up @@ -67,14 +66,18 @@ const MyAccountDrawerContext = createContext<MyAccountSectionContextState>(initV
export const useMyAccountDrawer = () => useContext(MyAccountDrawerContext)

function parseMessage(data: string) {
const [origin, name, value] = data.split(':')
const match = data.match(/^([^:]+):([^:]+):(.+)$/)
if (!match) return null

const origin = match[1]
const name = match[2]
const value = match[3]
if (origin !== 'grill') return null
return { name: name ?? '', value: value ?? '' }
}
export const AccountMenu: React.FunctionComponent<AddressProps> = ({ address, owner }) => {
const iframeRef = useRef<HTMLIFrameElement | null>(null)
const [isOpenProfileModal, setIsOpenProfileModal] = useState(false)
const router = useRouter()

useEffect(() => {
window.onmessage = event => {
Expand All @@ -84,8 +87,9 @@ export const AccountMenu: React.FunctionComponent<AddressProps> = ({ address, ow
const { name, value } = message
if (name === 'profile' && value === 'close') {
setIsOpenProfileModal(false)
} else if (name === 'redirect') {
router.push(value)
} else if (name === 'redirect' || name === 'redirect-hard') {
// Using router push for redirect don't redirect properly, it just have loading for a bit and changes the url much later
window.location.href = value
setIsOpenProfileModal(false)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/config/app/grill/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const index: AppConfig = {
appBaseUrl: 'https://grillapp.net',
themeName: undefined,
metaTags: {
siteName: 'Grill: Grill: Monetize Every Like, Comment, Post | Web3 Social',
siteName: 'Grill: Monetize Every Like, Comment, Post | Web3 Social',
title: 'Grill: Monetize Every Like, Comment, Post | Web3 Social',
desc: 'Revolutionary Web3 social finance platform where bloggers and their followers earn together. Blockchain, NFT, and crypto content.',
defaultImage: '/images/grill-default-cover.png',
Expand Down
Loading