mirror of
https://github.com/movie-web/movie-web.git
synced 2024-06-02 23:38:45 +02:00
21 lines
795 B
TypeScript
21 lines
795 B
TypeScript
|
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
|
||
|
}
|