<think>Let me analyze the staged changes to generate a proper conventional commit message.
All checks were successful
Frontend CI / build-and-push-web (push) Successful in 3m16s
Frontend CI / ota-android (push) Successful in 11m42s
Frontend CI / build-android-apk (push) Successful in 59m5s

Looking at the changes:

1. **New files**:
   - `app/(app)/(tabs)/profile/account-deletion.tsx` - account deletion screen
   - `app/(app)/(tabs)/profile/privacy-settings.tsx` - privacy settings screen
   - `src/screens/profile/AccountDeletionScreen.tsx` - account deletion implementation
   - `src/screens/profile/PrivacySettingsScreen.tsx` - privacy settings implementation

2. **Modified files**:
   - Database changes: `LocalDataSource.ts`, `DatabaseManager.ts`, `DatabaseConfig.ts`, `MigrationManager.ts` - refactoring database layer (removing LockManager, simplified initialization, added retry logic)
   - Auth store: `authStore.ts` - changed `initDatabase` to `switchDatabase`
   - Auth service: `authService.ts` - added privacy settings and account deletion methods
   - DTOs: `dto.ts` - added PrivacySettingsDTO, DeletionStatusDTO, VoteOptionDTO, VoteResultDTO types
   - Navigation: `hrefs.ts` - added new href functions for privacy settings and account deletion
   - Profile screens: `SettingsScreen.tsx`, `index.ts`, `_layout.tsx` - added new menu items and routes
   - Various message screens - added keyboard handling props
   - `app/_layout.tsx` - added CSS for mobile touch handling
   - `CreatePostScreen.tsx` - fixed vote_options format
   - `PostDetailScreen.tsx` - added type annotations for vote handling
   - `MediaCacheManager.ts` - updated to use new expo-file-system API
   - `VerificationSettingsScreen.tsx` - fixed type safety
   - `AccountSecurityScreen.tsx` - styling refactoring

This is a multi-faceted change involving:

Database refactoring, new privacy/account deletion features, bug fixes, and UI improvements. The database changes appear to be refactoring without new functionality. The most significant changes are the privacy settings and account deletion features, plus bug fixes like the vote options format and mobile touch handling.
</think>

feat(profile): add privacy settings and account deletion screens

Add privacy settings and account deletion functionality with new screens and APIs. Refactor database initialization to use switchDatabase for user switching. Fix vote options format in post creation and add type safety to vote handling. Improve mobile touch handling in layout and message screens. Update media cache to use new expo-file-system API.

BREAKING CHANGE: Database initialization now uses switchDatabase instead of initDatabase for user switching
This commit is contained in:
lafay
2026-04-08 16:48:19 +08:00
parent 96a5207cf8
commit be8f6de8cf
28 changed files with 1092 additions and 420 deletions

View File

@@ -23,33 +23,42 @@ import {
CREATE_POSTS_CACHE_TABLE,
} from './PostSchema';
export async function runMigrations(db: SQLiteDatabase): Promise<void> {
if (typeof window !== 'undefined') {
async function execWithRetry(db: SQLiteDatabase, sql: string, maxRetries = 5): Promise<void> {
for (let i = 0; i < maxRetries; i++) {
try {
await db.execAsync(`PRAGMA locking_mode = EXCLUSIVE;`);
await db.execAsync(`PRAGMA journal_mode = MEMORY;`);
await db.execAsync(`PRAGMA temp_store = MEMORY;`);
console.log('[MigrationManager] Web: 已设置 EXCLUSIVE locking + MEMORY journal/temp 模式');
} catch (e) {
console.warn('[MigrationManager] 设置 PRAGMA 失败:', e);
await db.execAsync(sql);
return;
} catch (error) {
const msg = String(error);
if (msg.includes('database is locked') && i < maxRetries - 1) {
const delay = 200 * (i + 1);
console.warn(`[MigrationManager] 数据库锁定,${delay}ms 后重试 (${i + 1}/${maxRetries})`);
await new Promise(r => setTimeout(r, delay));
continue;
}
throw error;
}
}
}
await db.execAsync(CREATE_MESSAGES_TABLE);
await db.execAsync(CREATE_CONVERSATIONS_TABLE);
await db.execAsync(CREATE_CONVERSATION_CACHE_TABLE);
await db.execAsync(CREATE_CONVERSATION_LIST_CACHE_TABLE);
await db.execAsync(CREATE_USERS_TABLE);
await db.execAsync(CREATE_CURRENT_USER_CACHE_TABLE);
await db.execAsync(CREATE_GROUPS_TABLE);
await db.execAsync(CREATE_GROUP_MEMBERS_TABLE);
await db.execAsync(CREATE_POSTS_CACHE_TABLE);
export async function runMigrations(db: SQLiteDatabase): Promise<void> {
await execWithRetry(db, 'PRAGMA busy_timeout = 10000;');
await execWithRetry(db, CREATE_MESSAGES_TABLE);
await execWithRetry(db, CREATE_CONVERSATIONS_TABLE);
await execWithRetry(db, CREATE_CONVERSATION_CACHE_TABLE);
await execWithRetry(db, CREATE_CONVERSATION_LIST_CACHE_TABLE);
await execWithRetry(db, CREATE_USERS_TABLE);
await execWithRetry(db, CREATE_CURRENT_USER_CACHE_TABLE);
await execWithRetry(db, CREATE_GROUPS_TABLE);
await execWithRetry(db, CREATE_GROUP_MEMBERS_TABLE);
await execWithRetry(db, CREATE_POSTS_CACHE_TABLE);
for (const indexSql of CREATE_MESSAGES_INDEXES) {
await db.execAsync(indexSql);
await execWithRetry(db, indexSql);
}
for (const indexSql of CREATE_GROUP_INDEXES) {
await db.execAsync(indexSql);
await execWithRetry(db, indexSql);
}
await MIGRATE_MESSAGES_TABLE(db);