refactor: /simplify — 22 fixes from 3-agent code review
Critical: - Fix MXC URI resolution: all avatars/images now resolve mxc:// to HTTP - Sync persistence: only write changed rooms, batch message upserts - lastActivityAt uses room.lastEvent.originServerTs, not creation time High: - Shared MatrixAvatar widget replaces 6 duplicate implementations - CallScreen decodes roomId before LiveKit JWT fetch - Decline button actually dismisses incoming call overlay - EventTypes constants replace raw string literals - LiveKitService uses lazy auth reads, onDispose disconnects Medium: - CallController is keepAlive with timer/room cleanup - authRepository is keepAlive (used from keepAlive notifier) - StreamController not closed in stopListening (crash fix) - Index on messages.roomId for query performance - 400ms debounce on user search - Static DateFormat in MessageBubble - Hardcoded strings replaced with AppConfig refs - Duplicate isDirectMessage field removed from RoomModel - E2EE profile claim corrected to Phase 3 Shared utilities: - lib/shared/widgets/matrix_avatar.dart - lib/shared/utils/mxc_url.dart - lib/shared/utils/room_preview.dart - lib/shared/utils/matrix_id.dart rawJson column removed (unused, caused main-thread jsonEncode) Schema migrated to v2 with roomId index. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Version: 1.0.1 | Created: 2026-04-01
|
||||
// Version: 1.1.0 | Created: 2026-04-01 | Updated: 2026-04-02
|
||||
// Profile screen. Shows current user info and logout button.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -6,7 +6,10 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../../core/auth/auth_notifier.dart';
|
||||
import '../../../core/auth/auth_state.dart';
|
||||
import '../../../core/config/app_config.dart';
|
||||
import '../../../core/network/matrix_client.dart';
|
||||
import '../../../shared/utils/matrix_id.dart';
|
||||
import '../../../shared/widgets/matrix_avatar.dart';
|
||||
|
||||
class ProfileScreen extends ConsumerWidget {
|
||||
const ProfileScreen({super.key, this.embedded = false});
|
||||
@@ -24,14 +27,12 @@ class ProfileScreen extends ConsumerWidget {
|
||||
orElse: () => '',
|
||||
);
|
||||
|
||||
final displayName = client.userID != null
|
||||
? (client.userID!.split(':').first.replaceFirst('@', ''))
|
||||
: 'Unknown';
|
||||
final displayName = client.userID?.matrixLocalpart ?? 'Unknown';
|
||||
|
||||
final body = ListView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
children: [
|
||||
_ProfileAvatar(displayName: displayName),
|
||||
Center(child: MatrixAvatar(name: displayName, radius: 48)),
|
||||
const SizedBox(height: 16),
|
||||
Center(
|
||||
child: Text(
|
||||
@@ -84,7 +85,7 @@ class ProfileScreen extends ConsumerWidget {
|
||||
ListTile(
|
||||
leading: const Icon(Icons.lock_outline),
|
||||
title: const Text('End-to-end encryption'),
|
||||
subtitle: const Text('Active — messages are encrypted'),
|
||||
subtitle: const Text('Setup coming in Phase 3'),
|
||||
enabled: false,
|
||||
),
|
||||
ListTile(
|
||||
@@ -112,7 +113,7 @@ class ProfileScreen extends ConsumerWidget {
|
||||
const SizedBox(height: 16),
|
||||
Center(
|
||||
child: Text(
|
||||
'M8Chat 1.0.0 · matrix.m8chat.au',
|
||||
'${AppConfig.appName} ${AppConfig.appVersion} · ${AppConfig.matrixServerName}',
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurface.withAlpha(77),
|
||||
),
|
||||
@@ -130,34 +131,6 @@ class ProfileScreen extends ConsumerWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class _ProfileAvatar extends StatelessWidget {
|
||||
const _ProfileAvatar({required this.displayName});
|
||||
|
||||
final String displayName;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final initials = displayName.isNotEmpty
|
||||
? displayName[0].toUpperCase()
|
||||
: '?';
|
||||
|
||||
return Center(
|
||||
child: CircleAvatar(
|
||||
radius: 48,
|
||||
backgroundColor: Theme.of(context).colorScheme.primary.withAlpha(51),
|
||||
child: Text(
|
||||
initials,
|
||||
style: TextStyle(
|
||||
fontSize: 36,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _LogoutButton extends StatelessWidget {
|
||||
const _LogoutButton({required this.onLogout});
|
||||
|
||||
@@ -171,7 +144,9 @@ class _LogoutButton extends StatelessWidget {
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
title: const Text('Sign out'),
|
||||
content: const Text('Are you sure you want to sign out of M8Chat?'),
|
||||
content: Text(
|
||||
'Are you sure you want to sign out of ${AppConfig.appName}?',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
|
||||
Reference in New Issue
Block a user