refactor: Update Twitter OAuth 2.0 PKCE flow for dynamic redirect URI and public client authentication, replace SVG back button with a native icon, and enhance Twitter login error reporting.
This commit is contained in:
@@ -75,6 +75,7 @@ class MessagingNotifier extends StateNotifier<MessagingState> {
|
||||
MessagingNotifier(this._repository, this._ref)
|
||||
: super(const MessagingState()) {
|
||||
_initSocketListeners();
|
||||
loadUnreadCount();
|
||||
}
|
||||
|
||||
String? get _currentUserId => _ref.read(authProvider).user?.id;
|
||||
@@ -132,9 +133,15 @@ class MessagingNotifier extends StateNotifier<MessagingState> {
|
||||
return c;
|
||||
}).toList();
|
||||
|
||||
// Recalculate total unread count
|
||||
final totalUnread = updatedConversations.fold<int>(
|
||||
0, (sum, c) => sum + c.unreadCount,
|
||||
);
|
||||
|
||||
state = state.copyWith(
|
||||
messages: updatedMessages,
|
||||
conversations: updatedConversations,
|
||||
unreadCount: totalUnread,
|
||||
);
|
||||
}));
|
||||
|
||||
@@ -575,9 +582,13 @@ class MessagingNotifier extends StateNotifier<MessagingState> {
|
||||
..remove(conversationId);
|
||||
final updatedConversations =
|
||||
state.conversations.where((c) => c.id != conversationId).toList();
|
||||
final totalUnread = updatedConversations.fold<int>(
|
||||
0, (sum, c) => sum + c.unreadCount,
|
||||
);
|
||||
state = state.copyWith(
|
||||
messages: updatedMessages,
|
||||
conversations: updatedConversations,
|
||||
unreadCount: totalUnread,
|
||||
clearActiveConversation: true,
|
||||
);
|
||||
} catch (_) {
|
||||
|
||||
@@ -171,8 +171,8 @@ class _ChatScreenState extends ConsumerState<ChatScreen>
|
||||
_showConfirmDialog(
|
||||
title: 'Clear Chat',
|
||||
message: 'Are you sure you want to clear all messages? This cannot be undone.',
|
||||
onConfirm: () {
|
||||
ref.read(messagingProvider.notifier).clearChat(widget.conversationId);
|
||||
onConfirm: () async {
|
||||
await ref.read(messagingProvider.notifier).clearChat(widget.conversationId);
|
||||
},
|
||||
);
|
||||
break;
|
||||
@@ -194,9 +194,10 @@ class _ChatScreenState extends ConsumerState<ChatScreen>
|
||||
_showConfirmDialog(
|
||||
title: 'Delete Conversation',
|
||||
message: 'Are you sure you want to delete this conversation? This cannot be undone.',
|
||||
onConfirm: () {
|
||||
ref.read(messagingProvider.notifier).deleteConversation(widget.conversationId);
|
||||
context.go('/messages');
|
||||
onConfirm: () async {
|
||||
final notifier = ref.read(messagingProvider.notifier);
|
||||
await notifier.deleteConversation(widget.conversationId);
|
||||
if (mounted) context.go('/messages');
|
||||
},
|
||||
isDanger: true,
|
||||
);
|
||||
@@ -207,7 +208,7 @@ class _ChatScreenState extends ConsumerState<ChatScreen>
|
||||
void _showConfirmDialog({
|
||||
required String title,
|
||||
required String message,
|
||||
required VoidCallback onConfirm,
|
||||
required Future<void> Function() onConfirm,
|
||||
bool isDanger = false,
|
||||
}) {
|
||||
showDialog(
|
||||
|
||||
Reference in New Issue
Block a user