From 6d00c242776d3e646466caa57cd418068f4a5ee6 Mon Sep 17 00:00:00 2001 From: Baptiste Parmantier Date: Thu, 15 Aug 2024 16:56:29 +0200 Subject: [PATCH] fix(datastore): change server serialization --- .../internals/datastore/parts/server_part.dart | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/infrastructure/internals/datastore/parts/server_part.dart b/lib/infrastructure/internals/datastore/parts/server_part.dart index 34a20a74..73781706 100644 --- a/lib/infrastructure/internals/datastore/parts/server_part.dart +++ b/lib/infrastructure/internals/datastore/parts/server_part.dart @@ -20,8 +20,9 @@ final class ServerPart implements DataStorePart { final cacheKey = _kernel.marshaller.cacheKey; final serverCacheKey = cacheKey.server(id); - if (await _kernel.marshaller.cache.has(serverCacheKey)) { - return _kernel.marshaller.serializers.server.serializeCache({'id': id.value}); + final rawServer = await _kernel.marshaller.cache.get(serverCacheKey); + if (rawServer != null) { + return _kernel.marshaller.serializers.server.serializeCache(rawServer); } final [serverResponse, channelsResponse, membersResponse] = await Future.wait([ @@ -36,10 +37,8 @@ final class ServerPart implements DataStorePart { 'members': membersResponse.body }); - final rawServer = await _kernel.marshaller.serializers.server.deserialize(server); - await Future.wait([ - _kernel.marshaller.cache.put(serverCacheKey, rawServer), + _kernel.marshaller.cache.put(serverCacheKey, await _kernel.marshaller.serializers.server.deserialize(server)), ...server.channels.list.values.map((channel) { final channelCacheKey = cacheKey.channel(channel.id); final rawChannel = _kernel.marshaller.serializers.channels.deserialize(channel);