diff --git a/next.config.js b/next.config.js index 743d89ee5f..4572a13ba2 100644 --- a/next.config.js +++ b/next.config.js @@ -43,6 +43,10 @@ const nextConfig = { name: 'removeDimensions', active: true, }, + { + name: 'prefixIds', + active: true, + }, ], }, }, diff --git a/package-lock.json b/package-lock.json index 1533138342..c4b27a97e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "matters-web", - "version": "4.13.2", + "version": "4.13.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "matters-web", - "version": "4.13.2", + "version": "4.13.4", "license": "Apache-2.0", "dependencies": { "@apollo/react-common": "^3.1.3", @@ -14,7 +14,7 @@ "@apollo/react-ssr": "^3.1.3", "@ensdomains/content-hash": "^2.5.7", "@matters/apollo-upload-client": "^11.1.0", - "@matters/matters-editor": "^0.1.27-alpha.1", + "@matters/matters-editor": "^0.1.27-alpha.3", "@next/bundle-analyzer": "^13.1.1", "@reach/alert": "^0.17.0", "@reach/dialog": "^0.17.0", @@ -6459,9 +6459,9 @@ } }, "node_modules/@matters/matters-editor": { - "version": "0.1.27-alpha.1", - "resolved": "https://registry.npmjs.org/@matters/matters-editor/-/matters-editor-0.1.27-alpha.1.tgz", - "integrity": "sha512-9Uc8dE/vy1iKqbr8zklaX/IQiqT6YsdK5eAZ0W5ATOXVcSYmiNuZ9Xt+rLuFd8SsZmiEf8cZw9a8nh+2N3o7kg==", + "version": "0.1.27-alpha.3", + "resolved": "https://registry.npmjs.org/@matters/matters-editor/-/matters-editor-0.1.27-alpha.3.tgz", + "integrity": "sha512-mOfHXg9SNDzGf3Td+3YBqqGP3rjQclx0nijZB+hHCEhQMR+AgLd2C+6HDBxtB1WYCidMAiLrK9WA7ewttwEHBg==", "dependencies": { "autosize": "^4.0.2", "classnames": "^2.2.6", @@ -47760,9 +47760,9 @@ } }, "@matters/matters-editor": { - "version": "0.1.27-alpha.1", - "resolved": "https://registry.npmjs.org/@matters/matters-editor/-/matters-editor-0.1.27-alpha.1.tgz", - "integrity": "sha512-9Uc8dE/vy1iKqbr8zklaX/IQiqT6YsdK5eAZ0W5ATOXVcSYmiNuZ9Xt+rLuFd8SsZmiEf8cZw9a8nh+2N3o7kg==", + "version": "0.1.27-alpha.3", + "resolved": "https://registry.npmjs.org/@matters/matters-editor/-/matters-editor-0.1.27-alpha.3.tgz", + "integrity": "sha512-mOfHXg9SNDzGf3Td+3YBqqGP3rjQclx0nijZB+hHCEhQMR+AgLd2C+6HDBxtB1WYCidMAiLrK9WA7ewttwEHBg==", "requires": { "autosize": "^4.0.2", "classnames": "^2.2.6", diff --git a/package.json b/package.json index 2d04a3b7c9..1becb1ab65 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matters-web", - "version": "4.13.3", + "version": "4.13.5", "description": "codebase of Matters' website", "sideEffects": false, "author": "Matters ", @@ -36,7 +36,7 @@ "@apollo/react-ssr": "^3.1.3", "@ensdomains/content-hash": "^2.5.7", "@matters/apollo-upload-client": "^11.1.0", - "@matters/matters-editor": "^0.1.27-alpha.1", + "@matters/matters-editor": "^0.1.27-alpha.3", "@next/bundle-analyzer": "^13.1.1", "@reach/alert": "^0.17.0", "@reach/dialog": "^0.17.0", diff --git a/src/common/utils/number/index.ts b/src/common/utils/number/index.ts index 474bcef18f..802ab682d9 100644 --- a/src/common/utils/number/index.ts +++ b/src/common/utils/number/index.ts @@ -9,7 +9,7 @@ export const numPrefix = (num: number | string) => { return parsedNum > 0 ? `+${num}` : num } -export const numAbbr = (num: number, decPlaces: number = 2) => +export const numAbbr = (num: number, decPlaces: number = 1) => abbr(num, decPlaces) export const numRound = (num: number, decPlaces: number = 2) => { diff --git a/src/components/Dialogs/LikeCoinDialog/SetupLikeCoin/Binding/index.tsx b/src/components/Dialogs/LikeCoinDialog/SetupLikeCoin/Binding/index.tsx index 0923685e47..885ee1443b 100644 --- a/src/components/Dialogs/LikeCoinDialog/SetupLikeCoin/Binding/index.tsx +++ b/src/components/Dialogs/LikeCoinDialog/SetupLikeCoin/Binding/index.tsx @@ -1,6 +1,6 @@ import { useQuery } from '@apollo/react-hooks' import gql from 'graphql-tag' -import { useEffect, useState } from 'react' +import { useEffect } from 'react' import { Dialog, Spinner, Translate } from '~/components' import { ViewerLikerIdQuery } from '~/gql/graphql' @@ -23,15 +23,22 @@ const VIEWER_LIKER_ID = gql` ` const Binding: React.FC = ({ prevStep, nextStep, windowRef }) => { - const [polling, setPolling] = useState(true) - const { data, error } = useQuery(VIEWER_LIKER_ID, { - pollInterval: polling ? 1000 : undefined, - errorPolicy: 'none', - fetchPolicy: 'network-only', - skip: typeof window === 'undefined', - }) + const { data, error, startPolling, stopPolling } = + useQuery(VIEWER_LIKER_ID, { + errorPolicy: 'none', + fetchPolicy: 'network-only', + skip: typeof window === 'undefined', + }) const likerId = data?.viewer?.liker.likerId + useEffect(() => { + startPolling(1000) + + return () => { + stopPolling() + } + }, []) + useEffect(() => { if (likerId) { nextStep() @@ -44,7 +51,7 @@ const Binding: React.FC = ({ prevStep, nextStep, windowRef }) => { } if (error) { - setPolling(false) + stopPolling() } }) diff --git a/src/components/Dialogs/TagEditorDialog/List/index.tsx b/src/components/Dialogs/TagEditorDialog/List/index.tsx index 98b40f86c3..548a54581f 100644 --- a/src/components/Dialogs/TagEditorDialog/List/index.tsx +++ b/src/components/Dialogs/TagEditorDialog/List/index.tsx @@ -144,7 +144,7 @@ const TagEditorList = ({ id, closeDialog, toAddStep, toRemoveStep }: Props) => {
{(isHavingNoneEditors || isReachingLimit) && ( @@ -152,9 +152,14 @@ const TagEditorList = ({ id, closeDialog, toAddStep, toRemoveStep }: Props) => { + 4 + - {' 4 '} )} {isAllowAdd && isHavingEditors && ( @@ -162,16 +167,16 @@ const TagEditorList = ({ id, closeDialog, toAddStep, toRemoveStep }: Props) => { {4 - count} + )} -

@@ -186,7 +191,7 @@ const TagEditorList = ({ id, closeDialog, toAddStep, toRemoveStep }: Props) => { diff --git a/src/components/Forms/PaymentForm/ConnectStripeAccount/Onboarding.tsx b/src/components/Forms/PaymentForm/ConnectStripeAccount/Onboarding.tsx index 9ac2f3f4b7..d1a5b0bb9d 100644 --- a/src/components/Forms/PaymentForm/ConnectStripeAccount/Onboarding.tsx +++ b/src/components/Forms/PaymentForm/ConnectStripeAccount/Onboarding.tsx @@ -1,6 +1,6 @@ import { useQuery } from '@apollo/react-hooks' import gql from 'graphql-tag' -import { useState } from 'react' +import { useEffect, useState } from 'react' import { Dialog, Spinner, Translate } from '~/components' import { ViewerStripeAccountQuery } from '~/gql/graphql' @@ -25,17 +25,24 @@ const VIEWER_STRIPE_ACCOUNT = gql` const Onboarding: React.FC = ({ nextStep }) => { const [polling, setPolling] = useState(true) - const { data, error } = useQuery( - VIEWER_STRIPE_ACCOUNT, - { - pollInterval: polling ? 1000 : undefined, + const { data, error, startPolling, stopPolling } = + useQuery(VIEWER_STRIPE_ACCOUNT, { errorPolicy: 'none', fetchPolicy: 'network-only', skip: typeof window === 'undefined', - } - ) + }) const stripeAccount = data?.viewer?.wallet.stripeAccount?.id + useEffect(() => { + if (polling) { + startPolling(1000) + } + + return () => { + stopPolling() + } + }, [polling]) + if (stripeAccount) { nextStep() return null diff --git a/src/components/Forms/PaymentForm/Processing/index.tsx b/src/components/Forms/PaymentForm/Processing/index.tsx index 3eaace2f3f..bc5d271011 100644 --- a/src/components/Forms/PaymentForm/Processing/index.tsx +++ b/src/components/Forms/PaymentForm/Processing/index.tsx @@ -2,7 +2,7 @@ import { useQuery } from '@apollo/react-hooks' import { ethers } from 'ethers' import gql from 'graphql-tag' import _get from 'lodash/get' -import { useContext, useEffect, useState } from 'react' +import { useContext, useEffect } from 'react' import { useAccount, useContractWrite, useNetwork } from 'wagmi' import { @@ -76,14 +76,13 @@ const OthersProcessingForm: React.FC = ({ closeDialog, windowRef, }) => { - const [polling, setPolling] = useState(true) - const { data, error } = useQuery(VIEWER_TX_STATE, { - variables: { id: txId }, - pollInterval: polling ? 1000 : undefined, - errorPolicy: 'none', - fetchPolicy: 'network-only', - skip: typeof window === 'undefined', - }) + const { data, error, startPolling, stopPolling } = + useQuery(VIEWER_TX_STATE, { + variables: { id: txId }, + errorPolicy: 'none', + fetchPolicy: 'network-only', + skip: typeof window === 'undefined', + }) const txState = _get(data, 'viewer.wallet.transactions.edges.0.node.state') const succeededFn = () => { @@ -101,19 +100,27 @@ const OthersProcessingForm: React.FC = ({ } } - if (txState === 'succeeded') { - if (currency === CURRENCY.HKD) { - setTimeout(() => { - succeededFn() - }, 3 * 1000) + useEffect(() => { + if (error) { + stopPolling() } else { - succeededFn() + startPolling(1000) } - } - if (error) { - setPolling(false) - } + return () => {} + }, [error]) + + useEffect(() => { + if (txState === 'succeeded') { + if (currency === CURRENCY.HKD) { + setTimeout(() => { + succeededFn() + }, 3 * 1000) + } else { + succeededFn() + } + } + }, [txState]) return ( <> diff --git a/src/components/Forms/PaymentForm/SubscribeCircle/Processing/index.tsx b/src/components/Forms/PaymentForm/SubscribeCircle/Processing/index.tsx index a70c07633a..118371b570 100644 --- a/src/components/Forms/PaymentForm/SubscribeCircle/Processing/index.tsx +++ b/src/components/Forms/PaymentForm/SubscribeCircle/Processing/index.tsx @@ -1,6 +1,5 @@ import { useQuery } from '@apollo/react-hooks' -import _get from 'lodash/get' -import { useState } from 'react' +import { useEffect } from 'react' import { Dialog, Spinner, Translate } from '~/components' import { ViewerCircleStateQuery } from '~/gql/graphql' @@ -13,27 +12,30 @@ interface Props { } const Processing: React.FC = ({ circleName, nextStep }) => { - const [polling, setPolling] = useState(true) - const { data, error } = useQuery( - VIEWER_CIRLCE_STATE, - { + const { data, error, startPolling, stopPolling } = + useQuery(VIEWER_CIRLCE_STATE, { variables: { name: circleName }, - pollInterval: polling ? 1000 : undefined, errorPolicy: 'none', fetchPolicy: 'network-only', skip: typeof window === 'undefined', - } - ) + }) const isMember = data?.circle?.isMember - if (isMember) { - nextStep() - return null - } + useEffect(() => { + if (error) { + stopPolling() + } else { + startPolling(1000) + } - if (error) { - setPolling(false) - } + return () => {} + }, [error]) + + useEffect(() => { + if (isMember) { + nextStep() + } + }, [isMember]) return ( diff --git a/src/components/Head/index.tsx b/src/components/Head/index.tsx index 6a87c9429e..2666105fe3 100644 --- a/src/components/Head/index.tsx +++ b/src/components/Head/index.tsx @@ -1,5 +1,4 @@ import NextHead from 'next/head' -import NextScript from 'next/script' import { useContext } from 'react' import IMAGE_APPLE_TOUCH_ICON from '@/public/static/apple-touch-icon.png' @@ -219,13 +218,6 @@ export const Head: React.FC = (props) => { key="ld-json-data" /> )} - - ) } diff --git a/src/components/Notice/NoticeActorAvatar.tsx b/src/components/Notice/NoticeActorAvatar.tsx index 377032799d..b92f4cc344 100644 --- a/src/components/Notice/NoticeActorAvatar.tsx +++ b/src/components/Notice/NoticeActorAvatar.tsx @@ -23,7 +23,9 @@ const NoticeActorAvatar = ({ return ( - + + + ) } diff --git a/src/components/Notice/NoticeActorName.tsx b/src/components/Notice/NoticeActorName.tsx index fc9474d4db..148becb01e 100644 --- a/src/components/Notice/NoticeActorName.tsx +++ b/src/components/Notice/NoticeActorName.tsx @@ -18,7 +18,11 @@ const NoticeActorName = ({ userName: user.userName || '', }) - return {user.displayName} + return ( + + {user.displayName} + + ) } NoticeActorName.fragments = { diff --git a/src/components/Notice/NoticeArticleTitle.tsx b/src/components/Notice/NoticeArticleTitle.tsx index a06e143af4..7397ae5f11 100644 --- a/src/components/Notice/NoticeArticleTitle.tsx +++ b/src/components/Notice/NoticeArticleTitle.tsx @@ -22,7 +22,11 @@ const NoticeArticleTitle = ({ }) if (!isBlock) { - return {article.title} + return ( + + {article.title} + + ) } return diff --git a/src/components/Notice/NoticeCircleName.tsx b/src/components/Notice/NoticeCircleName.tsx index ec1c468f41..aeb3042785 100644 --- a/src/components/Notice/NoticeCircleName.tsx +++ b/src/components/Notice/NoticeCircleName.tsx @@ -20,7 +20,11 @@ const NoticeCircleName = ({ circle, }) - return {circle.displayName} + return ( + + {circle.displayName} + + ) } NoticeCircleName.fragments = { diff --git a/src/components/TagDigest/Feed/styles.css b/src/components/TagDigest/Feed/styles.css index fbbab126a9..794bf010ae 100644 --- a/src/components/TagDigest/Feed/styles.css +++ b/src/components/TagDigest/Feed/styles.css @@ -8,6 +8,7 @@ header { .nums { display: inline-flex; + flex-shrink: 0; & :global(> * + *) { margin-left: var(--spacing-x-tight); diff --git a/src/components/TagDigest/Sidebar/styles.css b/src/components/TagDigest/Sidebar/styles.css index b3a06830d1..3a0759ed6c 100644 --- a/src/components/TagDigest/Sidebar/styles.css +++ b/src/components/TagDigest/Sidebar/styles.css @@ -36,7 +36,7 @@ margin-top: var(--spacing-x-tight); & :global(> *) { - width: 3.625rem; + width: 4rem; } & :global(> * + *) { diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index eed1389498..47afefb53f 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -1,4 +1,5 @@ import Document, { Head, Html, Main, NextScript } from 'next/document' +import Script from 'next/script' import React from 'react' import { CSP_POLICY } from '~/common/enums' @@ -18,6 +19,13 @@ class MattersDocument extends Document {
+ +