Skip to content

Commit

Permalink
Merge pull request #329 from dappforce/deploy/redirect
Browse files Browse the repository at this point in the history
Integrate redirect-hard message to fix suggest feature redirect issue
  • Loading branch information
olehmell authored Mar 8, 2024
2 parents 1fc14b2 + f20aec1 commit dd9a89c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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

0 comments on commit dd9a89c

Please sign in to comment.