fix: non-ens wallets engagement, syncing hydration

This commit is contained in:
Danish Arora 2025-09-19 13:44:11 +05:30
parent 8bab4d1a9a
commit 1d86a43406
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E
9 changed files with 75 additions and 24 deletions

View File

@ -81,7 +81,7 @@ export function CreateCellDialog({
if (!canCreateCell) {
toast({
title: 'Permission Denied',
description: 'You need to verify Ordinal ownership to create cells.',
description: 'Only verified ENS or Logos Ordinal owners can create cells.',
variant: 'destructive',
});
return;

View File

@ -297,7 +297,7 @@ const PostDetail = () => {
{!permissions.canComment && (
<div className="mb-6 p-4 border border-cyber-muted rounded-sm bg-cyber-muted/20 text-center">
<p className="text-sm mb-3">
Connect wallet and verify Ordinal ownership to comment
Connect your wallet to comment
</p>
<Button asChild size="sm">
<Link to="/">Connect Wallet</Link>

View File

@ -244,7 +244,7 @@ const PostList = () => {
{!canPost && !currentUser && (
<div className="section-spacing content-card-sm text-center">
<p className="text-sm mb-3">
Connect wallet and verify Ordinal ownership to post
Connect your wallet to post
</p>
<Button asChild size="sm">
<Link to="/">Connect Wallet</Link>
@ -260,7 +260,7 @@ const PostList = () => {
<p className="empty-state-description">
{canPost
? 'Be the first to post in this cell!'
: 'Connect your wallet and verify Ordinal ownership to start a thread.'}
: 'Connect your wallet to start a thread.'}
</p>
</div>
) : (
@ -273,7 +273,7 @@ const PostList = () => {
onClick={() => handleVotePost(post.id, true)}
disabled={!canVote || isVoting}
title={
canVote ? 'Upvote' : 'Connect wallet and verify to vote'
canVote ? 'Upvote' : 'Connect your wallet to vote'
}
>
<ArrowUp className="w-4 h-4" />
@ -286,7 +286,7 @@ const PostList = () => {
onClick={() => handleVotePost(post.id, false)}
disabled={!canVote || isVoting}
title={
canVote ? 'Downvote' : 'Connect wallet and verify to vote'
canVote ? 'Downvote' : 'Connect your wallet to vote'
}
>
<ArrowDown className="w-4 h-4" />

View File

@ -167,7 +167,7 @@ const FeedPage: React.FC = () => {
{verificationStatus !==
EVerificationStatus.ENS_ORDINAL_VERIFIED && (
<p className="text-sm text-cyber-neutral/80">
Connect your wallet and verify Ordinal ownership to
Connect your wallet to
start posting
</p>
)}

View File

@ -363,7 +363,7 @@ export class ForumActions {
return {
success: false,
error:
'Authentication required. You need to verify Ordinal ownership to moderate posts.',
'Authentication required. Connect your wallet to moderate posts.',
};
}
if (currentUser.address !== cellOwner) {
@ -437,7 +437,7 @@ export class ForumActions {
return {
success: false,
error:
'Authentication required. You need to verify Ordinal ownership to moderate comments.',
'Authentication required. Connect your wallet to moderate comments.',
};
}
if (currentUser.address !== cellOwner) {
@ -511,7 +511,7 @@ export class ForumActions {
return {
success: false,
error:
'Authentication required. You need to verify Ordinal ownership to moderate users.',
'Authentication required. Connect your wallet to moderate users.',
};
}
if (currentUser.address !== cellOwner) {
@ -579,7 +579,7 @@ export class ForumActions {
return {
success: false,
error:
'Authentication required. You need to verify Ordinal ownership to unmoderate posts.',
'Authentication required. Connect your wallet to unmoderate posts.',
};
}
if (currentUser.address !== cellOwner) {
@ -653,7 +653,7 @@ export class ForumActions {
return {
success: false,
error:
'Authentication required. You need to verify Ordinal ownership to unmoderate comments.',
'Authentication required. Connect your wallet to unmoderate comments.',
};
}
if (currentUser.address !== cellOwner) {
@ -727,7 +727,7 @@ export class ForumActions {
return {
success: false,
error:
'Authentication required. You need to verify Ordinal ownership to unmoderate users.',
'Authentication required. Connect your wallet to unmoderate users.',
};
}
if (currentUser.address !== cellOwner) {

View File

@ -55,6 +55,7 @@ export class MessageService {
onSent: id => {
console.log(`Message ${id} sent`);
statusCallback?.onSent?.(id);
try { localDatabase.clearPending(message.id); } catch {}
},
onAcknowledged: id => {
console.log(`Message ${id} acknowledged`);

View File

@ -173,6 +173,48 @@ export const AuthProvider: React.FC<{
autoConnect();
}, [isWalletConnected, connectedAddress, walletType]); // Remove currentUser and verifyOwnership dependencies
// Ensure verificationStatus reflects a connected wallet even if a user was preloaded
useEffect(() => {
const syncConnectedStatus = async () => {
if (!isWalletConnected || !connectedAddress || !currentUser) return;
const needsAddressSync =
currentUser.address !== connectedAddress ||
currentUser.walletType !== (walletType as 'bitcoin' | 'ethereum');
const needsStatusUpgrade =
currentUser.verificationStatus === EVerificationStatus.WALLET_UNCONNECTED;
if (needsAddressSync || needsStatusUpgrade) {
const nextStatus =
currentUser.verificationStatus ===
EVerificationStatus.ENS_ORDINAL_VERIFIED
? EVerificationStatus.ENS_ORDINAL_VERIFIED
: EVerificationStatus.WALLET_CONNECTED;
const updatedUser: User = {
...currentUser,
address: connectedAddress,
walletType: walletType as 'bitcoin' | 'ethereum',
verificationStatus: nextStatus,
lastChecked: Date.now(),
} as User;
setCurrentUser(updatedUser);
await localDatabase.storeUser(updatedUser);
await localDatabase.upsertUserIdentity(connectedAddress, {
ensName: updatedUser.ensDetails?.ensName,
ordinalDetails: updatedUser.ordinalDetails,
verificationStatus: nextStatus,
lastUpdated: Date.now(),
});
}
};
syncConnectedStatus();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isWalletConnected, connectedAddress, walletType, currentUser]);
const connectWallet = useCallback(async (): Promise<boolean> => {
if (!isWalletConnected || !connectedAddress) return false;

View File

@ -131,6 +131,14 @@ export const ForumProvider: React.FC<{
};
}, [client, updateFromCache]);
// 2b) Pending state wiring rehydrate when local pending queue changes
useEffect(() => {
const off = localDatabase.onPendingChange(async () => {
try { await updateFromCache(); } catch {}
});
return () => { try { off && off(); } catch {} };
}, [updateFromCache]);
// 3) Visibility change: re-check connection immediately when tab becomes active
useEffect(() => {
const handleVisibility = async () => {

View File

@ -394,7 +394,7 @@ export function useForumApi(): UseForumApi {
currentUser,
isAuthenticated: !!currentUser,
},
async () => {} // updateStateFromCache handled by ForumProvider
async () => { await refreshData(); }
);
return result.data || null;
} catch {
@ -403,7 +403,7 @@ export function useForumApi(): UseForumApi {
},
createPost: async (input: { cellId: string; title: string; content: string }) => {
if (!permissions.canPost) {
throw new Error('You need to verify Ordinal ownership to create posts.');
throw new Error('Connect your wallet to create posts.');
}
if (!input.title.trim() || !input.content.trim()) {
throw new Error('Please provide both a title and content for the post.');
@ -417,7 +417,7 @@ export function useForumApi(): UseForumApi {
currentUser,
isAuthenticated: !!currentUser,
},
async () => {}
async () => { await refreshData(); }
);
return result.data || null;
} catch {
@ -439,7 +439,7 @@ export function useForumApi(): UseForumApi {
currentUser,
isAuthenticated: !!currentUser,
},
async () => {}
async () => { await refreshData(); }
);
return result.data || null;
} catch {
@ -460,7 +460,7 @@ export function useForumApi(): UseForumApi {
currentUser,
isAuthenticated: !!currentUser,
},
async () => {}
async () => { await refreshData(); }
);
return result.success;
} catch {
@ -472,7 +472,7 @@ export function useForumApi(): UseForumApi {
try {
const result = await client.forumActions.moderatePost(
{ cellId, postId, reason, currentUser, isAuthenticated: !!currentUser, cellOwner: currentUser?.address || '' },
async () => {}
async () => { await refreshData(); }
);
return result.success;
} catch { return false; }
@ -481,7 +481,7 @@ export function useForumApi(): UseForumApi {
try {
const result = await client.forumActions.unmoderatePost(
{ cellId, postId, reason, currentUser, isAuthenticated: !!currentUser, cellOwner: currentUser?.address || '' },
async () => {}
async () => { await refreshData(); }
);
return result.success;
} catch { return false; }
@ -490,7 +490,7 @@ export function useForumApi(): UseForumApi {
try {
const result = await client.forumActions.moderateComment(
{ cellId, commentId, reason, currentUser, isAuthenticated: !!currentUser, cellOwner: currentUser?.address || '' },
async () => {}
async () => { await refreshData(); }
);
return result.success;
} catch { return false; }
@ -499,7 +499,7 @@ export function useForumApi(): UseForumApi {
try {
const result = await client.forumActions.unmoderateComment(
{ cellId, commentId, reason, currentUser, isAuthenticated: !!currentUser, cellOwner: currentUser?.address || '' },
async () => {}
async () => { await refreshData(); }
);
return result.success;
} catch { return false; }
@ -508,7 +508,7 @@ export function useForumApi(): UseForumApi {
try {
const result = await client.forumActions.moderateUser(
{ cellId, userAddress, reason, currentUser, isAuthenticated: !!currentUser, cellOwner: currentUser?.address || '' },
async () => {}
async () => { await refreshData(); }
);
return result.success;
} catch { return false; }
@ -517,7 +517,7 @@ export function useForumApi(): UseForumApi {
try {
const result = await client.forumActions.unmoderateUser(
{ cellId, userAddress, reason, currentUser, isAuthenticated: !!currentUser, cellOwner: currentUser?.address || '' },
async () => {}
async () => { await refreshData(); }
);
return result.success;
} catch { return false; }