From 08ccf7f159ce64c173cdb640653593e297f15f88 Mon Sep 17 00:00:00 2001 From: dan63047 Date: Thu, 1 Feb 2024 17:38:11 +0300 Subject: [PATCH] TL matches list bugfix --- lib/services/tetrio_crud.dart | 6 +++--- lib/views/main_view.dart | 8 +++++--- lib/widgets/user_thingy.dart | 1 - 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/services/tetrio_crud.dart b/lib/services/tetrio_crud.dart index 4f13830..5d42d00 100644 --- a/lib/services/tetrio_crud.dart +++ b/lib/services/tetrio_crud.dart @@ -228,7 +228,8 @@ class TetrioService extends DB { saveReplayStats(data); // saving to DB for later return data; } - /// Gets and returns Top TR as a double for a player with given [id]. May return null if player top tr is unknown + + /// Gets and returns Top TR for a player with given [id]. May return null if player top tr is unknown /// or api is unavaliable (404). May throw an exception, if something else happens. Future fetchTopTR(String id) async { try{ // read from cache @@ -287,7 +288,7 @@ class TetrioService extends DB { // so i'm going to document only unique differences between them /// Retrieves Tetra League history from p1nkl0bst3r api for a player with given [id]. Returns a list of states - /// (state = instance of player stats at some point of time). Can throw an exception if fails to retrieve data. + /// (state = instance of [TetrioPlayer] at some point of time). Can throw an exception if fails to retrieve data. Future> fetchAndsaveTLHistory(String id) async { Uri url; if (kIsWeb) { @@ -835,7 +836,6 @@ class TetrioService extends DB { } } - /// Retrieves general stats of [user] (nickname or id) from Tetra Channel api. Returns [TetrioPlayer] object of this user. /// If [isItDiscordID] is true, function expects [user] to be a discord user id. Throws an exception if fails to retrieve. Future fetchPlayer(String user, {bool isItDiscordID = false}) async { diff --git a/lib/views/main_view.dart b/lib/views/main_view.dart index da3e7d2..f82a24e 100644 --- a/lib/views/main_view.dart +++ b/lib/views/main_view.dart @@ -173,10 +173,13 @@ class _MainState extends State with TickerProviderStateMixin { TetraLeagueAlpha? compareWith; Set uniqueTL = {}; tlMatches = tlStream.records; + var storedRecords = await teto.getTLMatchesbyPlayerID(me.userId); // get old matches if (isTracking){ // if tracked - save data to local DB await teto.storeState(me); await teto.saveTLMatchesFromStream(tlStream); - var storedRecords = await teto.getTLMatchesbyPlayerID(me.userId); // get old matches + } + + // building list of TL matches for (var match in storedRecords) { // add stored match to list only if it missing from retrived ones if (!tlMatches.contains(match)) tlMatches.add(match); @@ -186,8 +189,7 @@ class _MainState extends State with TickerProviderStateMixin { if(a.timestamp.isAtSameMomentAs(b.timestamp)) return 0; if(a.timestamp.isAfter(b.timestamp)) return -1; return 0; - }); - } + }); // Handling history if(fetchHistory) await teto.fetchAndsaveTLHistory(_searchFor); // Retrieve if needed diff --git a/lib/widgets/user_thingy.dart b/lib/widgets/user_thingy.dart index c839a21..a2fa26d 100644 --- a/lib/widgets/user_thingy.dart +++ b/lib/widgets/user_thingy.dart @@ -1,4 +1,3 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:syncfusion_flutter_gauges/gauges.dart';