|
|
|
@ -4,6 +4,7 @@ import 'dart:developer';
|
|
|
|
import 'package:fluffychat/pangea/constants/pangea_room_types.dart';
|
|
|
|
import 'package:fluffychat/pangea/constants/pangea_room_types.dart';
|
|
|
|
import 'package:fluffychat/pangea/enum/bar_chart_view_enum.dart';
|
|
|
|
import 'package:fluffychat/pangea/enum/bar_chart_view_enum.dart';
|
|
|
|
import 'package:fluffychat/pangea/extensions/pangea_room_extension/pangea_room_extension.dart';
|
|
|
|
import 'package:fluffychat/pangea/extensions/pangea_room_extension/pangea_room_extension.dart';
|
|
|
|
|
|
|
|
import 'package:fluffychat/pangea/models/language_model.dart';
|
|
|
|
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
|
|
|
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
|
|
|
import 'package:fluffychat/pangea/widgets/common/list_placeholder.dart';
|
|
|
|
import 'package:fluffychat/pangea/widgets/common/list_placeholder.dart';
|
|
|
|
import 'package:fluffychat/pangea/widgets/common/p_circular_loader.dart';
|
|
|
|
import 'package:fluffychat/pangea/widgets/common/p_circular_loader.dart';
|
|
|
|
@ -33,6 +34,18 @@ class SpaceAnalyticsV2Controller extends State<SpaceAnalyticsPage> {
|
|
|
|
List<User> students = [];
|
|
|
|
List<User> students = [];
|
|
|
|
String? get spaceId => GoRouterState.of(context).pathParameters['spaceid'];
|
|
|
|
String? get spaceId => GoRouterState.of(context).pathParameters['spaceid'];
|
|
|
|
Room? _spaceRoom;
|
|
|
|
Room? _spaceRoom;
|
|
|
|
|
|
|
|
List<LanguageModel> targetLanguages = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
Future.delayed(Duration.zero, () async {
|
|
|
|
|
|
|
|
if (spaceRoom == null || (!(spaceRoom?.isSpace ?? false))) {
|
|
|
|
|
|
|
|
context.go('/rooms');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
getChatAndStudents();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Room? get spaceRoom {
|
|
|
|
Room? get spaceRoom {
|
|
|
|
if (_spaceRoom == null || _spaceRoom!.id != spaceId) {
|
|
|
|
if (_spaceRoom == null || _spaceRoom!.id != spaceId) {
|
|
|
|
@ -44,23 +57,11 @@ class SpaceAnalyticsV2Controller extends State<SpaceAnalyticsPage> {
|
|
|
|
context.go('/rooms/analytics');
|
|
|
|
context.go('/rooms/analytics');
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getChatAndStudents();
|
|
|
|
getChatAndStudents().then((_) => setTargetLanguages());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return _spaceRoom;
|
|
|
|
return _spaceRoom;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
debugPrint("init space analytics");
|
|
|
|
|
|
|
|
Future.delayed(Duration.zero, () async {
|
|
|
|
|
|
|
|
if (spaceRoom == null || (!(spaceRoom?.isSpace ?? false))) {
|
|
|
|
|
|
|
|
context.go('/rooms');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
getChatAndStudents();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> getChatAndStudents() async {
|
|
|
|
Future<void> getChatAndStudents() async {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
await spaceRoom?.postLoad();
|
|
|
|
await spaceRoom?.postLoad();
|
|
|
|
@ -97,12 +98,12 @@ class SpaceAnalyticsV2Controller extends State<SpaceAnalyticsPage> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @override
|
|
|
|
Future<void> setTargetLanguages() async {
|
|
|
|
// void dispose() {
|
|
|
|
// get a list of language models, sorted by the
|
|
|
|
// super.dispose();
|
|
|
|
// number of students who are learning that language
|
|
|
|
// refreshTimer?.cancel();
|
|
|
|
targetLanguages = await spaceRoom?.targetLanguages() ?? [];
|
|
|
|
// stateSub?.cancel();
|
|
|
|
setState(() {});
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|