fix mini app bot father
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
import { Copy, ImageIcon, LayoutGrid, Loader2, RefreshCw, TextQuote, UserCircle2 } from 'lucide-react';
|
||||
import { useAuth } from '@/components/id/auth-provider';
|
||||
import { usePublicSettings } from '@/components/id/public-settings-provider';
|
||||
import { useToast } from '@/components/id/toast-provider';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
updateManagedBot,
|
||||
updateManagedBotProfile
|
||||
} from '@/lib/api';
|
||||
import { useEmbeddedAuthFallback } from '@/lib/embedded-auth-bridge';
|
||||
import { useMiniAppAuth } from '@/hooks/use-mini-app-auth';
|
||||
import { parseComposerMenuButtonJson } from '@/lib/bot-menu-button';
|
||||
|
||||
function FieldTextarea({
|
||||
@@ -78,9 +78,8 @@ function SectionCard({
|
||||
export function BotManageMiniAppContent() {
|
||||
const searchParams = useSearchParams();
|
||||
const botId = searchParams.get('botId') ?? '';
|
||||
const { token, isPinLocked, isLoading } = useAuth();
|
||||
const embeddedToken = useEmbeddedAuthFallback();
|
||||
const effectiveToken = token ?? embeddedToken;
|
||||
const { projectName } = usePublicSettings();
|
||||
const { effectiveToken, canUse: canUseSession, authReady, waitingForBridge, isLoading } = useMiniAppAuth();
|
||||
const { showToast } = useToast();
|
||||
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -97,7 +96,7 @@ export function BotManageMiniAppContent() {
|
||||
const [tokenPrefix, setTokenPrefix] = useState('');
|
||||
const [newToken, setNewToken] = useState<string | null>(null);
|
||||
|
||||
const canUse = Boolean(effectiveToken && !isPinLocked && botId);
|
||||
const canUse = Boolean(canUseSession && botId);
|
||||
|
||||
const loadBot = useCallback(async () => {
|
||||
if (!canUse || !effectiveToken) return;
|
||||
@@ -219,10 +218,19 @@ export function BotManageMiniAppContent() {
|
||||
);
|
||||
}
|
||||
|
||||
if ((waitingForBridge || !authReady) && !effectiveToken) {
|
||||
return (
|
||||
<div className="flex min-h-screen items-center justify-center p-6 text-center text-sm text-[#667085]">
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||
Загрузка...
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!canUse) {
|
||||
return (
|
||||
<div className="flex min-h-screen items-center justify-center p-6 text-center text-sm text-[#667085]">
|
||||
Войдите в Lendry ID, чтобы управлять ботом
|
||||
Войдите в {projectName}, чтобы управлять ботом
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user