~emersion/goguma

1cb3a5af2e3d577ebc0f18a91c75149c79497aff — Simon Ser 2 months ago af90605
page/buffer: fix unread counter not being cleared

We need to wait for messages to be loaded from the DB before
calling _markRead().

Closes: https://todo.sr.ht/~emersion/goguma/106
1 files changed, 10 insertions(+), 4 deletions(-)

M lib/page/buffer.dart
M lib/page/buffer.dart => lib/page/buffer.dart +10 -4
@@ 90,9 90,15 @@ class _BufferPageState extends State<BufferPage> with WidgetsBindingObserver {
		_scrollController.addListener(_handleScroll);

		// Timer.run prevents calling setState() from inside initState()
		Timer.run(() {
			_fetchChatHistory();
			_updateBufferFocus();
		Timer.run(() async {
			try {
				await _fetchChatHistory();
			} on Exception catch (err) {
				print('Failed to fetch chat history: $err');
			}
			if (mounted) {
				_updateBufferFocus();
			}
		});
	}



@@ 114,7 120,7 @@ class _BufferPageState extends State<BufferPage> with WidgetsBindingObserver {
		}
	}

	void _fetchChatHistory() async {
	Future<void> _fetchChatHistory() async {
		if (_chatHistoryLoading) {
			return;
		}