Skip to content

Commit

Permalink
fix(datastore): change server serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
LeadcodeDev committed Aug 15, 2024
1 parent ed76c1c commit 6d00c24
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/infrastructure/internals/datastore/parts/server_part.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -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);
Expand Down

0 comments on commit 6d00c24

Please sign in to comment.