mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
@@ -18,6 +18,21 @@ export interface FullscreenEnabled {
|
|||||||
const BRANDING_CACHE_KEY = 'cabinet_branding'
|
const BRANDING_CACHE_KEY = 'cabinet_branding'
|
||||||
const LOGO_PRELOADED_KEY = 'cabinet_logo_preloaded'
|
const LOGO_PRELOADED_KEY = 'cabinet_logo_preloaded'
|
||||||
|
|
||||||
|
// Check if logo was already preloaded in this session
|
||||||
|
export const isLogoPreloaded = (): boolean => {
|
||||||
|
try {
|
||||||
|
const cached = getCachedBranding()
|
||||||
|
if (!cached?.has_custom_logo || !cached?.logo_url) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const logoUrl = `${import.meta.env.VITE_API_URL || ''}${cached.logo_url}`
|
||||||
|
const preloaded = sessionStorage.getItem(LOGO_PRELOADED_KEY)
|
||||||
|
return preloaded === logoUrl
|
||||||
|
} catch {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get cached branding from localStorage
|
// Get cached branding from localStorage
|
||||||
export const getCachedBranding = (): BrandingInfo | null => {
|
export const getCachedBranding = (): BrandingInfo | null => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import TicketNotificationBell from '../TicketNotificationBell'
|
|||||||
import AnimatedBackground from '../AnimatedBackground'
|
import AnimatedBackground from '../AnimatedBackground'
|
||||||
import { contestsApi } from '../../api/contests'
|
import { contestsApi } from '../../api/contests'
|
||||||
import { pollsApi } from '../../api/polls'
|
import { pollsApi } from '../../api/polls'
|
||||||
import { brandingApi, getCachedBranding, setCachedBranding, preloadLogo } from '../../api/branding'
|
import { brandingApi, getCachedBranding, setCachedBranding, preloadLogo, isLogoPreloaded } from '../../api/branding'
|
||||||
import { wheelApi } from '../../api/wheel'
|
import { wheelApi } from '../../api/wheel'
|
||||||
import { themeColorsApi } from '../../api/themeColors'
|
import { themeColorsApi } from '../../api/themeColors'
|
||||||
import { promoApi } from '../../api/promo'
|
import { promoApi } from '../../api/promo'
|
||||||
@@ -240,8 +240,8 @@ export default function Layout({ children }: LayoutProps) {
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// State to track if logo image has loaded
|
// State to track if logo image has loaded - start with true if already preloaded
|
||||||
const [logoLoaded, setLogoLoaded] = useState(false)
|
const [logoLoaded, setLogoLoaded] = useState(() => isLogoPreloaded())
|
||||||
|
|
||||||
// Fetch branding settings with localStorage cache for instant load
|
// Fetch branding settings with localStorage cache for instant load
|
||||||
const { data: branding } = useQuery({
|
const { data: branding } = useQuery({
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useNavigate, useLocation } from 'react-router-dom'
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useQuery } from '@tanstack/react-query'
|
import { useQuery } from '@tanstack/react-query'
|
||||||
import { useAuthStore } from '../store/auth'
|
import { useAuthStore } from '../store/auth'
|
||||||
import { brandingApi, getCachedBranding, setCachedBranding, preloadLogo, type BrandingInfo } from '../api/branding'
|
import { brandingApi, getCachedBranding, setCachedBranding, preloadLogo, isLogoPreloaded, type BrandingInfo } from '../api/branding'
|
||||||
import { getAndClearReturnUrl } from '../utils/token'
|
import { getAndClearReturnUrl } from '../utils/token'
|
||||||
import LanguageSwitcher from '../components/LanguageSwitcher'
|
import LanguageSwitcher from '../components/LanguageSwitcher'
|
||||||
import TelegramLoginButton from '../components/TelegramLoginButton'
|
import TelegramLoginButton from '../components/TelegramLoginButton'
|
||||||
@@ -19,7 +19,7 @@ export default function Login() {
|
|||||||
const [error, setError] = useState('')
|
const [error, setError] = useState('')
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
const [isTelegramWebApp, setIsTelegramWebApp] = useState(false)
|
const [isTelegramWebApp, setIsTelegramWebApp] = useState(false)
|
||||||
const [logoLoaded, setLogoLoaded] = useState(false)
|
const [logoLoaded, setLogoLoaded] = useState(() => isLogoPreloaded())
|
||||||
|
|
||||||
// Получаем URL для возврата после авторизации
|
// Получаем URL для возврата после авторизации
|
||||||
const getReturnUrl = useCallback(() => {
|
const getReturnUrl = useCallback(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user