Merge branch 'main' into toolbar-min-dimensions
This commit is contained in:
commit
d64fe86d6a
5 changed files with 29 additions and 16 deletions
|
|
@ -22,7 +22,7 @@ import 'package:sentry_flutter/sentry_flutter.dart';
|
|||
class GetAnalyticsController {
|
||||
late PangeaController _pangeaController;
|
||||
final List<AnalyticsCacheEntry> _cache = [];
|
||||
StreamSubscription<AnalyticsUpdateType>? _analyticsUpdateSubscription;
|
||||
StreamSubscription<AnalyticsUpdate>? _analyticsUpdateSubscription;
|
||||
CachedStreamController<List<OneConstructUse>> analyticsStream =
|
||||
CachedStreamController<List<OneConstructUse>>();
|
||||
|
||||
|
|
@ -87,8 +87,9 @@ class GetAnalyticsController {
|
|||
prevXP = null;
|
||||
}
|
||||
|
||||
Future<void> onAnalyticsUpdate(AnalyticsUpdateType type) async {
|
||||
if (type == AnalyticsUpdateType.server) {
|
||||
Future<void> onAnalyticsUpdate(AnalyticsUpdate analyticsUpdate) async {
|
||||
if (analyticsUpdate.isLogout) return;
|
||||
if (analyticsUpdate.type == AnalyticsUpdateType.server) {
|
||||
await getConstructs(forceUpdate: true);
|
||||
}
|
||||
updateAnalyticsStream();
|
||||
|
|
|
|||
|
|
@ -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<AnalyticsStream> {
|
||||
late PangeaController _pangeaController;
|
||||
CachedStreamController<AnalyticsUpdateType> analyticsUpdateStream =
|
||||
CachedStreamController<AnalyticsUpdateType>();
|
||||
CachedStreamController<AnalyticsUpdate> analyticsUpdateStream =
|
||||
CachedStreamController<AnalyticsUpdate>();
|
||||
StreamSubscription<AnalyticsStream>? _analyticsStream;
|
||||
Timer? _updateTimer;
|
||||
|
||||
|
|
@ -237,7 +237,9 @@ class MyAnalyticsController extends BaseController<AnalyticsStream> {
|
|||
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<AnalyticsStream> {
|
|||
/// 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<void> sendLocalAnalyticsToAnalyticsRoom() async {
|
||||
Future<void> 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<AnalyticsStream> {
|
|||
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});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ extension AnalyticsRoomExtension on Room {
|
|||
await analyticsRoom.requestParticipants();
|
||||
}
|
||||
|
||||
final List<User> participants = await analyticsRoom.requestParticipants();
|
||||
final List<User> participants = analyticsRoom.getParticipants();
|
||||
final List<User> 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,
|
||||
},
|
||||
);
|
||||
}),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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.22.3+3553
|
||||
|
||||
environment:
|
||||
sdk: ">=3.0.0 <4.0.0"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue