diff --git a/lib/data_objects/tetrio.dart b/lib/data_objects/tetrio.dart index 64da900..78022fe 100644 --- a/lib/data_objects/tetrio.dart +++ b/lib/data_objects/tetrio.dart @@ -896,8 +896,8 @@ class TetraLeagueBetaStream{ for (var entry in json) records.add(BetaRecord.fromJson(entry)); } - addFromAlphaStream(TetraLeagueAlphaStream oldStream){ - for (var entry in oldStream.records) { + addFromAlphaStream(List r){ + for (var entry in r) { records.add( BetaRecord( id: entry.ownId, diff --git a/lib/views/main_view.dart b/lib/views/main_view.dart index fc00955..861b37e 100644 --- a/lib/views/main_view.dart +++ b/lib/views/main_view.dart @@ -236,10 +236,10 @@ class _MainState extends State with TickerProviderStateMixin { _TLHistoryWasFetched = true; } } - if (storedRecords.isNotEmpty) _TLHistoryWasFetched = true; - - // add stored match to list only if it missing from retrived ones - if (oldMatches != null) tlStream.addFromAlphaStream(oldMatches); + if (storedRecords.isNotEmpty) { + _TLHistoryWasFetched = true; + tlStream.addFromAlphaStream(storedRecords); + } // tlMatches.sort((a, b) { // Newest matches gonna be shown at the top of the list // if(a.ts.isBefore(b.ts)) return 1; diff --git a/lib/views/tl_match_view.dart b/lib/views/tl_match_view.dart index 975d5b8..fdd2f76 100644 --- a/lib/views/tl_match_view.dart +++ b/lib/views/tl_match_view.dart @@ -112,10 +112,11 @@ class TlMatchResultState extends State { bool bigScreen = width >= 768; if (roundSelector.isNegative){ time = totalTime; - readableTime = "${t.matchLength}: ${time.inMinutes}:${secs.format(time.inMicroseconds /1000000 % 60)}"; + readableTime = !time.isNegative ? "${t.matchLength}: ${time.inMinutes}:${secs.format(time.inMicroseconds /1000000 % 60)}" : "${t.matchLength}: ---"; }else{ time = roundLengths[roundSelector]; - readableTime = "${t.roundLength}: ${time.inMinutes}:${secs.format(time.inMicroseconds /1000000 % 60)}\n${t.winner}: ${widget.record.results.rounds[roundSelector].firstWhere((element) => element.alive)}"; + int alive = widget.record.results.rounds[roundSelector].indexWhere((element) => element.alive); + readableTime = "${t.roundLength}: ${!time.isNegative ? "${time.inMinutes}:${secs.format(time.inMicroseconds /1000000 % 60)}" : "---"}\n${t.winner}: ${alive == -1 ? "idk" : widget.record.results.rounds[roundSelector][alive].username}"; } return SizedBox( width: width, @@ -448,12 +449,16 @@ class TlMatchResultState extends State { children: [ Text(t.matchLength), RichText( - text: TextSpan( - text: "${totalTime.inMinutes}:${NumberFormat("00", LocaleSettings.currentLocale.languageCode).format(totalTime.inSeconds%60)}", - style: const TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 28, fontWeight: FontWeight.w500, color: Colors.white), - children: [TextSpan(text: ".${NumberFormat("000", LocaleSettings.currentLocale.languageCode).format(totalTime.inMilliseconds%1000)}", style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 14, fontWeight: FontWeight.w100))] - ), - ) + text: !totalTime.isNegative ? TextSpan( + text: "${totalTime.inMinutes}:${NumberFormat("00", LocaleSettings.currentLocale.languageCode).format(totalTime.inSeconds%60)}", + style: const TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 28, fontWeight: FontWeight.w500, color: Colors.white), + children: [TextSpan(text: ".${NumberFormat("000", LocaleSettings.currentLocale.languageCode).format(totalTime.inMilliseconds%1000)}", style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 14, fontWeight: FontWeight.w100))] + ) : const TextSpan( + text: "-:--", + style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 28, fontWeight: FontWeight.w500, color: Colors.grey), + children: [TextSpan(text: ".---", style: TextStyle(fontFamily: "Eurostile Round", fontSize: 14, fontWeight: FontWeight.w100))] + ), + ) ],), if (widget.record.id != widget.record.replayID) Column( crossAxisAlignment: CrossAxisAlignment.end, @@ -507,11 +512,15 @@ class TlMatchResultState extends State { ), child: ListTile( leading:RichText( - text: TextSpan( + text: !time.isNegative ? TextSpan( text: "${time.inMinutes}:${NumberFormat("00", LocaleSettings.currentLocale.languageCode).format(time.inSeconds%60)}", style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 22, fontWeight: FontWeight.w500, color: Colors.white), children: [TextSpan(text: ".${NumberFormat("000", LocaleSettings.currentLocale.languageCode).format(time.inMilliseconds%1000)}", style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 14, fontWeight: FontWeight.w100))] - ), + ) : const TextSpan( + text: "-:--", + style: TextStyle(fontFamily: "Eurostile Round", fontSize: 22, fontWeight: FontWeight.w500, color: Colors.grey), + children: [TextSpan(text: ".---", style: TextStyle(fontFamily: "Eurostile Round", fontSize: 14, fontWeight: FontWeight.w100))] + ), ), title: Text(widget.record.results.rounds[index][0].username, textAlign: TextAlign.center), trailing: TrailingStats(