🐛 Optimized typing indicator
This commit is contained in:
parent
0bbfa6ddde
commit
2a7876e22f
@ -337,7 +337,7 @@ class ChatRoomScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
typingDebouncer.value = Timer(const Duration(milliseconds: 1000), () {
|
typingDebouncer.value = Timer(const Duration(milliseconds: 850), () {
|
||||||
typingDebouncer.value = null;
|
typingDebouncer.value = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -384,9 +384,11 @@ class ChatRoomScreen extends HookConsumerWidget {
|
|||||||
if (!pkt.type.startsWith('messages')) return;
|
if (!pkt.type.startsWith('messages')) return;
|
||||||
if (['messages.read'].contains(pkt.type)) return;
|
if (['messages.read'].contains(pkt.type)) return;
|
||||||
|
|
||||||
if (pkt.type == 'messages.typing') {
|
if (pkt.type == 'messages.typing' && pkt.data?['sender'] != null) {
|
||||||
|
if (pkt.data?['sender_id'] == chatIdentity.value?.id) return;
|
||||||
|
|
||||||
final sender = SnChatMember.fromJson(
|
final sender = SnChatMember.fromJson(
|
||||||
pkt.data!['sender'],
|
pkt.data?['sender'],
|
||||||
).copyWith(lastTyped: DateTime.now());
|
).copyWith(lastTyped: DateTime.now());
|
||||||
|
|
||||||
// Check if the sender is already in the typing list
|
// Check if the sender is already in the typing list
|
||||||
@ -733,7 +735,7 @@ class ChatRoomScreen extends HookConsumerWidget {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
AnimatedSwitcher(
|
AnimatedSwitcher(
|
||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 150),
|
||||||
switchInCurve: Curves.fastEaseInToSlowEaseOut,
|
switchInCurve: Curves.fastEaseInToSlowEaseOut,
|
||||||
switchOutCurve: Curves.fastEaseInToSlowEaseOut,
|
switchOutCurve: Curves.fastEaseInToSlowEaseOut,
|
||||||
transitionBuilder: (
|
transitionBuilder: (
|
||||||
@ -800,7 +802,7 @@ class ChatRoomScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
: const SizedBox.shrink(
|
: const SizedBox.shrink(
|
||||||
key: ValueKey('no_typing'),
|
key: ValueKey('typing-indicator-none'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
_ChatInput(
|
_ChatInput(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user