Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
current stand
Browse files Browse the repository at this point in the history
  • Loading branch information
Myzel394 committed Sep 27, 2023
1 parent c210024 commit 8de4b32
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
30 changes: 16 additions & 14 deletions lib/api/get-relays-meta.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,34 +96,36 @@ class RelayMeta {
relay: relay,
canRead: canRead,
canWrite: canWrite,
name: adnk(content, "info.name") ?? relay,
contactInfo: adnk(content, "info.contact") ?? "",
description: adnk(content, "info.description") ?? "",
connectionLatencies:
List<int?>.from(adnk(content, "latency.$worldRegion.0") ?? [])
.where((value) => value != null)
.toList()
.cast<int>(),
name: adnk<dynamic>(content, "info.name") ?? relay,
contactInfo: adnk<dynamic>(content, "info.contact") ?? "",
description: adnk<dynamic>(content, "info.description") ?? "",
connectionLatencies: List<int?>.from(
adnk<dynamic>(content, "latency.$worldRegion.0") ?? [])
.where((value) => value != null)
.toList()
.cast<int>(),
readLatencies:
List<int?>.from(adnk(content, "latency.$worldRegion.1") ?? [])
List<int?>.from(adnk<dynamic>(content, "latency.$worldRegion.1") ?? [])
.where((value) => value != null)
.toList()
.cast<int>(),
writeLatencies:
List<int?>.from(adnk(content, "latency.$worldRegion.2") ?? [])
List<int?>.from(adnk<dynamic>(content, "latency.$worldRegion.2") ?? [])
.where((value) => value != null)
.toList()
.cast<int>(),
maxContentLength:
adnk(content, "info.limitations.max_content_length") ??
adnk<dynamic>(content, "info.limitations.max_content_length") ??
MIN_LENGTH,
maxMessageLength:
adnk(content, "info.limitations.max_message_length") ??
adnk<dynamic>(content, "info.limitations.max_message_length") ??
MIN_LENGTH,
requiresPayment:
adnk(content, "info.limitations.payment_required") ?? false,
adnk<dynamic>(content, "info.limitations.payment_required") ??
false,
minPowDifficulty:
adnk(content, "info.limitations.min_pow_difficulty") ?? 0);
adnk<dynamic>(content, "info.limitations.min_pow_difficulty") ??
0);

bool get isSuitable =>
canWrite &&
Expand Down
8 changes: 5 additions & 3 deletions lib/utils/access-deeply-nested-key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ T? accessDeeplyNestedKey<T>(final Map<String, dynamic> obj, final String path) {
dynamic result = obj;

for (final subPath in path.split(".")) {
if (result is List
? result[int.parse(subPath)]
: result.containsKey(subPath)) {
if (result is List) {
final index = int.tryParse(subPath)!;

result = result[index];
} else if (result.containsKey(subPath)) {
result = result[subPath];
} else {
return null;
Expand Down

0 comments on commit 8de4b32

Please sign in to comment.