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 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
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
9 changes: 6 additions & 3 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 @@ -1192,7 +1192,7 @@ const hubContextHelper = ({
await initSdkIfNeeded()
const { hubs } = await NinaSdk.Release.fetchHubs(releasePubkey, true)
const updatedHubState = {}
const updatedHubContent = { ...hubContentState }
const updatedHubContent = {}
hubs.forEach((hub) => {
const accountData = { ...hub.accountData }
delete hub.accountData
Expand All @@ -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
1 change: 0 additions & 1 deletion js/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"@fortawesome/fontawesome-svg-core": "^1.3.0",
"@fortawesome/free-brands-svg-icons": "^5.15.4",
"@fortawesome/react-fontawesome": "^0.1.16",
"@nina-protocol/js-sdk": "^0.0.14",
"@project-serum/anchor": "^0.25.0",
"@solana/spl-token": "^0.1.8",
"@solana/wallet-adapter-backpack": "^0.1.13",
Expand Down
8 changes: 4 additions & 4 deletions js/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2307,10 +2307,10 @@
jsbi "^3.1.5"
sha.js "^2.4.11"

"@nina-protocol/js-sdk@^0.0.14":
version "0.0.14"
resolved "https://registry.yarnpkg.com/@nina-protocol/js-sdk/-/js-sdk-0.0.14.tgz#6ccf6997edc60d7f69a6346f2e0d4170a3818874"
integrity sha512-o/a5EjPDuXd31CPa2Angn+LIikTYhmEIpJl2FbIKH5II9rjxXYdRBJYH8PzoUs0fGO1ObT2galbrQ3WEfKDXzg==
"@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"
Expand Down