Skip to content
Closed
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
4 changes: 2 additions & 2 deletions packages/web/components/Player/PlayerTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const PlayerTile: React.FC<Props> = ({

const [loading, setLoading] = useState(true);
const daosRef = React.useRef<HTMLDivElement>(null);
const [limit, setLimit] = useState(12);
const [limit, setLimit] = useState(3);

useEffect(() => {
getAllMemberships(player).then(({ all }) => {
Expand All @@ -64,7 +64,7 @@ export const PlayerTile: React.FC<Props> = ({

const handleResize = useCallback(() => {
const width = daosRef.current?.scrollWidth;
setLimit(Math.max(8, Math.floor((width ?? 22) / 22)));
setLimit(Math.min(3, Math.max(1, Math.floor((width ?? 22) / 22))));
}, []);

useEffect(() => {
Expand Down
18 changes: 16 additions & 2 deletions packages/web/lib/hooks/ceramic/useSaveToComposeDB.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ComposeDBProfile, Maybe } from '@metafam/utils';
import { useCallback, useState } from 'react';

import { useAccount } from 'wagmi';
import { useLinkOwnCeramicNodeMutation } from '#graphql/autogen/hasura-sdk';
import {
ComposeDBCreateProfileResponseData,
Expand All @@ -20,6 +21,7 @@ export class EmptyProfileError extends Error {

export const useSaveToComposeDB = () => {
const { composeDBClient, connect } = useComposeDB();
const { isConnected } = useAccount();

// When saving to ComposeDB, it's essential that we have the most recent
// value for user.ceramicProfileId so that we don't inadvertently create
Expand All @@ -40,13 +42,25 @@ export const useSaveToComposeDB = () => {
if(Object.keys(values).length === 0) {
throw new EmptyProfileError();
}

if (!isConnected) {
throw new Error('Wallet is not connected. Please connect your wallet to save changes.');
}

if (!composeDBClient) {
throw new CeramicError(
'Unable to connect to the Ceramic API to save changes.',
);
}

if (!user) {
throw new Error('No wallet connected.');
throw new Error(
'Unable to load user profile. Please try refreshing the page or reconnecting your wallet.',
);
}

if (!user.address) {
throw new Error('User profile is missing wallet address information.');
}

if (!composeDBClient.context.isAuthenticated()) {
Expand Down Expand Up @@ -100,7 +114,7 @@ export const useSaveToComposeDB = () => {
}
return user.ceramicProfileId;
},
[composeDBClient, connect, linkNode, user],
[composeDBClient, connect, linkNode, user, isConnected],
);

return { save, status };
Expand Down