1
0
mirror of https://github.com/DocNR/POWR.git synced 2025-05-16 19:25:51 +00:00
POWR/lib/db/db-service.ts
DocNR c64ca8bf19 fix: profile stats loading and display issues on iOS and Android
- Enhanced NostrBandService with aggressive cache-busting and better error handling
- Improved useProfileStats hook with optimized refresh settings and platform-specific logging
- Fixed ProfileFollowerStats UI to show actual values with loading indicators
- Added visual feedback during refresh operations
- Updated CHANGELOG.md to document these improvements

This resolves the issue where follower/following counts were not updating properly
on Android and iOS platforms.
2025-04-04 15:46:31 -04:00

65 lines
1.5 KiB
TypeScript

// lib/db/db-service.ts
import { SQLiteDatabase } from 'expo-sqlite';
import { createLogger } from '@/lib/utils/logger';
// Create database-specific logger
const logger = createLogger('SQLite');
export class DbService {
private db: SQLiteDatabase;
constructor(db: SQLiteDatabase) {
this.db = db;
}
async execAsync(sql: string): Promise<void> {
try {
logger.debug('Executing SQL:', sql);
await this.db.execAsync(sql);
} catch (error) {
logger.error('SQL Error:', error);
throw error;
}
}
async runAsync(sql: string, params: any[] = []) {
try {
logger.debug('Running SQL:', sql);
logger.debug('Parameters:', params);
return await this.db.runAsync(sql, params);
} catch (error) {
logger.error('SQL Error:', error);
throw error;
}
}
async getFirstAsync<T>(sql: string, params: any[] = []): Promise<T | null> {
try {
return await this.db.getFirstAsync<T>(sql, params);
} catch (error) {
logger.error('SQL Error:', error);
throw error;
}
}
async getAllAsync<T>(sql: string, params: any[] = []): Promise<T[]> {
try {
return await this.db.getAllAsync<T>(sql, params);
} catch (error) {
logger.error('SQL Error:', error);
throw error;
}
}
async withTransactionAsync(action: () => Promise<void>): Promise<void> {
try {
await this.db.withTransactionAsync(async () => {
await action();
});
} catch (error) {
logger.error('Transaction Error:', error);
throw error;
}
}
}