Refactor proxyFetch and enhance MediaProviderDetailPage layout
- Removed the isCloud check from proxyFetch.js, simplifying the fetch patching logic. - Updated MediaProviderDetailPage to include a new section for API key retrieval, improving user experience with clearer layout and additional notice text. - Enhanced ConnectionRow to better handle email display names. - Improved ProviderDetailPage to conditionally render provider notices and API key links. - Refactored localDb, requestDetailsDb, and usageDb to remove unnecessary isCloud checks, streamlining database interactions. - Updated OAuthModal to combine waiting and manual input steps for a more cohesive user flow. - Added API key URLs to several providers in providers.js for better accessibility.
This commit is contained in:
@@ -7,10 +7,9 @@ import lockfile from "proper-lockfile";
|
||||
import { DATA_DIR } from "@/lib/dataDir.js";
|
||||
|
||||
const DEFAULT_MITM_ROUTER_BASE = "http://localhost:20128";
|
||||
const isCloud = typeof caches !== 'undefined' || typeof caches === 'object';
|
||||
const DB_FILE = isCloud ? null : path.join(DATA_DIR, "db.json");
|
||||
const DB_FILE = path.join(DATA_DIR, "db.json");
|
||||
|
||||
if (!isCloud && !fs.existsSync(DATA_DIR)) {
|
||||
if (!fs.existsSync(DATA_DIR)) {
|
||||
fs.mkdirSync(DATA_DIR, { recursive: true });
|
||||
}
|
||||
|
||||
@@ -57,7 +56,7 @@ function cloneDefaultData() {
|
||||
};
|
||||
}
|
||||
|
||||
if (!isCloud && DB_FILE && !fs.existsSync(DB_FILE)) {
|
||||
if (!fs.existsSync(DB_FILE)) {
|
||||
fs.writeFileSync(DB_FILE, JSON.stringify(cloneDefaultData(), null, 2));
|
||||
}
|
||||
|
||||
@@ -144,11 +143,6 @@ class LocalMutex {
|
||||
const localMutex = new LocalMutex();
|
||||
|
||||
async function withFileLock(db, operation) {
|
||||
if (isCloud) {
|
||||
await operation();
|
||||
return;
|
||||
}
|
||||
|
||||
const releaseLocal = await localMutex.acquire();
|
||||
let release = null;
|
||||
try {
|
||||
@@ -176,15 +170,6 @@ async function safeWrite(db) {
|
||||
}
|
||||
|
||||
export async function getDb() {
|
||||
if (isCloud) {
|
||||
if (!dbInstance) {
|
||||
const data = cloneDefaultData();
|
||||
dbInstance = new Low({ read: async () => { }, write: async () => { } }, data);
|
||||
dbInstance.data = data;
|
||||
}
|
||||
return dbInstance;
|
||||
}
|
||||
|
||||
if (!dbInstance) {
|
||||
dbInstance = new Low(new JSONFile(DB_FILE), cloneDefaultData());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user