Skip to content

Commit

Permalink
Datahub Proxy (#449)
Browse files Browse the repository at this point in the history
* Send post data to datahub before sending tx

* Add todo

* Change all subscription to use datahub subs

* Change posts api to use datahub

* Update link for datahub

* Fix id issue in get post

* Integrate sending optimistic messages

* Fix cache issue with comment ids

* Fixed subscription for persistent event

* Fix subscription logic

* Make websocket connection singleton

* Update optimistic

* Update all useSubsocialMutation calls

* Fix type error

* Refactor subscription code

* Add sending status to message indicator

* Add loading status

* Add offset to center spinner

* Improve client optimistic to datahub message order

* Fix subscription logic

* feat: added tmp script for data-hub-sdk install (#395)

* fix: fixed dh-sdk installation in dockerfile

* Refactor subscription

* Change subscription method

* Update type error

* Update types for subscription

* Fix type errro

* Use optimistic data but update its id

* Fix cache issue

* Add reply data

* Remove logs

* Send create post to datahub before waiting energy

* Generate CID from client side

* Update datahub post fragment name

* Remove unused file

* Send upsert post data to datahub

* Refactor subscription logic to work for all post type

* Fix update flow with data hub

* Remove loading state

* Add edit

* Improve edit message handling

* Finish update post logic

* Make update message feedback instant

* Fix type error

* Change edit message color

* Change to https and send txSig to datahub

* Add back wss configs

* Add txSig for upsert post

* Add option to use http instead of wss

* Use codegen with new staging

* Update types

* Fix types

* Wait saving file before sending tx

* Update types

* Improve type usage

* Add create message failed handling

* Allow window unload if blockchain failed

* Refactor checkmark modal

* Add resend failed message mutation

* Fix type error

* Finish resend message functionality

* Change commentids data source to use datahub

* Update datatype of synth call to offchain

* Add new flow for sig

* Revert back subsocial query mutation

* Remove unused callbacks

* Remove supress error config

* Create better handling for tx error

* Update upsert post datahub imple

* Rename query

* Move datahub urls to env

* Add back metadata getter for posts

* Move datahub services and create fallback system for it

* Adjust error if datahub config is not there

* Add fallback for get comment ids

* Add subscribe option for fallback in getting comment ids

* Update export names

* Fix wrong logic in datahub mutation wrapper

* Finish fallback control if datahub not exist

* Make 1025 space not have join btn

* Not disconnect websocket if any pending tx

* Add pending transaction to request token

* Fix issue with waiting energy

How to replicate issue: send message and immediately go to different tab

* Fix invalidation for datahub posts

* Add notify update fail call

* Add ci for envs

* Fix issue update chat removes extensions

* Update wrong import

* Integrate new query for getting last message

* Fix last comment query prefetched

* Change query

* Update post metadata query

* Update unread count

* Integrate unread count query

* Add wrapper for datahub queries

* Fix datahub logic

* Increase datahub timeout because getting comment ids takes a pretty long time

* Update datahub staging url

* Fix issue where datahub fetcher is not used

* Revalidate page after upsert post and moderate

* Add revalidate path after some mutations

* Add await to make revalidate chat page error caught

* Add info when message is not sent

* Fix 0 unread count showing

* Remove jsonabc types

* Remove captcha validation if no env captcha

* Remove captcha envs in staging

* Remove recaptcha if no sitekey

* Fix invisible captcha waiting infinitely without captcha site key

* Add retry connect ws

* Fix refetch on window focus and subscription logic

* Fix flashing of unread message in chat page after sending new message

* Move datahub mutation to backend

* Change mutation config envs

* Add mutation token

* Fix optimistic messages disappear when invalidating

* Add validation to not call datahub for posts with client optimistic id

* Add rate limit error management

* Add secrets to datahub mutation token

* Remove logs

* Fix issue with sending message before logging in

* Fix optimistic messages not removed when commentids invalidated

* Fix type error

* Update rate limit error

* Disable input if rate limited

* Fix wrong timeout seconds

* Update rate limit error

* Resolve PR comments

* Fix error

* Increment version

* Update prod env

* Update prod env

* Improve datahub error desc

* Finish first version of optimization of comment ids

* Fix post metadata prefetch not working

* Add optimistic client side message

* Make ann unread count no need to update every window refocus

* remove useHttp so all tx uses wss

* Rename fetcher

* Add refetching of first page

* Update env

* Add timestamp and uuid field to datahub mutation

* Add protVersion

* Support deterministic id for sent message status

* Remove console logs and uncomment codes

* Add offchain posting

* Update staging url for datahub

* Fix wrong ordering of new messages

* Fix wrong env

* Move offchain posting button

* Add offchain flag

* Fix offchain message

* fix: tmp fix of getDeterministicId import

* Fix type errors

* Use proxy address if exist for optimistic data

* Update datahub env

* Fix optimistic id getting error

* Fix issue where error happen when no data in setfirstquerydata

* Remove offchain posting button

* fix: fixed createSocialDataEventInput func params (#451)

* Fix issue with wrong callname

* Remove dh-sdk-i

* turn off dh

* Not call datahub query when its turned off

* Fix delete optimistic data

* Fix mutation when datahub is turned off

* Remove edit if datahub is not enabled

* Fix issue with pageParams

* Change back feature based env

* Remove logs

* Change mutation url and mutation token env to queue

* Fix issue with profile modal opening after logout and login again

* Remove unused package

* Remove hack script

* Unify datahub flag var name

* Unify error names into one object

* Use single color for blockchain or optimistic messages

* Revert "Change mutation url and mutation token env to queue"

This reverts commit 3ed3a20.

* Remove unused var

* Update wording

* Improve readability

* Add todo for refactoring datahub query

* Refactor datahub queries

* Add todo

* Uncomment use load more if no scroll

* Remove unnecessary hook

* Remove unnecessary param for scroll to message

* Fix unread count

* Fix issue with scroll to message

* Fix unread count in notice

* Remove logs

* Fix get chat element logic

* Fix wrong logic to get last id

* Fix storage call to update last read

* Fix post id not pooled correctly if requested id is optimistic but result is already persistent

* Add optimistic message modal detail

* Change message redirect if its already persistent

---------

Co-authored-by: Max Kravchuk <[email protected]>
  • Loading branch information
teodorus-nathaniel and mckrava authored Nov 7, 2023
1 parent 743ea6d commit 9b93e5c
Show file tree
Hide file tree
Showing 110 changed files with 5,053 additions and 969 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ jobs:
GH_NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=grill-web-push.appspot.com
GH_NEXT_PUBLIC_FIREBASE_MESSAGING_ID=762898090466
GH_NEXT_PUBLIC_FIREBASE_APP_ID=1:762898090466:web:2a09d26c3bab706b95d1bb
GH_NEXT_PUBLIC_DATAHUB_QUERY_URL=https://data-hub.subsocial.network/graphql
GH_NEXT_PUBLIC_DATAHUB_SUBSCRIPTION_URL=wss://data-hub.subsocial.network/graphql-ws
GH_DATAHUB_MUTATION_URL=https://queue-data-hub.subsocial.network/graphql
GH_DATAHUB_MUTATION_TOKEN=${{ secrets.DATAHUB_MUTATION_TOKEN }}
target: runner
tags: |
${{ env.image }}
Expand Down Expand Up @@ -111,6 +115,10 @@ jobs:
GH_NEXT_PUBLIC_CAPTCHA_SITE_KEY=6LcnGU0lAAAAANPvuR2I3gZswHpX1GJnpJG2ocVb
GH_SERVER_DISCUSSION_CREATOR_MNEMONIC=${{ secrets.SERVER_DISCUSSION_CREATOR_MNEMONIC }}
GH_COVALENT_API_KEY=${{ secrets.COVALENT_API_KEY }}
GH_NEXT_PUBLIC_DATAHUB_QUERY_URL=https://data-hub.subsocial.network/graphql
GH_NEXT_PUBLIC_DATAHUB_SUBSCRIPTION_URL=wss://data-hub.subsocial.network/graphql-ws
GH_DATAHUB_MUTATION_URL=https://queue-data-hub.subsocial.network/graphql
GH_DATAHUB_MUTATION_TOKEN=${{ secrets.DATAHUB_MUTATION_TOKEN }}
target: storybook
tags: |
${{ env.image }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/feature-based.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ jobs:
build-args: |
GH_SERVER_MNEMONIC=plunge pumpkin penalty segment cattle more print below fat lemon clap uniform
GH_SERVER_DISCUSSION_CREATOR_MNEMONIC=plunge pumpkin penalty segment cattle more print below fat lemon clap uniform
GH_CAPTCHA_SECRET=6LeWW0QlAAAAABwWU1iEEb2RlfRRbj8fz2X04iNW
GH_SUBSOCIAL_PROMO_SECRET_HEX=0x836aa9c5e78c3aebb3526e6bc14b10e6bef02d8b07ee218cdd9dd5a32b2791cf
GH_USER_ID_SALT=salt
GH_CRUST_IPFS_AUTH=eyJkYXRhIjp7ImRvbWFpbiI6eyJjaGFpbklkIjoiNSIsIm5hbWUiOiJDbG91ZDMuY2MiLCJ2ZXJpZnlpbmdDb250cmFjdCI6IjB4Q2NDQ2NjY2NDQ0NDY0NDQ0NDQ2NDY0NjY0NjQ0NDY0NjY2NjY2NjQyIsInZlcnNpb24iOiIxIn0sIm1lc3NhZ2UiOnsiZGVzY3JpcHRpb24iOiJTaWduIGZvciBXMyBCdWNrZXQgQWNjZXNzIEF1dGhlbnRpY2F0aW9uIiwic2lnbmluZ0FkZHJlc3MiOiIweDAwNDFjNzA1ZTEwNmVlOWRFMjI3Q2ExMzlBZDRBOTlEQjY0NENCM2EiLCJ0b2tlbkFkZHJlc3MiOiIweDM5ODY2Mzg0MjY4MDMzMkExQWJBM0IwM2JkNmRCNDdhRTk4NDk5NEMiLCJ0b2tlbklkIjoiMzAwMDAzNyIsImVmZmVjdGl2ZVRpbWVzdGFtcCI6MTY3ODUzNzYxNywiZXhwaXJhdGlvblRpbWVzdGFtcCI6MH0sInByaW1hcnlUeXBlIjoiVzNCdWNrZXQiLCJ0eXBlcyI6eyJXM0J1Y2tldCI6W3sibmFtZSI6ImRlc2NyaXB0aW9uIiwidHlwZSI6InN0cmluZyJ9LHsibmFtZSI6InNpZ25pbmdBZGRyZXNzIiwidHlwZSI6ImFkZHJlc3MifSx7Im5hbWUiOiJ0b2tlbkFkZHJlc3MiLCJ0eXBlIjoiYWRkcmVzcyJ9LHsibmFtZSI6InRva2VuSWQiLCJ0eXBlIjoic3RyaW5nIn0seyJuYW1lIjoiZWZmZWN0aXZlVGltZXN0YW1wIiwidHlwZSI6InVpbnQyNTYifSx7Im5hbWUiOiJleHBpcmF0aW9uVGltZXN0YW1wIiwidHlwZSI6InVpbnQyNTYifV19fSwic2lnbmF0dXJlIjoiMHhhMTUxODkyZGNhMTZlMTJkZmViYTFjY2FkMjNmZjM5MGVmODQ1MzdhMGI2MWI4YWQ1NDY1ZGI1ZjI1NjZkMWJmMjc3MGE1OTQyMzFmNzFmYzA5YWVlZGJhNzJkZjM5Y2Y4NDIxMTQ3YzJkNWQyNTFkNDZjNGQyMDFlOGM1MmUzZTFjIn0=
GH_NEXT_PUBLIC_CAPTCHA_SITE_KEY=6LeWW0QlAAAAAL1u_pgngcjyH211q3dipMItu_5f
GH_NEXT_PUBLIC_SPACE_IDS=1002,1005,1010,1011,1023,1025,1030,1031
GH_MODERATION_URL=https://staging-moderation.subsocial.network/graphql
GH_MODERATION_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZG1pbiI6dHJ1ZX0.Ao4w7g-TvV-o5KgxEiHvSgdxN6MAe0mHe7jS0ZT5rLY
Expand All @@ -77,6 +75,10 @@ jobs:
GH_NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=gl-notifications-dev.appspot.com
GH_NEXT_PUBLIC_FIREBASE_MESSAGING_ID=581626459774
GH_NEXT_PUBLIC_FIREBASE_APP_ID=1:581626459774:web:6b7098eb48c0b142f50a2f
GH_NEXT_PUBLIC_DATAHUB_QUERY_URL=https://proxy-signer-data-hub.subsocial.network/graphql
GH_NEXT_PUBLIC_DATAHUB_SUBSCRIPTION_URL=wss://proxy-signer-data-hub.subsocial.network/graphql-ws
GH_DATAHUB_MUTATION_URL=https://proxy-signer-queue-data-hub.subsocial.network/graphql
GH_DATAHUB_MUTATION_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZG1pbiI6dHJ1ZX0.jpXwkIJ4DpV4IvSI3eWVVXE6x89qr_GIq7IlbBv5YE0
target: runner
tags: |
${{ env.image }}
Expand Down
4 changes: 4 additions & 0 deletions ci.env
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ CRUST_IPFS_AUTH='GH_CRUST_IPFS_AUTH'
USER_ID_SALT='$GH_USER_ID_SALT'
COVALENT_API_KEY='$GH_COVALENT_API_KEY'
SUBSOCIAL_PROMO_SECRET_HEX='$GH_SUBSOCIAL_PROMO_SECRET_HEX'
NEXT_PUBLIC_DATAHUB_QUERY_URL='$GH_NEXT_PUBLIC_DATAHUB_QUERY_URL'
NEXT_PUBLIC_DATAHUB_SUBSCRIPTION_URL='$GH_NEXT_PUBLIC_DATAHUB_SUBSCRIPTION_URL'
DATAHUB_MUTATION_URL='$GH_DATAHUB_MUTATION_URL'
DATAHUB_MUTATION_TOKEN='$GH_DATAHUB_MUTATION_TOKEN'
21 changes: 21 additions & 0 deletions codegen-datahub-mutation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { CodegenConfig } from '@graphql-codegen/cli'

const mutationUrl = process.env.DATAHUB_MUTATION_URL
if (!mutationUrl) throw new Error('Codegen error: Datahub Mutation URL not set')

const config: CodegenConfig = {
overwrite: true,
schema: mutationUrl,
documents: 'src/server/datahub/**/*.ts',
generates: {
'src/server/datahub/generated-mutation.ts': {
plugins: [
'typescript',
'typescript-operations',
'typescript-document-nodes',
],
},
},
}

export default config
22 changes: 22 additions & 0 deletions codegen-datahub-query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { CodegenConfig } from '@graphql-codegen/cli'

const queryUrl = process.env.NEXT_PUBLIC_DATAHUB_QUERY_URL
if (!queryUrl) throw new Error('Codegen error: Datahub Query URL not set')

const config: CodegenConfig = {
overwrite: true,
schema: queryUrl,
documents:
'src/services/subsocial/datahub/**/{fetcher,subscription,query}.ts',
generates: {
'src/services/subsocial/datahub/generated-query.ts': {
plugins: [
'typescript',
'typescript-operations',
'typescript-document-nodes',
],
},
},
}

export default config
20 changes: 18 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ ARG GH_IPFS_WRITE_URL
ARG GH_IPFS_PIN_URL
ARG GH_COVALENT_API_KEY
ARG GH_SUBSOCIAL_PROMO_SECRET_HEX
ARG GH_NEXT_PUBLIC_DATAHUB_QUERY_URL
ARG GH_NEXT_PUBLIC_DATAHUB_SUBSCRIPTION_URL
ARG GH_DATAHUB_MUTATION_URL
ARG GH_DATAHUB_MUTATION_TOKEN

ENV NEXT_PUBLIC_CAPTCHA_SITE_KEY=${GH_NEXT_PUBLIC_CAPTCHA_SITE_KEY} \
NEXT_PUBLIC_SPACE_IDS=${GH_NEXT_PUBLIC_SPACE_IDS} \
Expand All @@ -52,7 +56,11 @@ ENV NEXT_PUBLIC_CAPTCHA_SITE_KEY=${GH_NEXT_PUBLIC_CAPTCHA_SITE_KEY} \
SERVER_MNEMONIC=${GH_SERVER_MNEMONIC} \
SERVER_DISCUSSION_CREATOR_MNEMONIC=${GH_SERVER_DISCUSSION_CREATOR_MNEMONIC} \
COVALENT_API_KEY=${GH_COVALENT_API_KEY} \
SUBSOCIAL_PROMO_SECRET_HEX=${GH_SUBSOCIAL_PROMO_SECRET_HEX}
SUBSOCIAL_PROMO_SECRET_HEX=${GH_SUBSOCIAL_PROMO_SECRET_HEX} \
NEXT_PUBLIC_DATAHUB_QUERY_URL=${GH_NEXT_PUBLIC_DATAHUB_QUERY_URL} \
NEXT_PUBLIC_DATAHUB_SUBSCRIPTION_URL=${GH_NEXT_PUBLIC_DATAHUB_SUBSCRIPTION_URL} \
DATAHUB_MUTATION_URL=${GH_DATAHUB_MUTATION_URL} \
DATAHUB_MUTATION_TOKEN=${GH_DATAHUB_MUTATION_TOKEN}

WORKDIR /opt/subsocial/app

Expand Down Expand Up @@ -94,6 +102,10 @@ ARG GH_IPFS_WRITE_URL
ARG GH_IPFS_PIN_URL
ARG GH_COVALENT_API_KEY
ARG GH_SUBSOCIAL_PROMO_SECRET_HEX
ARG GH_NEXT_PUBLIC_DATAHUB_QUERY_URL
ARG GH_NEXT_PUBLIC_DATAHUB_SUBSCRIPTION_URL
ARG GH_DATAHUB_MUTATION_URL
ARG GH_DATAHUB_MUTATION_TOKEN

ENV NEXT_PUBLIC_CAPTCHA_SITE_KEY=${GH_NEXT_PUBLIC_CAPTCHA_SITE_KEY} \
NEXT_PUBLIC_SPACE_IDS=${GH_NEXT_PUBLIC_SPACE_IDS} \
Expand All @@ -120,7 +132,11 @@ ENV NEXT_PUBLIC_CAPTCHA_SITE_KEY=${GH_NEXT_PUBLIC_CAPTCHA_SITE_KEY} \
SERVER_MNEMONIC=${GH_SERVER_MNEMONIC} \
SERVER_DISCUSSION_CREATOR_MNEMONIC=${GH_SERVER_DISCUSSION_CREATOR_MNEMONIC} \
COVALENT_API_KEY=${GH_COVALENT_API_KEY} \
SUBSOCIAL_PROMO_SECRET_HEX=${GH_SUBSOCIAL_PROMO_SECRET_HEX}
SUBSOCIAL_PROMO_SECRET_HEX=${GH_SUBSOCIAL_PROMO_SECRET_HEX} \
NEXT_PUBLIC_DATAHUB_QUERY_URL=${GH_NEXT_PUBLIC_DATAHUB_QUERY_URL} \
NEXT_PUBLIC_DATAHUB_SUBSCRIPTION_URL=${GH_NEXT_PUBLIC_DATAHUB_SUBSCRIPTION_URL} \
DATAHUB_MUTATION_URL=${GH_DATAHUB_MUTATION_URL} \
DATAHUB_MUTATION_TOKEN=${GH_DATAHUB_MUTATION_TOKEN}

WORKDIR /opt/subsocial/app

Expand Down
1 change: 1 addition & 0 deletions integration/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Grill Widget

Grill Widget is a tiny package (< 1kb compressed) that you can use to integrate [Grill.chat](https://grill.chat) into your app. It wraps all of the available configs in a simple function call.

https://github.com/dappforce/grillchat/assets/39906111/1d1ca9b5-c49f-49e4-9c04-ae4a4a390b33
Expand Down
2 changes: 1 addition & 1 deletion integration/examples/dotfinder/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,5 @@

<!--**********************************
Grill Styles End
***********************************-->
***********************************-->
</html>
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"codegen:moderation": "graphql-codegen --require dotenv/config --config codegen-moderation.ts",
"codegen:squid": "graphql-codegen --require dotenv/config --config codegen-squid.ts",
"codegen:notifications": "graphql-codegen --require dotenv/config --config codegen-notifications.ts",
"codegen:datahub-query": "graphql-codegen --require dotenv/config --config codegen-datahub-query.ts",
"codegen:datahub-mutation": "graphql-codegen --require dotenv/config --config codegen-datahub-mutation.ts",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"start-storybook": "node ./.storybook/index.js"
Expand All @@ -38,13 +40,13 @@
"@polkadot/util": "^12.1.2",
"@rainbow-me/rainbowkit": "^1.0.11",
"@subsocial/api": "^0.8.14",
"@subsocial/data-hub-sdk": "dappforce/subsocial-data-hub-sdk#staging",
"@subsocial/grill-widget": "^0.0.8",
"@subsocial/utils": "0.8.14",
"@subwallet/wagmi-connector": "0.2.1",
"@talismn/connect-wallets": "^1.2.3",
"@talismn/wagmi-connector": "^0.3.1",
"@tanstack/react-query": "^4.24.10",
"@types/jsonabc": "^2.3.1",
"@types/lodash.truncate": "^4.4.7",
"@types/node": "18.14.1",
"@types/randomcolor": "^0.5.7",
Expand All @@ -67,9 +69,11 @@
"formidable": "^3.4.0",
"graphql": "^16.6.0",
"graphql-request": "^6.0.0",
"graphql-ws": "^5.14.0",
"html-metadata-parser": "^2.0.4",
"ioredis": "^5.3.2",
"jsonabc": "^2.3.1",
"ipfs-unixfs-importer": "7.0.1",
"isomorphic-ws": "^5.0.0",
"linkify-react": "^4.1.0",
"linkifyjs": "^4.1.0",
"localforage": "^1.10.0",
Expand Down Expand Up @@ -97,6 +101,7 @@
"react-tweet": "^3.1.0",
"sharp": "^0.32.1",
"slugify": "^1.6.6",
"sort-keys-recursive": "^2.1.9",
"tailwind-merge": "^1.10.0",
"typescript": "4.9.5",
"unique-names-generator": "^4.7.1",
Expand Down
9 changes: 7 additions & 2 deletions src/@types/subsocial.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ declare module '@subsocial/api/types' {
profileSource?: string
}
export interface PostContent extends SubsocialPostContent {
optimisticId?: string
linkMetadata?: LinkMetadata
inReplyTo?: {
kind: 'Post'
Expand All @@ -98,7 +99,11 @@ declare module '@subsocial/api/types' {
export declare type SpaceData = EntityPostData<SpaceStruct, SpaceContent>
export declare type PostData = EntityPostData<
PostStruct &
Pick<CommentStruct, 'rootPostId'> & { followersCount?: number },
Pick<CommentStruct, 'rootPostId'> & {
followersCount?: number
blockchainSyncFailed?: boolean
dataType?: 'persistent' | 'optimistic' | 'offChain'
},
PostContent
>
> & { requestedId?: string }
}
2 changes: 1 addition & 1 deletion src/components/BadgeManager.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { lastReadTimeLocalForage } from '@/hooks/useLastReadMessageId'
import { lastReadTimeLocalForage } from '@/components/chats/hooks/useLastReadMessageId'
import useWrapInRef from '@/hooks/useWrapInRef'
import { followedIdsStorage, useMyMainAddress } from '@/stores/my-account'
import { getSquidUrl } from '@/utils/env/client'
Expand Down
3 changes: 3 additions & 0 deletions src/components/auth/ProfileModal/contents/LogoutContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import Button from '@/components/Button'
import { useLinkFcm } from '@/services/api/notifications/mutation'
import { useSendEvent } from '@/stores/analytics'
import { useMyAccount } from '@/stores/my-account'
import { useProfileModal } from '@/stores/profile-modal'
import { ContentProps } from '../types'
import { fcmPushNotificationStorage } from './notifications/PushNotificationContent'

function LogoutContent({ setCurrentState }: ContentProps) {
const closeModal = useProfileModal((state) => state.closeModal)
const address = useMyAccount((state) => state.address)
const logout = useMyAccount((state) => state.logout)
const sendEvent = useSendEvent()
Expand All @@ -24,6 +26,7 @@ function LogoutContent({ setCurrentState }: ContentProps) {
linkFcm({ address, fcmToken, action: 'unlink' })
}
logout()
closeModal()
}

return (
Expand Down
25 changes: 16 additions & 9 deletions src/components/captcha/CaptchaInvisible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ export type CaptchaInvisibleProps = {

export default function CaptchaInvisible({ children }: CaptchaInvisibleProps) {
const captchaRef = useRef<ReCAPTCHA>(null)

const captchaSiteKey = getCaptchaSiteKey()

const runCaptcha = async () => {
if (!captchaSiteKey) return 'dummy-captcha'

let token: string | null = null
try {
console.log('waiting captcha...')
Expand Down Expand Up @@ -43,15 +48,17 @@ export default function CaptchaInvisible({ children }: CaptchaInvisibleProps) {
{children(runCaptcha, (className) => (
<CaptchaTermsAndService className={className} />
))}
<div className='hidden'>
<ReCAPTCHA
sitekey={getCaptchaSiteKey()}
theme='dark'
ref={captchaRef}
size='invisible'
badge='inline'
/>
</div>
{captchaSiteKey && (
<div className='hidden'>
<ReCAPTCHA
sitekey={getCaptchaSiteKey()}
theme='dark'
ref={captchaRef}
size='invisible'
badge='inline'
/>
</div>
)}
</>
)
}
Loading

0 comments on commit 9b93e5c

Please sign in to comment.