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

properly fetch hubs after repost + properly get users hubs on release… #1039

Merged
merged 3 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@mui/icons-material": "^5.4.1",
"@mui/material": "^5.6.3",
"@mui/styles": "^5.6.2",
"@nina-protocol/js-sdk": "^0.0.14",
"@nina-protocol/js-sdk": "^0.0.16",
"@nina-protocol/nina-internal-sdk": "0.0.35",
"@sentry/nextjs": "^7.8.0",
"@solana/spl-token": "^0.3.7",
Expand Down
7 changes: 5 additions & 2 deletions js/sdk/src/contexts/Hub/hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ const hubContextHelper = ({
queue = new Set(addToHubQueue)
queue.delete(releasePubkey.toBase58())
setAddToHubQueue(queue)
logEvent('hub_add_release_initiated', 'engagement', {
logEvent('hub_add_release_success', 'engagement', {
release: releasePubkey.toBase58(),
hub: hubPubkey.toBase58(),
wallet: provider.wallet.publicKey.toBase58(),
Expand Down Expand Up @@ -1209,7 +1209,10 @@ const hubContextHelper = ({
}
})
setHubState((prevState) => ({ ...prevState, ...updatedHubState }))
setHubContentState(updatedHubContent)
setHubContentState((prevState) => ({
...prevState,
...updatedHubContent,
facing-n marked this conversation as resolved.
Show resolved Hide resolved
}))
return hubs
} catch (error) {
console.warn(error)
Expand Down
9 changes: 7 additions & 2 deletions js/web/components/HubsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import Link from 'next/link'

const HubsModal = (props) => {
const { releasePubkey, metadata } = props
const { getHubsForRelease } = useContext(Hub.Context)
const { getHubsForRelease, filterHubsForRelease, hubContentState } =
useContext(Hub.Context)
const [open, setOpen] = useState(false)
const [hubs, setHubs] = useState([])

Expand All @@ -20,7 +21,11 @@ const HubsModal = (props) => {
setHubs(hubs)
}
handleGetHubsForRelease(releasePubkey)
}, [releasePubkey])
}, [])

useEffect(() => {
setHubs(filterHubsForRelease(releasePubkey))
}, [hubContentState])

return (
<>
Expand Down
13 changes: 6 additions & 7 deletions js/web/components/Release.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,14 @@ const ReleaseComponent = ({ metadataSsr, hub }) => {

setUserHubs(hubs)
}
if (wallet.connected && hubState && !userHubs) {
if (wallet.publicKey && wallet.connected && hubState && !userHubs) {
fetchHubs()
}
}, [wallet?.connected, hubState])

useEffect(() => {
setUserHubs(null)
setUserIsRecipient(false)
}, [wallet?.disconnecting])
if (!wallet.connected) {
setUserHubs(null)
setUserIsRecipient(false)
}
}, [wallet, wallet?.connected, hubState])

const handleFetchGates = async () => {
const gates = await fetchGatesForRelease(releasePubkey)
Expand Down
8 changes: 8 additions & 0 deletions js/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2315,6 +2315,14 @@
"@project-serum/anchor" "^0.25.0"
axios "^0.27.2"

"@nina-protocol/js-sdk@^0.0.16":
version "0.0.16"
resolved "https://registry.yarnpkg.com/@nina-protocol/js-sdk/-/js-sdk-0.0.16.tgz#837c05dc56610c4120da129d157d4e50e90cde70"
integrity sha512-zhhFumjD6xH+00kXJ3KoBXcvzGViJQd3oImN0dRsiShI3PyMYEi/bB8Z7R8V3Ofqgu/so3AOdsBAQ6MG4V8rlw==
dependencies:
"@project-serum/anchor" "^0.25.0"
axios "^0.27.2"

"@nina-protocol/js-sdk@^0.0.8":
version "0.0.8"
resolved "https://registry.yarnpkg.com/@nina-protocol/js-sdk/-/js-sdk-0.0.8.tgz#ad8ac467b05675715eaeee2438def3a4cc01efed"
Expand Down