mirror of
https://github.com/movie-web/movie-web.git
synced 2025-02-07 05:23:24 +01:00
Ok now i fixed it all
This commit is contained in:
parent
c87abb2c32
commit
4ec1bb9280
@ -21,8 +21,8 @@ import {
|
|||||||
ExtensionDetectionResult,
|
ExtensionDetectionResult,
|
||||||
detectExtensionInstall,
|
detectExtensionInstall,
|
||||||
} from "@/utils/detectFeatures";
|
} from "@/utils/detectFeatures";
|
||||||
import { getExtensionState } from "@/utils/onboarding";
|
import { getExtensionState } from "@/utils/extension";
|
||||||
import type { ExtensionStatus } from "@/utils/onboarding";
|
import type { ExtensionStatus } from "@/utils/extension";
|
||||||
|
|
||||||
function RefreshBar() {
|
function RefreshBar() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -11,7 +11,8 @@ import { Paragraph } from "@/components/text/Paragraph";
|
|||||||
import { Title } from "@/components/text/Title";
|
import { Title } from "@/components/text/Title";
|
||||||
import { ScrapingItems, ScrapingSegment } from "@/hooks/useProviderScrape";
|
import { ScrapingItems, ScrapingSegment } from "@/hooks/useProviderScrape";
|
||||||
import { ErrorContainer, ErrorLayout } from "@/pages/layouts/ErrorLayout";
|
import { ErrorContainer, ErrorLayout } from "@/pages/layouts/ErrorLayout";
|
||||||
import { ExtensionStatus, getExtensionState } from "@/utils/onboarding";
|
import { getExtensionState } from "@/utils/extension";
|
||||||
|
import type { ExtensionStatus } from "@/utils/extension";
|
||||||
import { getProviderApiUrls } from "@/utils/proxyUrls";
|
import { getProviderApiUrls } from "@/utils/proxyUrls";
|
||||||
|
|
||||||
import { ErrorCardInModal } from "../errors/ErrorCard";
|
import { ErrorCardInModal } from "../errors/ErrorCard";
|
||||||
|
20
src/utils/extension.ts
Normal file
20
src/utils/extension.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { isAllowedExtensionVersion } from "@/backend/extension/compatibility";
|
||||||
|
import { extensionInfo } from "@/backend/extension/messaging";
|
||||||
|
|
||||||
|
export type ExtensionStatus =
|
||||||
|
| "unknown"
|
||||||
|
| "failed"
|
||||||
|
| "disallowed"
|
||||||
|
| "noperms"
|
||||||
|
| "outdated"
|
||||||
|
| "success";
|
||||||
|
|
||||||
|
export async function getExtensionState(): Promise<ExtensionStatus> {
|
||||||
|
const info = await extensionInfo();
|
||||||
|
if (!info) return "unknown"; // cant talk to extension
|
||||||
|
if (!info.success) return "failed"; // extension failed to respond
|
||||||
|
if (!info.allowed) return "disallowed"; // extension is not enabled on this page
|
||||||
|
if (!info.hasPermission) return "noperms"; // extension has no perms to do it's tasks
|
||||||
|
if (!isAllowedExtensionVersion(info.version)) return "outdated"; // extension is too old
|
||||||
|
return "success"; // no problems
|
||||||
|
}
|
@ -1,30 +1,8 @@
|
|||||||
import { isAllowedExtensionVersion } from "@/backend/extension/compatibility";
|
import { isExtensionActive } from "@/backend/extension/messaging";
|
||||||
import {
|
|
||||||
extensionInfo,
|
|
||||||
isExtensionActive,
|
|
||||||
} from "@/backend/extension/messaging";
|
|
||||||
import { conf } from "@/setup/config";
|
import { conf } from "@/setup/config";
|
||||||
import { useAuthStore } from "@/stores/auth";
|
import { useAuthStore } from "@/stores/auth";
|
||||||
import { useOnboardingStore } from "@/stores/onboarding";
|
import { useOnboardingStore } from "@/stores/onboarding";
|
||||||
|
|
||||||
export type ExtensionStatus =
|
|
||||||
| "unknown"
|
|
||||||
| "failed"
|
|
||||||
| "disallowed"
|
|
||||||
| "noperms"
|
|
||||||
| "outdated"
|
|
||||||
| "success";
|
|
||||||
|
|
||||||
export async function getExtensionState(): Promise<ExtensionStatus> {
|
|
||||||
const info = await extensionInfo();
|
|
||||||
if (!info) return "unknown"; // cant talk to extension
|
|
||||||
if (!info.success) return "failed"; // extension failed to respond
|
|
||||||
if (!info.allowed) return "disallowed"; // extension is not enabled on this page
|
|
||||||
if (!info.hasPermission) return "noperms"; // extension has no perms to do it's tasks
|
|
||||||
if (!isAllowedExtensionVersion(info.version)) return "outdated"; // extension is too old
|
|
||||||
return "success"; // no problems
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function needsOnboarding(): Promise<boolean> {
|
export async function needsOnboarding(): Promise<boolean> {
|
||||||
// if onboarding is dislabed, no onboarding needed
|
// if onboarding is dislabed, no onboarding needed
|
||||||
if (!conf().HAS_ONBOARDING) return false;
|
if (!conf().HAS_ONBOARDING) return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user