Fix skill XP from constructSummary not being generated bug
Also added commented out code to fetch last construct summary instead of generate a new one for testing
This commit is contained in:
parent
64aba1d6e4
commit
61c60f5ff6
5 changed files with 66 additions and 62 deletions
|
|
@ -1,11 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/analytics_misc/client_analytics_extension.dart';
|
||||
import 'package:fluffychat/pangea/analytics_misc/construct_list_model.dart';
|
||||
import 'package:fluffychat/pangea/analytics_misc/construct_type_enum.dart';
|
||||
|
|
@ -22,6 +16,10 @@ import 'package:fluffychat/pangea/events/constants/pangea_event_types.dart';
|
|||
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/models/language_model.dart';
|
||||
import 'package:fluffychat/pangea/practice_activities/practice_selection_repo.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
/// A minimized version of AnalyticsController that get the logged in user's analytics
|
||||
class GetAnalyticsController extends BaseController {
|
||||
|
|
@ -455,10 +453,13 @@ class GetAnalyticsController extends BaseController {
|
|||
// int diffXP = maxXP - minXP;
|
||||
// if (diffXP < 0) diffXP = 0;
|
||||
|
||||
Future<ConstructSummary?> getConstructSummaryFromStateEvent() async {
|
||||
ConstructSummary? getConstructSummaryFromStateEvent() {
|
||||
try {
|
||||
final Room? analyticsRoom = _client.analyticsRoomLocal(_l2!);
|
||||
if (analyticsRoom == null) return null;
|
||||
if (analyticsRoom == null) {
|
||||
debugPrint("Analytics room is null");
|
||||
return null;
|
||||
}
|
||||
final state =
|
||||
analyticsRoom.getState(PangeaEventTypes.constructSummary, '');
|
||||
if (state == null) return null;
|
||||
|
|
@ -477,9 +478,10 @@ class GetAnalyticsController extends BaseController {
|
|||
// generate level up analytics as a construct summary
|
||||
ConstructSummary summary;
|
||||
try {
|
||||
final int maxXP = constructListModel.calculateXpWithLevel(upperLevel);
|
||||
final int minXP = constructListModel.calculateXpWithLevel(lowerLevel);
|
||||
final int maxXP = constructListModel.calculateXpWithLevel(lowerLevel);
|
||||
final int minXP = constructListModel.calculateXpWithLevel(upperLevel);
|
||||
int diffXP = maxXP - minXP;
|
||||
debugPrint("minXP: $minXP, maxXP: $maxXP, diffXP: $diffXP");
|
||||
if (diffXP < 0) diffXP = 0;
|
||||
|
||||
// compute construct use of current level
|
||||
|
|
|
|||
|
|
@ -102,7 +102,6 @@ class LevelUpBannerState extends State<LevelUpBanner>
|
|||
widget.level,
|
||||
widget.prevLevel,
|
||||
);
|
||||
LevelUpManager.instance.printAnalytics();
|
||||
|
||||
_slideController = AnimationController(
|
||||
vsync: this,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import 'package:fluffychat/pangea/analytics_misc/construct_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/analytics_misc/level_up/level_up_banner.dart';
|
||||
import 'package:fluffychat/pangea/constructs/construct_repo.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
|
@ -27,8 +26,6 @@ class LevelUpManager {
|
|||
bool shouldAutoPopup = false;
|
||||
String? error;
|
||||
|
||||
bool _isShowingLevelUp = false;
|
||||
|
||||
int get vocabCount =>
|
||||
MatrixState.pangeaController.getAnalytics.constructListModel
|
||||
.unlockedLemmas(ConstructTypeEnum.vocab)
|
||||
|
|
@ -51,15 +48,46 @@ class LevelUpManager {
|
|||
.pangeaController.getAnalytics.constructListModel.vocabLemmas;
|
||||
|
||||
//for now idk how to get these
|
||||
prevGrammar = nextGrammar < 20 ? 0 : nextGrammar - 20;
|
||||
prevGrammar = nextGrammar < 30 ? 0 : nextGrammar - 30;
|
||||
|
||||
prevVocab = nextVocab < 20 ? 0 : nextVocab - 20;
|
||||
prevVocab = nextVocab < 30 ? 0 : nextVocab - 30;
|
||||
|
||||
userL2Code = MatrixState.pangeaController.languageController
|
||||
.activeL2Code()
|
||||
?.toUpperCase();
|
||||
|
||||
//fetch construct summary
|
||||
/*for testing, just fetch last level up
|
||||
constructSummary = MatrixState.pangeaController.getAnalytics
|
||||
.getConstructSummaryFromStateEvent();
|
||||
debugPrint(
|
||||
"Last saved construct summary: ${constructSummary?.toJson()}",
|
||||
);
|
||||
|
||||
final client = MatrixState.pangeaController.matrixState.client;
|
||||
|
||||
final Room? analyticsRoom = client.analyticsRoomLocal(
|
||||
MatrixState.pangeaController.languageController.userL2!,
|
||||
);
|
||||
|
||||
// Get all summary events in the timeline
|
||||
final timeline = await analyticsRoom!.getTimeline();
|
||||
final summaryEvents = timeline.events
|
||||
.where(
|
||||
(e) => e.type == PangeaEventTypes.constructSummary,
|
||||
)
|
||||
.map(
|
||||
(e) => ConstructSummary.fromJson(e.content),
|
||||
)
|
||||
.toList();
|
||||
debugPrint("List of previous summaries from timeline: $summaryEvents");
|
||||
|
||||
for (final summary in summaryEvents) {
|
||||
debugPrint("Individual summaries from timeline: ${summary.toJson()}");
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
// fetch construct summary for actual app, not while testing since level up isn't true
|
||||
try {
|
||||
constructSummary = await MatrixState.pangeaController.getAnalytics
|
||||
.generateLevelUpAnalytics(
|
||||
|
|
@ -69,6 +97,24 @@ class LevelUpManager {
|
|||
} catch (e) {
|
||||
error = e.toString();
|
||||
}
|
||||
// end of that block
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 1),
|
||||
() => LevelUpManager.instance.printAnalytics(),
|
||||
);
|
||||
}
|
||||
|
||||
void printAnalytics() {
|
||||
debugPrint('Level Up Analytics:');
|
||||
debugPrint('Current Level: $level');
|
||||
debugPrint('Previous Level: $prevLevel');
|
||||
debugPrint('Next Grammar: $nextGrammar');
|
||||
debugPrint('Next Vocab: $nextVocab');
|
||||
if (constructSummary != null) {
|
||||
debugPrint('Construct Summary: ${constructSummary!.toJson()}');
|
||||
} else {
|
||||
debugPrint('Construct Summary: Not available');
|
||||
}
|
||||
}
|
||||
|
||||
void markPopupSeen() {
|
||||
|
|
@ -76,40 +122,6 @@ class LevelUpManager {
|
|||
shouldAutoPopup = false;
|
||||
}
|
||||
|
||||
void printAnalytics() {
|
||||
print('Level Up Analytics:');
|
||||
print('Current Level: $level');
|
||||
print('Previous Level: $prevLevel');
|
||||
print('Next Grammar: $nextGrammar');
|
||||
print('Next Vocab: $nextVocab');
|
||||
print("should show popup: $shouldAutoPopup");
|
||||
print("has seen popup: $hasSeenPopup");
|
||||
if (constructSummary != null) {
|
||||
print('Construct Summary: ${constructSummary!.toJson()}');
|
||||
} else {
|
||||
print('Construct Summary: Not available');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> handleLevelUp(
|
||||
BuildContext context,
|
||||
int level,
|
||||
int prevLevel,
|
||||
) async {
|
||||
if (_isShowingLevelUp) return;
|
||||
_isShowingLevelUp = true;
|
||||
|
||||
await preloadAnalytics(context, level, prevLevel);
|
||||
|
||||
if (!context.mounted) {
|
||||
_isShowingLevelUp = false;
|
||||
return;
|
||||
}
|
||||
|
||||
await LevelUpUtil.showLevelUpDialog(level, prevLevel, context);
|
||||
_isShowingLevelUp = false;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
hasSeenPopup = false;
|
||||
shouldAutoPopup = false;
|
||||
|
|
@ -121,7 +133,6 @@ class LevelUpManager {
|
|||
nextVocab = 0;
|
||||
constructSummary = null;
|
||||
error = null;
|
||||
_isShowingLevelUp = false;
|
||||
// Reset any other state if necessary
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,7 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:desktop_notifications/desktop_notifications.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:matrix/encryption/utils/key_verification.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/config/setting_keys.dart';
|
||||
import 'package:fluffychat/pangea/common/constants/model_keys.dart';
|
||||
|
|
@ -129,6 +119,7 @@ abstract class ClientManager {
|
|||
PangeaEventTypes.userSetLemmaInfo,
|
||||
EventTypes.RoomJoinRules,
|
||||
PangeaEventTypes.activityPlan,
|
||||
PangeaEventTypes.constructSummary,
|
||||
// Pangea#
|
||||
},
|
||||
logLevel: kReleaseMode ? Level.warning : Level.verbose,
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ dependencies:
|
|||
text_to_speech:
|
||||
git: https://github.com/pangeachat/text_to_speech.git
|
||||
flutter_tts: ^4.2.0
|
||||
animated_flip_counter: ^0.3.4
|
||||
# Pangea#
|
||||
|
||||
dev_dependencies:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue