fix: only show space analytics download button on web (#1492)

* fix: only show space analytics download button on web

* fix: don't close keyboard right after opening lemma meaning text field

* fix: make proportion the number of relevant tokens with completed activities over the number of relevant tokens
This commit is contained in:
ggurdin 2025-01-17 11:00:09 -05:00 committed by GitHub
parent d42c511bbb
commit 5383a62502
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 27 additions and 42 deletions

View file

@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:adaptive_dialog/adaptive_dialog.dart';
@ -337,7 +338,7 @@ class PangeaChatDetailsView extends StatelessWidget {
room: room,
controller: controller,
),
if (room.isSpace && room.isRoomAdmin)
if (room.isSpace && room.isRoomAdmin && kIsWeb)
DownloadAnalyticsButton(space: room),
Divider(color: theme.dividerColor, height: 1),
if (isGroupChat)

View file

@ -569,37 +569,22 @@ class PangeaMessageEvent {
}
final eligibleTokens = messageDisplayRepresentation!.tokens!.where(
(token) => token.shouldDoActivity(
(token) => token.isActivityBasicallyEligible(
ActivityTypeEnum.wordMeaning,
),
);
if (eligibleTokens.isEmpty) return 1;
final alreadyDid = eligibleTokens.where(
(token) => !token.shouldDoActivity(
a: ActivityTypeEnum.wordMeaning,
feature: null,
tag: null,
),
);
final int total = eligibleTokens.length;
if (total == 0) return 1;
final didActivity = eligibleTokens.where(
(token) => token.didActivitySuccessfully(ActivityTypeEnum.wordMeaning),
);
final double proportion = 1 - ((total - didActivity.length) / total);
if (proportion < 0) {
debugger(when: kDebugMode);
ErrorHandler.logError(
m: "proportion of activities completed is less than 0",
data: {
"proportion": proportion,
"total": total,
"toDo": didActivity,
"tokens": messageDisplayRepresentation!.tokens,
},
);
return 0;
}
return proportion;
return alreadyDid.length / eligibleTokens.length;
}
String? get l2Code =>

View file

@ -211,7 +211,7 @@ class PangeaToken {
);
}
bool _isActivityBasicallyEligible(
bool isActivityBasicallyEligible(
ActivityTypeEnum a, [
String? morphFeature,
String? morphTag,
@ -421,7 +421,7 @@ class PangeaToken {
required String? feature,
required String? tag,
}) {
return _isActivityBasicallyEligible(a, feature, tag) &&
return isActivityBasicallyEligible(a, feature, tag) &&
_isActivityProbablyLevelAppropriate(a, feature, tag);
}

View file

@ -75,20 +75,8 @@ class LemmaMeaningWidgetState extends State<LemmaMeaningWidget> {
return FutureBuilder<LemmaInfoResponse>(
future: _lemmaMeaning(),
builder: (context, snapshot) {
if (snapshot.connectionState != ConnectionState.done) {
return const TextLoadingShimmer();
}
if (snapshot.hasError || snapshot.data == null) {
debugger(when: kDebugMode);
return Text(
snapshot.error.toString(),
textAlign: TextAlign.center,
);
}
if (_editMode) {
_controller.text = snapshot.data!.meaning;
_controller.text = snapshot.data?.meaning ?? "";
return Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
@ -105,7 +93,6 @@ class LemmaMeaningWidgetState extends State<LemmaMeaningWidget> {
minLines: 1,
maxLines: 3,
controller: _controller,
onSubmitted: editLemmaMeaning,
decoration: InputDecoration(
hintText: snapshot.data!.meaning,
),
@ -147,6 +134,18 @@ class LemmaMeaningWidgetState extends State<LemmaMeaningWidget> {
);
}
if (snapshot.connectionState != ConnectionState.done) {
return const TextLoadingShimmer();
}
if (snapshot.hasError || snapshot.data == null) {
debugger(when: kDebugMode);
return Text(
snapshot.error.toString(),
textAlign: TextAlign.center,
);
}
return Flexible(
child: GestureDetector(
onLongPress: () => _toggleEditMode(true),