fix: eliminate blank overlay flash when opening ShareModal

Initialize hasRelationship and isCheckingRelationship based on whether
factoryId is present, so the first render frame already shows the correct
content instead of an empty backdrop overlay.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Chever John 2026-06-30 02:58:39 +08:00
parent a3e9361cab
commit aba6330db7
No known key found for this signature in database
GPG Key ID: 2894D52ED1211DF0

View File

@ -66,8 +66,10 @@ export function ShareModal({
const shortLinkGenerated = useRef(false);
// 新流程状态
const [hasRelationship, setHasRelationship] = useState<boolean | null>(null);
const [isCheckingRelationship, setIsCheckingRelationship] = useState(false);
// When no factoryId (unlinked plan), we already know there's no relationship
// so initialize directly to avoid a blank-overlay flash before useEffect runs.
const [hasRelationship, setHasRelationship] = useState<boolean | null>(factoryId ? null : false);
const [isCheckingRelationship, setIsCheckingRelationship] = useState(!!factoryId);
const [existingLink, setExistingLink] = useState<ShareLinkStatus | null>(null);
const [isGeneratingLink, setIsGeneratingLink] = useState(false);
const [pushSuccess, setPushSuccess] = useState(false);