From 59682599a5a6a3b5d3109cd44d1c10a512cae369 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 24 Oct 2024 10:47:02 -0400 Subject: [PATCH 01/12] turn off choice array animation --- .../choreographer/widgets/choice_array.dart | 150 +++++++++--------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/lib/pangea/choreographer/widgets/choice_array.dart b/lib/pangea/choreographer/widgets/choice_array.dart index 32395099e..549665064 100644 --- a/lib/pangea/choreographer/widgets/choice_array.dart +++ b/lib/pangea/choreographer/widgets/choice_array.dart @@ -1,5 +1,4 @@ import 'dart:developer'; -import 'dart:math'; import 'package:collection/collection.dart'; import 'package:flutter/foundation.dart'; @@ -213,98 +212,99 @@ class ChoiceAnimationWidgetState extends State with SingleTickerProviderStateMixin { late final AnimationController _controller; late final Animation _animation; - AnimationState animationState = AnimationState.ready; + // AnimationState animationState = AnimationState.ready; @override void initState() { super.initState(); - _controller = AnimationController( - duration: const Duration(milliseconds: 300), - vsync: this, - ); + // _controller = AnimationController( + // duration: const Duration(milliseconds: 300), + // vsync: this, + // ); - _animation = widget.isGold - ? Tween(begin: 1.0, end: 1.2).animate(_controller) - : TweenSequence([ - TweenSequenceItem( - tween: Tween(begin: 0, end: -8 * pi / 180), - weight: 1.0, - ), - TweenSequenceItem( - tween: Tween(begin: -8 * pi / 180, end: 16 * pi / 180), - weight: 2.0, - ), - TweenSequenceItem( - tween: Tween(begin: 16 * pi / 180, end: 0), - weight: 1.0, - ), - ]).animate(_controller); + // _animation = widget.isGold + // ? Tween(begin: 1.0, end: 1.2).animate(_controller) + // : TweenSequence([ + // TweenSequenceItem( + // tween: Tween(begin: 0, end: -8 * pi / 180), + // weight: 1.0, + // ), + // TweenSequenceItem( + // tween: Tween(begin: -8 * pi / 180, end: 16 * pi / 180), + // weight: 2.0, + // ), + // TweenSequenceItem( + // tween: Tween(begin: 16 * pi / 180, end: 0), + // weight: 1.0, + // ), + // ]).animate(_controller); widget.enableInteraction(); - if (widget.selected && animationState == AnimationState.ready) { - widget.disableInteraction(); - _controller.forward(); - setState(() { - animationState = AnimationState.forward; - }); - } - _controller.addStatusListener((status) { - if (status == AnimationStatus.completed && - animationState == AnimationState.forward) { - _controller.reverse(); - setState(() { - animationState = AnimationState.reverse; - }); - } - if (status == AnimationStatus.dismissed && - animationState == AnimationState.reverse) { - widget.enableInteraction(); - setState(() { - animationState = AnimationState.finished; - }); - } - }); + // if (widget.selected && animationState == AnimationState.ready) { + // widget.disableInteraction(); + // _controller.forward(); + // setState(() { + // animationState = AnimationState.forward; + // }); + // } + // _controller.addStatusListener((status) { + // if (status == AnimationStatus.completed && + // animationState == AnimationState.forward) { + // _controller.reverse(); + // setState(() { + // animationState = AnimationState.reverse; + // }); + // } + // if (status == AnimationStatus.dismissed && + // animationState == AnimationState.reverse) { + // widget.enableInteraction(); + // setState(() { + // animationState = AnimationState.finished; + // }); + // } + // }); } @override void didUpdateWidget(ChoiceAnimationWidget oldWidget) { super.didUpdateWidget(oldWidget); - if (widget.selected && animationState == AnimationState.ready) { - widget.disableInteraction(); - _controller.forward(); - setState(() { - animationState = AnimationState.forward; - }); - } + // if (widget.selected && animationState == AnimationState.ready) { + // widget.disableInteraction(); + // _controller.forward(); + // setState(() { + // animationState = AnimationState.forward; + // }); + // } } @override Widget build(BuildContext context) { - return widget.isGold - ? AnimatedBuilder( - key: UniqueKey(), - animation: _animation, - builder: (context, child) { - return Transform.scale( - scale: _animation.value, - child: child, - ); - }, - child: widget.child, - ) - : AnimatedBuilder( - key: UniqueKey(), - animation: _animation, - builder: (context, child) { - return Transform.rotate( - angle: _animation.value, - child: child, - ); - }, - child: widget.child, - ); + return widget.child; + // widget.isGold + // ? AnimatedBuilder( + // key: UniqueKey(), + // animation: _animation, + // builder: (context, child) { + // return Transform.scale( + // scale: _animation.value, + // child: child, + // ); + // }, + // child: widget.child, + // ) + // : AnimatedBuilder( + // key: UniqueKey(), + // animation: _animation, + // builder: (context, child) { + // return Transform.rotate( + // angle: _animation.value, + // child: child, + // ); + // }, + // child: widget.child, + // ); } @override From 612296d341ef01c7bcd2e0e2e091a4aaa9a3570a Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 24 Oct 2024 10:47:31 -0400 Subject: [PATCH 02/12] bump version number --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index cdb13d908..98b846ae7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ description: Learn a language while texting your friends. # Pangea# publish_to: none # On version bump also increase the build number for F-Droid -version: 1.21.6+3546 +version: 1.21.7+3547 environment: sdk: ">=3.0.0 <4.0.0" From f141680cc73ca672a08c94fb6bc29242a81db93b Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 24 Oct 2024 11:07:05 -0400 Subject: [PATCH 03/12] comment out some references to myAnalytics stream --- lib/pangea/utils/logout.dart | 4 +-- .../multiple_choice_activity.dart | 26 +++++++++---------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/pangea/utils/logout.dart b/lib/pangea/utils/logout.dart index e2bdce074..c94cb8909 100644 --- a/lib/pangea/utils/logout.dart +++ b/lib/pangea/utils/logout.dart @@ -20,8 +20,8 @@ void pLogoutAction(BuildContext context, {bool? isDestructiveAction}) async { final matrix = Matrix.of(context); // before wiping out locally cached construct data, save it to the server - await MatrixState.pangeaController.myAnalytics - .sendLocalAnalyticsToAnalyticsRoom(); + // await MatrixState.pangeaController.myAnalytics + // .sendLocalAnalyticsToAnalyticsRoom(); await showFutureLoadingDialog( context: context, diff --git a/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart b/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart index ee892837b..3e8a9f126 100644 --- a/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart +++ b/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart @@ -2,13 +2,11 @@ import 'dart:developer'; import 'package:collection/collection.dart'; import 'package:fluffychat/pangea/choreographer/widgets/choice_array.dart'; -import 'package:fluffychat/pangea/controllers/my_analytics_controller.dart'; import 'package:fluffychat/pangea/enum/activity_type_enum.dart'; import 'package:fluffychat/pangea/models/practice_activities.dart/practice_activity_model.dart'; import 'package:fluffychat/pangea/models/practice_activities.dart/practice_activity_record_model.dart'; import 'package:fluffychat/pangea/widgets/practice_activity/practice_activity_card.dart'; import 'package:fluffychat/pangea/widgets/practice_activity/word_audio_button.dart'; -import 'package:fluffychat/widgets/matrix.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -68,18 +66,18 @@ class MultipleChoiceActivityState extends State { } // #freeze-activity - MatrixState.pangeaController.myAnalytics.setState( - AnalyticsStream( - // note - this maybe should be the activity event id - eventId: - widget.practiceCardController.widget.pangeaMessageEvent.eventId, - roomId: widget.practiceCardController.widget.pangeaMessageEvent.room.id, - constructs: currentRecordModel!.latestResponse!.toUses( - widget.practiceCardController.currentActivity!, - widget.practiceCardController.metadata, - ), - ), - ); + // MatrixState.pangeaController.myAnalytics.setState( + // AnalyticsStream( + // // note - this maybe should be the activity event id + // eventId: + // widget.practiceCardController.widget.pangeaMessageEvent.eventId, + // roomId: widget.practiceCardController.widget.pangeaMessageEvent.room.id, + // constructs: currentRecordModel!.latestResponse!.toUses( + // widget.practiceCardController.currentActivity!, + // widget.practiceCardController.metadata, + // ), + // ), + // ); // If the selected choice is correct, send the record and get the next activity if (widget.currentActivity.content.isCorrect(value, index)) { From 70d598c7b2cadfbab1f334b6c388c37f3182cf4f Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 24 Oct 2024 11:07:25 -0400 Subject: [PATCH 04/12] bump version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 98b846ae7..444472501 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ description: Learn a language while texting your friends. # Pangea# publish_to: none # On version bump also increase the build number for F-Droid -version: 1.21.7+3547 +version: 1.21.8+3548 environment: sdk: ">=3.0.0 <4.0.0" From 4c51bb15f63313f424bf9e9366535b6d540a144e Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 24 Oct 2024 11:22:04 -0400 Subject: [PATCH 05/12] turn back on analytics stream call in logout --- lib/pangea/utils/logout.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pangea/utils/logout.dart b/lib/pangea/utils/logout.dart index c94cb8909..e2bdce074 100644 --- a/lib/pangea/utils/logout.dart +++ b/lib/pangea/utils/logout.dart @@ -20,8 +20,8 @@ void pLogoutAction(BuildContext context, {bool? isDestructiveAction}) async { final matrix = Matrix.of(context); // before wiping out locally cached construct data, save it to the server - // await MatrixState.pangeaController.myAnalytics - // .sendLocalAnalyticsToAnalyticsRoom(); + await MatrixState.pangeaController.myAnalytics + .sendLocalAnalyticsToAnalyticsRoom(); await showFutureLoadingDialog( context: context, From 636fb150e8bac8e7b9f19b553a9432808a600fec Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 24 Oct 2024 11:22:21 -0400 Subject: [PATCH 06/12] bump version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 444472501..0a45647dc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ description: Learn a language while texting your friends. # Pangea# publish_to: none # On version bump also increase the build number for F-Droid -version: 1.21.8+3548 +version: 1.21.9+3549 environment: sdk: ">=3.0.0 <4.0.0" From 1944c19c50f1f6356a0f71db48f81051e98eaca6 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 24 Oct 2024 11:28:20 -0400 Subject: [PATCH 07/12] Revert "when inviting tachers to analytics room, request all particpants to ensure teacher isn't already a member" This reverts commit bc1dfc1e0e8f017c9c4032afcd4b18112042d35b. --- .../pangea_room_extension/room_analytics_extension.dart | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/pangea/extensions/pangea_room_extension/room_analytics_extension.dart b/lib/pangea/extensions/pangea_room_extension/room_analytics_extension.dart index b44c40ece..73371b080 100644 --- a/lib/pangea/extensions/pangea_room_extension/room_analytics_extension.dart +++ b/lib/pangea/extensions/pangea_room_extension/room_analytics_extension.dart @@ -99,7 +99,7 @@ extension AnalyticsRoomExtension on Room { await analyticsRoom.requestParticipants(); } - final List participants = await analyticsRoom.requestParticipants(); + final List participants = analyticsRoom.getParticipants(); final List uninvitedTeachers = teachersLocal .where((teacher) => !participants.contains(teacher)) .toList(); @@ -110,12 +110,8 @@ extension AnalyticsRoomExtension on Room { (teacher) => analyticsRoom.invite(teacher.id).catchError((err, s) { ErrorHandler.logError( e: err, - m: "Failed to invite teacher to analytics room", + m: "Failed to invite teacher ${teacher.id} to analytics room ${analyticsRoom.id}", s: s, - data: { - "teacherId": teacher.id, - "analyticsRoomId": analyticsRoom.id, - }, ); }), ), From f6bd07400098c4a0fd9205d6ae41926af9c0ccb2 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 24 Oct 2024 11:29:02 -0400 Subject: [PATCH 08/12] revert change to getting room participants --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 0a45647dc..dba848cf1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ description: Learn a language while texting your friends. # Pangea# publish_to: none # On version bump also increase the build number for F-Droid -version: 1.21.9+3549 +version: 1.22.0+3550 environment: sdk: ">=3.0.0 <4.0.0" From 5b232cea69df588ca3dbec732aad4378bb8d7bc4 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 24 Oct 2024 11:37:24 -0400 Subject: [PATCH 09/12] turn back on setState on analytics data --- .../multiple_choice_activity.dart | 26 ++++++++++--------- pubspec.yaml | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart b/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart index 3e8a9f126..ee892837b 100644 --- a/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart +++ b/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart @@ -2,11 +2,13 @@ import 'dart:developer'; import 'package:collection/collection.dart'; import 'package:fluffychat/pangea/choreographer/widgets/choice_array.dart'; +import 'package:fluffychat/pangea/controllers/my_analytics_controller.dart'; import 'package:fluffychat/pangea/enum/activity_type_enum.dart'; import 'package:fluffychat/pangea/models/practice_activities.dart/practice_activity_model.dart'; import 'package:fluffychat/pangea/models/practice_activities.dart/practice_activity_record_model.dart'; import 'package:fluffychat/pangea/widgets/practice_activity/practice_activity_card.dart'; import 'package:fluffychat/pangea/widgets/practice_activity/word_audio_button.dart'; +import 'package:fluffychat/widgets/matrix.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -66,18 +68,18 @@ class MultipleChoiceActivityState extends State { } // #freeze-activity - // MatrixState.pangeaController.myAnalytics.setState( - // AnalyticsStream( - // // note - this maybe should be the activity event id - // eventId: - // widget.practiceCardController.widget.pangeaMessageEvent.eventId, - // roomId: widget.practiceCardController.widget.pangeaMessageEvent.room.id, - // constructs: currentRecordModel!.latestResponse!.toUses( - // widget.practiceCardController.currentActivity!, - // widget.practiceCardController.metadata, - // ), - // ), - // ); + MatrixState.pangeaController.myAnalytics.setState( + AnalyticsStream( + // note - this maybe should be the activity event id + eventId: + widget.practiceCardController.widget.pangeaMessageEvent.eventId, + roomId: widget.practiceCardController.widget.pangeaMessageEvent.room.id, + constructs: currentRecordModel!.latestResponse!.toUses( + widget.practiceCardController.currentActivity!, + widget.practiceCardController.metadata, + ), + ), + ); // If the selected choice is correct, send the record and get the next activity if (widget.currentActivity.content.isCorrect(value, index)) { diff --git a/pubspec.yaml b/pubspec.yaml index dba848cf1..f1b17f029 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ description: Learn a language while texting your friends. # Pangea# publish_to: none # On version bump also increase the build number for F-Droid -version: 1.22.0+3550 +version: 1.22.1+3551 environment: sdk: ">=3.0.0 <4.0.0" From 63cd77baf49819322ade33aa646bfd9665a192bd Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 24 Oct 2024 11:58:11 -0400 Subject: [PATCH 10/12] Revert "turn off choice array animation" This reverts commit 59682599a5a6a3b5d3109cd44d1c10a512cae369. --- .../choreographer/widgets/choice_array.dart | 150 +++++++++--------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/lib/pangea/choreographer/widgets/choice_array.dart b/lib/pangea/choreographer/widgets/choice_array.dart index 549665064..32395099e 100644 --- a/lib/pangea/choreographer/widgets/choice_array.dart +++ b/lib/pangea/choreographer/widgets/choice_array.dart @@ -1,4 +1,5 @@ import 'dart:developer'; +import 'dart:math'; import 'package:collection/collection.dart'; import 'package:flutter/foundation.dart'; @@ -212,99 +213,98 @@ class ChoiceAnimationWidgetState extends State with SingleTickerProviderStateMixin { late final AnimationController _controller; late final Animation _animation; - // AnimationState animationState = AnimationState.ready; + AnimationState animationState = AnimationState.ready; @override void initState() { super.initState(); - // _controller = AnimationController( - // duration: const Duration(milliseconds: 300), - // vsync: this, - // ); + _controller = AnimationController( + duration: const Duration(milliseconds: 300), + vsync: this, + ); - // _animation = widget.isGold - // ? Tween(begin: 1.0, end: 1.2).animate(_controller) - // : TweenSequence([ - // TweenSequenceItem( - // tween: Tween(begin: 0, end: -8 * pi / 180), - // weight: 1.0, - // ), - // TweenSequenceItem( - // tween: Tween(begin: -8 * pi / 180, end: 16 * pi / 180), - // weight: 2.0, - // ), - // TweenSequenceItem( - // tween: Tween(begin: 16 * pi / 180, end: 0), - // weight: 1.0, - // ), - // ]).animate(_controller); + _animation = widget.isGold + ? Tween(begin: 1.0, end: 1.2).animate(_controller) + : TweenSequence([ + TweenSequenceItem( + tween: Tween(begin: 0, end: -8 * pi / 180), + weight: 1.0, + ), + TweenSequenceItem( + tween: Tween(begin: -8 * pi / 180, end: 16 * pi / 180), + weight: 2.0, + ), + TweenSequenceItem( + tween: Tween(begin: 16 * pi / 180, end: 0), + weight: 1.0, + ), + ]).animate(_controller); widget.enableInteraction(); - // if (widget.selected && animationState == AnimationState.ready) { - // widget.disableInteraction(); - // _controller.forward(); - // setState(() { - // animationState = AnimationState.forward; - // }); - // } - // _controller.addStatusListener((status) { - // if (status == AnimationStatus.completed && - // animationState == AnimationState.forward) { - // _controller.reverse(); - // setState(() { - // animationState = AnimationState.reverse; - // }); - // } - // if (status == AnimationStatus.dismissed && - // animationState == AnimationState.reverse) { - // widget.enableInteraction(); - // setState(() { - // animationState = AnimationState.finished; - // }); - // } - // }); + if (widget.selected && animationState == AnimationState.ready) { + widget.disableInteraction(); + _controller.forward(); + setState(() { + animationState = AnimationState.forward; + }); + } + _controller.addStatusListener((status) { + if (status == AnimationStatus.completed && + animationState == AnimationState.forward) { + _controller.reverse(); + setState(() { + animationState = AnimationState.reverse; + }); + } + if (status == AnimationStatus.dismissed && + animationState == AnimationState.reverse) { + widget.enableInteraction(); + setState(() { + animationState = AnimationState.finished; + }); + } + }); } @override void didUpdateWidget(ChoiceAnimationWidget oldWidget) { super.didUpdateWidget(oldWidget); - // if (widget.selected && animationState == AnimationState.ready) { - // widget.disableInteraction(); - // _controller.forward(); - // setState(() { - // animationState = AnimationState.forward; - // }); - // } + if (widget.selected && animationState == AnimationState.ready) { + widget.disableInteraction(); + _controller.forward(); + setState(() { + animationState = AnimationState.forward; + }); + } } @override Widget build(BuildContext context) { - return widget.child; - // widget.isGold - // ? AnimatedBuilder( - // key: UniqueKey(), - // animation: _animation, - // builder: (context, child) { - // return Transform.scale( - // scale: _animation.value, - // child: child, - // ); - // }, - // child: widget.child, - // ) - // : AnimatedBuilder( - // key: UniqueKey(), - // animation: _animation, - // builder: (context, child) { - // return Transform.rotate( - // angle: _animation.value, - // child: child, - // ); - // }, - // child: widget.child, - // ); + return widget.isGold + ? AnimatedBuilder( + key: UniqueKey(), + animation: _animation, + builder: (context, child) { + return Transform.scale( + scale: _animation.value, + child: child, + ); + }, + child: widget.child, + ) + : AnimatedBuilder( + key: UniqueKey(), + animation: _animation, + builder: (context, child) { + return Transform.rotate( + angle: _animation.value, + child: child, + ); + }, + child: widget.child, + ); } @override From 6052e1618981b7fcc0f87f2412331df36fcbe75c Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 24 Oct 2024 12:01:05 -0400 Subject: [PATCH 11/12] bump version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index f1b17f029..10b124acf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ description: Learn a language while texting your friends. # Pangea# publish_to: none # On version bump also increase the build number for F-Droid -version: 1.22.1+3551 +version: 1.22.2+3552 environment: sdk: ">=3.0.0 <4.0.0" From 23b6dd08b55f3409b94066b250c0195f620d39ce Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 24 Oct 2024 12:19:00 -0400 Subject: [PATCH 12/12] when sending analytics to the server at logout, don't update the getAnalytics stream afterwards --- .../controllers/get_analytics_controller.dart | 7 ++--- .../controllers/my_analytics_controller.dart | 26 +++++++++++++++---- lib/pangea/utils/logout.dart | 2 +- pubspec.yaml | 2 +- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/lib/pangea/controllers/get_analytics_controller.dart b/lib/pangea/controllers/get_analytics_controller.dart index 03cb2d60b..66cf39501 100644 --- a/lib/pangea/controllers/get_analytics_controller.dart +++ b/lib/pangea/controllers/get_analytics_controller.dart @@ -22,7 +22,7 @@ import 'package:sentry_flutter/sentry_flutter.dart'; class GetAnalyticsController { late PangeaController _pangeaController; final List _cache = []; - StreamSubscription? _analyticsUpdateSubscription; + StreamSubscription? _analyticsUpdateSubscription; CachedStreamController> analyticsStream = CachedStreamController>(); @@ -87,8 +87,9 @@ class GetAnalyticsController { prevXP = null; } - Future onAnalyticsUpdate(AnalyticsUpdateType type) async { - if (type == AnalyticsUpdateType.server) { + Future onAnalyticsUpdate(AnalyticsUpdate analyticsUpdate) async { + if (analyticsUpdate.isLogout) return; + if (analyticsUpdate.type == AnalyticsUpdateType.server) { await getConstructs(forceUpdate: true); } updateAnalyticsStream(); diff --git a/lib/pangea/controllers/my_analytics_controller.dart b/lib/pangea/controllers/my_analytics_controller.dart index 77e6caf27..6ffa1ef31 100644 --- a/lib/pangea/controllers/my_analytics_controller.dart +++ b/lib/pangea/controllers/my_analytics_controller.dart @@ -21,8 +21,8 @@ enum AnalyticsUpdateType { server, local } /// 2) constructs used by the user, both in sending messages and doing practice activities class MyAnalyticsController extends BaseController { late PangeaController _pangeaController; - CachedStreamController analyticsUpdateStream = - CachedStreamController(); + CachedStreamController analyticsUpdateStream = + CachedStreamController(); StreamSubscription? _analyticsStream; Timer? _updateTimer; @@ -237,7 +237,9 @@ class MyAnalyticsController extends BaseController { final int newLevel = _pangeaController.analytics.level; newLevel > prevLevel ? sendLocalAnalyticsToAnalyticsRoom() - : analyticsUpdateStream.add(AnalyticsUpdateType.local); + : analyticsUpdateStream.add( + AnalyticsUpdate(AnalyticsUpdateType.local), + ); } /// Clears the local cache of recently sent constructs. Called before updating analytics @@ -281,7 +283,9 @@ class MyAnalyticsController extends BaseController { /// for the completion of the previous update and returns. Otherwise, it creates a new [_updateCompleter] and /// proceeds with the update process. If the update is successful, it clears any messages that were received /// since the last update and notifies the [analyticsUpdateStream]. - Future sendLocalAnalyticsToAnalyticsRoom() async { + Future sendLocalAnalyticsToAnalyticsRoom({ + onLogout = false, + }) async { if (_pangeaController.matrixState.client.userID == null) return; if (!(_updateCompleter?.isCompleted ?? true)) { await _updateCompleter!.future; @@ -293,7 +297,12 @@ class MyAnalyticsController extends BaseController { clearMessagesSinceUpdate(); lastUpdated = DateTime.now(); - analyticsUpdateStream.add(AnalyticsUpdateType.server); + analyticsUpdateStream.add( + AnalyticsUpdate( + AnalyticsUpdateType.server, + isLogout: onLogout, + ), + ); } catch (err, s) { ErrorHandler.logError( e: err, @@ -340,3 +349,10 @@ class AnalyticsStream { required this.constructs, }); } + +class AnalyticsUpdate { + final AnalyticsUpdateType type; + final bool isLogout; + + AnalyticsUpdate(this.type, {this.isLogout = false}); +} diff --git a/lib/pangea/utils/logout.dart b/lib/pangea/utils/logout.dart index e2bdce074..def632828 100644 --- a/lib/pangea/utils/logout.dart +++ b/lib/pangea/utils/logout.dart @@ -21,7 +21,7 @@ void pLogoutAction(BuildContext context, {bool? isDestructiveAction}) async { // before wiping out locally cached construct data, save it to the server await MatrixState.pangeaController.myAnalytics - .sendLocalAnalyticsToAnalyticsRoom(); + .sendLocalAnalyticsToAnalyticsRoom(onLogout: true); await showFutureLoadingDialog( context: context, diff --git a/pubspec.yaml b/pubspec.yaml index 98b846ae7..076a0ed49 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ description: Learn a language while texting your friends. # Pangea# publish_to: none # On version bump also increase the build number for F-Droid -version: 1.21.7+3547 +version: 1.22.3+3553 environment: sdk: ">=3.0.0 <4.0.0"