mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-03 19:12:04 +08:00
fix: remove last-provider deletion restriction for OMO/OMO Slim plugins
OMO and OMO Slim are OpenCode plugins, not standalone apps — users should be able to fully remove them. Remove the count-based guard that prevented deleting the last active provider, and clean up the now-unused provider-count API surface across the full stack.
This commit is contained in:
@@ -7,7 +7,6 @@ function createOmoQueryKeys(prefix: string) {
|
||||
return {
|
||||
all: [prefix] as const,
|
||||
currentProviderId: () => [prefix, "current-provider-id"] as const,
|
||||
providerCount: () => [prefix, "provider-count"] as const,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,7 +19,6 @@ function createOmoQueryHooks(
|
||||
function invalidateAll(queryClient: ReturnType<typeof useQueryClient>) {
|
||||
queryClient.invalidateQueries({ queryKey: ["providers"] });
|
||||
queryClient.invalidateQueries({ queryKey: keys.currentProviderId() });
|
||||
queryClient.invalidateQueries({ queryKey: keys.providerCount() });
|
||||
}
|
||||
|
||||
function useCurrentProviderId(enabled = true) {
|
||||
@@ -34,17 +32,6 @@ function createOmoQueryHooks(
|
||||
});
|
||||
}
|
||||
|
||||
function useProviderCount(enabled = true) {
|
||||
return useQuery({
|
||||
queryKey: keys.providerCount(),
|
||||
queryFn:
|
||||
"getOmoProviderCount" in api
|
||||
? (api as typeof omoApi).getOmoProviderCount
|
||||
: (api as typeof omoSlimApi).getProviderCount,
|
||||
enabled,
|
||||
});
|
||||
}
|
||||
|
||||
function useReadLocalFile() {
|
||||
return useMutation({
|
||||
mutationFn: () => api.readLocalFile(),
|
||||
@@ -65,7 +52,6 @@ function createOmoQueryHooks(
|
||||
return {
|
||||
keys,
|
||||
useCurrentProviderId,
|
||||
useProviderCount,
|
||||
useReadLocalFile,
|
||||
useDisableCurrent,
|
||||
};
|
||||
@@ -82,11 +68,9 @@ export const omoKeys = omoHooks.keys;
|
||||
export const omoSlimKeys = omoSlimHooks.keys;
|
||||
|
||||
export const useCurrentOmoProviderId = omoHooks.useCurrentProviderId;
|
||||
export const useOmoProviderCount = omoHooks.useProviderCount;
|
||||
export const useReadOmoLocalFile = omoHooks.useReadLocalFile;
|
||||
export const useDisableCurrentOmo = omoHooks.useDisableCurrent;
|
||||
|
||||
export const useCurrentOmoSlimProviderId = omoSlimHooks.useCurrentProviderId;
|
||||
export const useOmoSlimProviderCount = omoSlimHooks.useProviderCount;
|
||||
export const useReadOmoSlimLocalFile = omoSlimHooks.useReadLocalFile;
|
||||
export const useDisableCurrentOmoSlim = omoSlimHooks.useDisableCurrent;
|
||||
|
||||
Reference in New Issue
Block a user