~emersion/goguma

60e700b32524293a26173fadf3ad81547525942e — Simon Ser a month ago 89867c4
Send ACK when running background sync

References: https://todo.sr.ht/~emersion/goguma/88
1 files changed, 6 insertions(+), 0 deletions(-)

M lib/main.dart
M lib/main.dart => lib/main.dart +6 -0
@@ 146,6 146,7 @@ void _initWorkManager() {

void _syncChatHistory(SendPort sendPort, ClientProvider clientProvider, NetworkListModel networkList) async {
	print('Starting chat history synchronization');
	sendPort.send(null); // send an ACK

	var autoReconnectLock = ClientAutoReconnectLock.acquire(clientProvider);



@@ 189,6 190,11 @@ void _dispatchWorkManager() {
			var receivePort = ReceivePort('work-manager:sync');
			var sendPort = IsolateNameServer.lookupPortByName('main:sync')!;
			sendPort.send(receivePort.sendPort);

			// Wait for an ACK
			await receivePort.first.timeout(const Duration(seconds: 5));

			// Wait for the result
			var data = await receivePort.first;
			receivePort.close();
			return data as bool;