Compare commits
13 Commits
accountvie
...
refactor-i
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ca2c1d4b3 | |||
|
|
cb8d8bed4c | ||
|
|
11658140ae | ||
|
|
85a64b06d7 | ||
|
|
72e23a9109 | ||
|
|
ceaf4ede11 | ||
|
|
523f88fd0d | ||
|
|
ee57fe9ea6 | ||
|
|
471bdd6b92 | ||
|
|
c26b8daaf7 | ||
|
|
16db790c5f | ||
|
|
59434ff5f7 | ||
|
|
239666e137 |
@@ -1156,6 +1156,9 @@ gem_path=$(which gem)
|
|||||||
shortened_path="${gem_path:h:h}"
|
shortened_path="${gem_path:h:h}"
|
||||||
export GEM_HOME=$shortened_path
|
export GEM_HOME=$shortened_path
|
||||||
export GEM_PATH=$shortened_path
|
export GEM_PATH=$shortened_path
|
||||||
|
|
||||||
|
cd ios/App
|
||||||
|
pod install
|
||||||
```
|
```
|
||||||
|
|
||||||
##### 1. Bump the version in package.json for `MARKETING_VERSION`, then `grep CURRENT_PROJECT_VERSION ios/App/App.xcodeproj/project.pbxproj` and add 1 for the numbered version;
|
##### 1. Bump the version in package.json for `MARKETING_VERSION`, then `grep CURRENT_PROJECT_VERSION ios/App/App.xcodeproj/project.pbxproj` and add 1 for the numbered version;
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ android {
|
|||||||
applicationId "app.timesafari.app"
|
applicationId "app.timesafari.app"
|
||||||
minSdkVersion rootProject.ext.minSdkVersion
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
versionCode 47
|
versionCode 48
|
||||||
versionName "1.1.2"
|
versionName "1.1.3-beta"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
aaptOptions {
|
aaptOptions {
|
||||||
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||||
|
|||||||
@@ -21,14 +21,8 @@ import IndexedDBBackend from "absurd-sql/dist/indexeddb-backend";
|
|||||||
import { runMigrations } from "../db-sql/migration";
|
import { runMigrations } from "../db-sql/migration";
|
||||||
import type { DatabaseService, QueryExecResult } from "../interfaces/database";
|
import type { DatabaseService, QueryExecResult } from "../interfaces/database";
|
||||||
import { logger } from "@/utils/logger";
|
import { logger } from "@/utils/logger";
|
||||||
|
import { OperationQueue, QueueExecutor } from "./platforms/OperationQueue";
|
||||||
interface QueuedOperation {
|
import { QueuedOperation } from "./platforms/types";
|
||||||
type: "run" | "query";
|
|
||||||
sql: string;
|
|
||||||
params: unknown[];
|
|
||||||
resolve: (value: unknown) => void;
|
|
||||||
reject: (reason: unknown) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface AbsurdSqlDatabase {
|
interface AbsurdSqlDatabase {
|
||||||
exec: (sql: string, params?: unknown[]) => Promise<QueryExecResult[]>;
|
exec: (sql: string, params?: unknown[]) => Promise<QueryExecResult[]>;
|
||||||
@@ -43,8 +37,7 @@ class AbsurdSqlDatabaseService implements DatabaseService {
|
|||||||
private db: AbsurdSqlDatabase | null;
|
private db: AbsurdSqlDatabase | null;
|
||||||
private initialized: boolean;
|
private initialized: boolean;
|
||||||
private initializationPromise: Promise<void> | null = null;
|
private initializationPromise: Promise<void> | null = null;
|
||||||
private operationQueue: Array<QueuedOperation> = [];
|
private operationQueue = new OperationQueue<AbsurdSqlDatabase>();
|
||||||
private isProcessingQueue: boolean = false;
|
|
||||||
|
|
||||||
private constructor() {
|
private constructor() {
|
||||||
this.db = null;
|
this.db = null;
|
||||||
@@ -161,42 +154,30 @@ class AbsurdSqlDatabaseService implements DatabaseService {
|
|||||||
this.processQueue();
|
this.processQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create executor adapter for AbsurdSQL API
|
||||||
|
*/
|
||||||
|
private createExecutor(): QueueExecutor<AbsurdSqlDatabase> {
|
||||||
|
return {
|
||||||
|
executeRun: async (db, sql, params) => {
|
||||||
|
return await db.run(sql, params);
|
||||||
|
},
|
||||||
|
executeQuery: async (db, sql, params) => {
|
||||||
|
return await db.exec(sql, params);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private async processQueue(): Promise<void> {
|
private async processQueue(): Promise<void> {
|
||||||
if (this.isProcessingQueue || !this.initialized || !this.db) {
|
if (!this.initialized || !this.db) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isProcessingQueue = true;
|
await this.operationQueue.processQueue(
|
||||||
|
this.db,
|
||||||
while (this.operationQueue.length > 0) {
|
this.createExecutor(),
|
||||||
const operation = this.operationQueue.shift();
|
"AbsurdSqlDatabaseService",
|
||||||
if (!operation) continue;
|
);
|
||||||
|
|
||||||
try {
|
|
||||||
let result: unknown;
|
|
||||||
switch (operation.type) {
|
|
||||||
case "run":
|
|
||||||
result = await this.db.run(operation.sql, operation.params);
|
|
||||||
break;
|
|
||||||
case "query":
|
|
||||||
result = await this.db.exec(operation.sql, operation.params);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
operation.resolve(result);
|
|
||||||
} catch (error) {
|
|
||||||
logger.error(
|
|
||||||
"Error while processing SQL queue:",
|
|
||||||
error,
|
|
||||||
" ... for sql:",
|
|
||||||
operation.sql,
|
|
||||||
" ... with params:",
|
|
||||||
operation.params,
|
|
||||||
);
|
|
||||||
operation.reject(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.isProcessingQueue = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async queueOperation<R>(
|
private async queueOperation<R>(
|
||||||
@@ -204,21 +185,24 @@ class AbsurdSqlDatabaseService implements DatabaseService {
|
|||||||
sql: string,
|
sql: string,
|
||||||
params: unknown[] = [],
|
params: unknown[] = [],
|
||||||
): Promise<R> {
|
): Promise<R> {
|
||||||
return new Promise<R>((resolve, reject) => {
|
const operation: QueuedOperation = {
|
||||||
const operation: QueuedOperation = {
|
type,
|
||||||
type,
|
sql,
|
||||||
sql,
|
params,
|
||||||
params,
|
resolve: (_value: unknown) => {
|
||||||
resolve: (value: unknown) => resolve(value as R),
|
// No-op, will be wrapped by OperationQueue
|
||||||
reject,
|
},
|
||||||
};
|
reject: () => {
|
||||||
this.operationQueue.push(operation);
|
// No-op, will be wrapped by OperationQueue
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
// If we're already initialized, start processing the queue
|
return this.operationQueue.queueOperation<R>(
|
||||||
if (this.initialized && this.db) {
|
operation,
|
||||||
this.processQueue();
|
this.initialized,
|
||||||
}
|
this.db,
|
||||||
});
|
() => this.processQueue(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async waitForInitialization(): Promise<void> {
|
private async waitForInitialization(): Promise<void> {
|
||||||
|
|||||||
@@ -4,76 +4,144 @@ import { CapacitorPlatformService } from "./platforms/CapacitorPlatformService";
|
|||||||
import { ElectronPlatformService } from "./platforms/ElectronPlatformService";
|
import { ElectronPlatformService } from "./platforms/ElectronPlatformService";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory class for creating platform-specific service implementations.
|
* HMR-safe global singleton storage for PlatformService
|
||||||
* Implements the Singleton pattern to ensure only one instance of PlatformService exists.
|
|
||||||
*
|
*
|
||||||
* The factory determines which platform implementation to use based on the VITE_PLATFORM
|
* Uses multiple fallbacks to ensure persistence across module reloads:
|
||||||
* environment variable. Supported platforms are:
|
* 1. globalThis (standard, works in most environments)
|
||||||
* - capacitor: Mobile platform using Capacitor
|
* 2. window (browser fallback)
|
||||||
* - electron: Desktop platform using Electron with Capacitor
|
* 3. self (web worker fallback)
|
||||||
* - web: Default web platform (fallback)
|
*/
|
||||||
|
declare global {
|
||||||
|
// eslint-disable-next-line no-var
|
||||||
|
var __PLATFORM_SERVICE_SINGLETON__: PlatformService | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the global object for singleton storage
|
||||||
|
* Uses multiple fallbacks to ensure compatibility
|
||||||
|
*/
|
||||||
|
function getGlobal(): typeof globalThis {
|
||||||
|
if (typeof globalThis !== "undefined") return globalThis;
|
||||||
|
if (typeof window !== "undefined") return window as typeof globalThis;
|
||||||
|
if (typeof self !== "undefined") return self as typeof globalThis;
|
||||||
|
// Fallback for Node.js environments
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
return {} as any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory function to create platform-specific service implementation
|
||||||
|
*
|
||||||
|
* Uses console.log instead of logger to avoid circular dependency
|
||||||
|
* (logger imports PlatformServiceFactory)
|
||||||
|
*/
|
||||||
|
function create(): PlatformService {
|
||||||
|
const which = import.meta.env?.VITE_PLATFORM ?? "web";
|
||||||
|
|
||||||
|
if (which === "capacitor") return new CapacitorPlatformService();
|
||||||
|
if (which === "electron") return new ElectronPlatformService();
|
||||||
|
return new WebPlatformService();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get or create the HMR-safe singleton instance of PlatformService
|
||||||
|
*
|
||||||
|
* Uses lazy initialization to avoid circular dependency issues at module load time.
|
||||||
|
*/
|
||||||
|
function getPlatformSvc(): PlatformService {
|
||||||
|
const global = getGlobal();
|
||||||
|
|
||||||
|
const exists = global.__PLATFORM_SERVICE_SINGLETON__ !== undefined;
|
||||||
|
|
||||||
|
if (!exists) {
|
||||||
|
global.__PLATFORM_SERVICE_SINGLETON__ = create();
|
||||||
|
// Verify it was stored
|
||||||
|
if (!global.__PLATFORM_SERVICE_SINGLETON__) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error(
|
||||||
|
"[PlatformServiceFactory] ERROR: Singleton creation failed - storage returned undefined",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type guard: ensure singleton exists (should never be undefined at this point)
|
||||||
|
const singleton = global.__PLATFORM_SERVICE_SINGLETON__;
|
||||||
|
if (!singleton) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error(
|
||||||
|
"[PlatformServiceFactory] CRITICAL: Singleton is undefined after creation/retrieval",
|
||||||
|
);
|
||||||
|
// Fallback: create a new one
|
||||||
|
global.__PLATFORM_SERVICE_SINGLETON__ = create();
|
||||||
|
return global.__PLATFORM_SERVICE_SINGLETON__;
|
||||||
|
}
|
||||||
|
|
||||||
|
return singleton;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HMR-safe singleton instance of PlatformService
|
||||||
|
*
|
||||||
|
* This is the ONLY way to access PlatformService throughout the application.
|
||||||
|
* Do not create new instances of platform services directly.
|
||||||
|
*
|
||||||
|
* Uses lazy initialization via Proxy to avoid circular dependency issues at module load time.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```typescript
|
* ```typescript
|
||||||
* const platformService = PlatformServiceFactory.getInstance();
|
* import { PlatformSvc } from "./services/PlatformServiceFactory";
|
||||||
* await platformService.takePicture();
|
* await PlatformSvc.takePicture();
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
export class PlatformServiceFactory {
|
export const PlatformSvc = new Proxy({} as PlatformService, {
|
||||||
private static instance: PlatformService | null = null;
|
get(_target, prop) {
|
||||||
private static callCount = 0; // Debug counter
|
const svc = getPlatformSvc();
|
||||||
private static creationLogged = false; // Only log creation once
|
const value = (svc as unknown as Record<string, unknown>)[prop as string];
|
||||||
|
// Bind methods to maintain 'this' context
|
||||||
|
if (typeof value === "function") {
|
||||||
|
return value.bind(svc);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Preserve singleton across Vite HMR
|
||||||
|
if (import.meta?.hot) {
|
||||||
|
import.meta.hot.accept(() => {
|
||||||
|
// Don't recreate on HMR - keep existing instance
|
||||||
|
const global = getGlobal();
|
||||||
|
if (!global.__PLATFORM_SERVICE_SINGLETON__) {
|
||||||
|
// Restore singleton if it was lost during HMR
|
||||||
|
global.__PLATFORM_SERVICE_SINGLETON__ = getPlatformSvc();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
import.meta.hot.dispose(() => {
|
||||||
|
// Don't delete - keep the global instance
|
||||||
|
// The singleton will persist in globalThis/window/self
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legacy factory class for backward compatibility
|
||||||
|
* @deprecated Use `PlatformSvc` directly instead
|
||||||
|
*/
|
||||||
|
export class PlatformServiceFactory {
|
||||||
/**
|
/**
|
||||||
* Gets or creates the singleton instance of PlatformService.
|
* Gets the singleton instance of PlatformService.
|
||||||
* Creates the appropriate platform-specific implementation based on environment.
|
* @deprecated Use `PlatformSvc` directly instead
|
||||||
*
|
|
||||||
* @returns {PlatformService} The singleton instance of PlatformService
|
|
||||||
*/
|
*/
|
||||||
public static getInstance(): PlatformService {
|
public static getInstance(): PlatformService {
|
||||||
PlatformServiceFactory.callCount++;
|
return PlatformSvc;
|
||||||
|
|
||||||
if (PlatformServiceFactory.instance) {
|
|
||||||
// Normal case - return existing instance silently
|
|
||||||
return PlatformServiceFactory.instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only log when actually creating the instance
|
|
||||||
const platform = process.env.VITE_PLATFORM || "web";
|
|
||||||
|
|
||||||
if (!PlatformServiceFactory.creationLogged) {
|
|
||||||
// Use console for critical startup message to avoid circular dependency
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log(
|
|
||||||
`[PlatformServiceFactory] Creating singleton instance for platform: ${platform}`,
|
|
||||||
);
|
|
||||||
PlatformServiceFactory.creationLogged = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (platform) {
|
|
||||||
case "capacitor":
|
|
||||||
PlatformServiceFactory.instance = new CapacitorPlatformService();
|
|
||||||
break;
|
|
||||||
case "electron":
|
|
||||||
// Use a specialized electron service that extends CapacitorPlatformService
|
|
||||||
PlatformServiceFactory.instance = new ElectronPlatformService();
|
|
||||||
break;
|
|
||||||
case "web":
|
|
||||||
default:
|
|
||||||
PlatformServiceFactory.instance = new WebPlatformService();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return PlatformServiceFactory.instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Debug method to check singleton usage stats
|
* Debug method to check singleton usage stats
|
||||||
*/
|
*/
|
||||||
public static getStats(): { callCount: number; instanceExists: boolean } {
|
public static getStats(): { callCount: number; instanceExists: boolean } {
|
||||||
|
const global = getGlobal();
|
||||||
return {
|
return {
|
||||||
callCount: PlatformServiceFactory.callCount,
|
callCount: 0, // Deprecated - no longer tracking
|
||||||
instanceExists: PlatformServiceFactory.instance !== null,
|
instanceExists: global.__PLATFORM_SERVICE_SINGLETON__ !== undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
135
src/services/platforms/OperationQueue.ts
Normal file
135
src/services/platforms/OperationQueue.ts
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
/**
|
||||||
|
* Shared operation queue handler for database services
|
||||||
|
*
|
||||||
|
* Provides a reusable queue mechanism for database operations that need to
|
||||||
|
* wait for initialization before execution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { QueuedOperation } from "./types";
|
||||||
|
import { logger } from "../../utils/logger";
|
||||||
|
|
||||||
|
export interface QueueExecutor<TDb> {
|
||||||
|
executeRun(db: TDb, sql: string, params: unknown[]): Promise<unknown>;
|
||||||
|
executeQuery(db: TDb, sql: string, params: unknown[]): Promise<unknown>;
|
||||||
|
executeRawQuery?(db: TDb, sql: string, params: unknown[]): Promise<unknown>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class OperationQueue<TDb> {
|
||||||
|
private operationQueue: Array<QueuedOperation> = [];
|
||||||
|
private isProcessingQueue: boolean = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process queued operations
|
||||||
|
*/
|
||||||
|
async processQueue(
|
||||||
|
db: TDb,
|
||||||
|
executor: QueueExecutor<TDb>,
|
||||||
|
serviceName: string,
|
||||||
|
): Promise<void> {
|
||||||
|
if (this.isProcessingQueue || !db) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isProcessingQueue = true;
|
||||||
|
|
||||||
|
while (this.operationQueue.length > 0) {
|
||||||
|
const operation = this.operationQueue.shift();
|
||||||
|
if (!operation) continue;
|
||||||
|
|
||||||
|
try {
|
||||||
|
let result: unknown;
|
||||||
|
switch (operation.type) {
|
||||||
|
case "run":
|
||||||
|
result = await executor.executeRun(
|
||||||
|
db,
|
||||||
|
operation.sql,
|
||||||
|
operation.params,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case "query":
|
||||||
|
result = await executor.executeQuery(
|
||||||
|
db,
|
||||||
|
operation.sql,
|
||||||
|
operation.params,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case "rawQuery":
|
||||||
|
if (executor.executeRawQuery) {
|
||||||
|
result = await executor.executeRawQuery(
|
||||||
|
db,
|
||||||
|
operation.sql,
|
||||||
|
operation.params,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Fallback to query if rawQuery not supported
|
||||||
|
result = await executor.executeQuery(
|
||||||
|
db,
|
||||||
|
operation.sql,
|
||||||
|
operation.params,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
operation.resolve(result);
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(
|
||||||
|
`[${serviceName}] Error while processing SQL queue:`,
|
||||||
|
error,
|
||||||
|
);
|
||||||
|
logger.error(
|
||||||
|
`[${serviceName}] Failed operation - Type: ${operation.type}, SQL: ${operation.sql}`,
|
||||||
|
);
|
||||||
|
logger.error(
|
||||||
|
`[${serviceName}] Failed operation - Params:`,
|
||||||
|
operation.params,
|
||||||
|
);
|
||||||
|
operation.reject(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isProcessingQueue = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queue an operation for later execution
|
||||||
|
*
|
||||||
|
* @param operation - Pre-constructed operation object (allows platform-specific parameter conversion)
|
||||||
|
* @param initialized - Whether the database is initialized
|
||||||
|
* @param db - Database connection (if available)
|
||||||
|
* @param onQueue - Callback to trigger queue processing
|
||||||
|
*/
|
||||||
|
queueOperation<R>(
|
||||||
|
operation: QueuedOperation,
|
||||||
|
initialized: boolean,
|
||||||
|
db: TDb | null,
|
||||||
|
onQueue: () => void,
|
||||||
|
): Promise<R> {
|
||||||
|
return new Promise<R>((resolve, reject) => {
|
||||||
|
// Wrap the operation's resolve/reject to match our Promise
|
||||||
|
const wrappedOperation: QueuedOperation = {
|
||||||
|
...operation,
|
||||||
|
resolve: (value: unknown) => {
|
||||||
|
operation.resolve(value);
|
||||||
|
resolve(value as R);
|
||||||
|
},
|
||||||
|
reject: (reason: unknown) => {
|
||||||
|
operation.reject(reason);
|
||||||
|
reject(reason);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
this.operationQueue.push(wrappedOperation);
|
||||||
|
|
||||||
|
// If already initialized, trigger queue processing
|
||||||
|
if (initialized && db) {
|
||||||
|
onQueue();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current queue length (for debugging)
|
||||||
|
*/
|
||||||
|
getQueueLength(): number {
|
||||||
|
return this.operationQueue.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/services/platforms/sqlite.ts
Normal file
20
src/services/platforms/sqlite.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* Shared SQLite connection manager for Capacitor platform
|
||||||
|
*
|
||||||
|
* Ensures only one SQLiteConnection instance exists across the application,
|
||||||
|
* preventing connection desync issues and unnecessary connection recreation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { CapacitorSQLite, SQLiteConnection } from "@capacitor-community/sqlite";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Native Capacitor SQLite plugin instance
|
||||||
|
* This is the bridge to the native SQLite implementation
|
||||||
|
*/
|
||||||
|
export const CAP_SQLITE = CapacitorSQLite;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shared SQLite connection manager
|
||||||
|
* Use this instance throughout the application - do not create new SQLiteConnection instances
|
||||||
|
*/
|
||||||
|
export const SQLITE = new SQLiteConnection(CAP_SQLITE);
|
||||||
13
src/services/platforms/types.ts
Normal file
13
src/services/platforms/types.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Types for platform services
|
||||||
|
*/
|
||||||
|
|
||||||
|
export interface QueuedOperation {
|
||||||
|
type: "run" | "query" | "rawQuery";
|
||||||
|
sql: string;
|
||||||
|
params: unknown[];
|
||||||
|
resolve: (value: unknown) => void;
|
||||||
|
reject: (reason: unknown) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type QueuedOperationType = QueuedOperation["type"];
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { NotificationIface } from "@/constants/app";
|
import { NotificationIface } from "@/constants/app";
|
||||||
|
import router from "@/router";
|
||||||
|
|
||||||
const SEED_REMINDER_KEY = "seedPhraseReminderLastShown";
|
const SEED_REMINDER_KEY = "seedPhraseReminderLastShown";
|
||||||
const REMINDER_COOLDOWN_MS = 24 * 60 * 60 * 1000; // 24 hours in milliseconds
|
const REMINDER_COOLDOWN_MS = 24 * 60 * 60 * 1000; // 24 hours in milliseconds
|
||||||
@@ -53,8 +54,8 @@ export function createSeedReminderNotification(): NotificationIface {
|
|||||||
yesText: "Backup Identifier Seed",
|
yesText: "Backup Identifier Seed",
|
||||||
noText: "Remind me Later",
|
noText: "Remind me Later",
|
||||||
onYes: async () => {
|
onYes: async () => {
|
||||||
// Navigate to seed backup page
|
// Navigate to seed backup page using SPA routing
|
||||||
window.location.href = "/seed-backup";
|
await router.push({ path: "/seed-backup" });
|
||||||
},
|
},
|
||||||
onNo: async () => {
|
onNo: async () => {
|
||||||
// Mark as shown so it won't appear again for 24 hours
|
// Mark as shown so it won't appear again for 24 hours
|
||||||
|
|||||||
@@ -157,11 +157,27 @@ export default class DeepLinkRedirectView extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const capabilities = this.platformService.getCapabilities();
|
||||||
|
|
||||||
|
// If we're already in the native app, use router navigation instead
|
||||||
|
// of window.location.href (which doesn't work properly in Capacitor)
|
||||||
|
if (capabilities.isNativeApp) {
|
||||||
|
// Navigate directly using the router
|
||||||
|
const destinationPath = `/${this.destinationUrl}`;
|
||||||
|
this.$router.push(destinationPath).catch((error) => {
|
||||||
|
logger.error("Router navigation failed: " + errorStringForLog(error));
|
||||||
|
this.pageError =
|
||||||
|
"Unable to navigate to the destination. Please use a manual option below.";
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// For web contexts, use window.location.href to redirect to app
|
||||||
// For mobile, try the deep link URL; for desktop, use the web URL
|
// For mobile, try the deep link URL; for desktop, use the web URL
|
||||||
const redirectUrl = this.isMobile ? this.deepLinkUrl : this.webUrl;
|
const redirectUrl = this.isMobile ? this.deepLinkUrl : this.webUrl;
|
||||||
|
|
||||||
// Method 1: Try window.location.href (works on most browsers)
|
// Method 1: Try window.location.href (works on most browsers)
|
||||||
window.location.href = redirectUrl;
|
window.location.href = redirectUrl; // Do not use this on native apps! The channel to Capacitor gets messed up.
|
||||||
|
|
||||||
// Method 2: Fallback - create and click a link element
|
// Method 2: Fallback - create and click a link element
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user