mirror of
https://github.com/abusoww/tuxmate.git
synced 2026-04-17 21:53:12 +02:00
- Replace runtime Flathub API calls with static JSON generation - Add prebuild and predev scripts to specificially fetch verification data - Refactor useVerification hook to be synchronous - Fixes Flathub API CORS errors in production
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
'use client';
|
|
|
|
import { useCallback } from 'react';
|
|
import type { DistroId } from '@/lib/data';
|
|
import {
|
|
isFlathubVerified,
|
|
isSnapVerified,
|
|
} from '@/lib/verification';
|
|
|
|
export interface UseVerificationResult {
|
|
// Kept for compatibility, always false now
|
|
isLoading: boolean;
|
|
hasError: boolean;
|
|
isVerified: (distro: DistroId, packageName: string) => boolean;
|
|
getVerificationSource: (distro: DistroId, packageName: string) => 'flathub' | 'snap' | null;
|
|
}
|
|
|
|
// Now purely synchronous using build-time generated data
|
|
export function useVerification(): UseVerificationResult {
|
|
// Check if package is verified for the distro
|
|
const isVerified = useCallback((distro: DistroId, packageName: string): boolean => {
|
|
if (distro === 'flatpak') {
|
|
return isFlathubVerified(packageName);
|
|
}
|
|
if (distro === 'snap') {
|
|
return isSnapVerified(packageName);
|
|
}
|
|
return false;
|
|
}, []);
|
|
|
|
// Get verification source for badge styling
|
|
const getVerificationSource = useCallback((distro: DistroId, packageName: string): 'flathub' | 'snap' | null => {
|
|
if (distro === 'flatpak' && isFlathubVerified(packageName)) {
|
|
return 'flathub';
|
|
}
|
|
if (distro === 'snap' && isSnapVerified(packageName)) {
|
|
return 'snap';
|
|
}
|
|
return null;
|
|
}, []);
|
|
|
|
return {
|
|
isLoading: false,
|
|
hasError: false,
|
|
isVerified,
|
|
getVerificationSource,
|
|
};
|
|
}
|
|
|