chore: fix for null check error in getFeedback (#2174)
This commit is contained in:
parent
af295b2817
commit
e3012f479f
2 changed files with 36 additions and 23 deletions
|
|
@ -60,7 +60,11 @@ class FullTextTranslationRepo {
|
|||
|
||||
// check cache first
|
||||
if (_cache.containsKey(cacheKey)) {
|
||||
return _cache[cacheKey]!;
|
||||
if (_cache[cacheKey] == null) {
|
||||
_cache.remove(cacheKey);
|
||||
} else {
|
||||
return _cache[cacheKey]!;
|
||||
}
|
||||
}
|
||||
|
||||
final Requests req = Requests(
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import 'package:http/http.dart';
|
|||
|
||||
import 'package:fluffychat/pangea/analytics_misc/text_loading_shimmer.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/repo/full_text_translation_repo.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import '../../../widgets/matrix.dart';
|
||||
import '../../bot/utils/bot_style.dart';
|
||||
import '../../common/controllers/pangea_controller.dart';
|
||||
|
|
@ -50,29 +51,37 @@ class ITFeedbackCardController extends State<ITFeedbackCard> {
|
|||
isLoadingFeedback = true;
|
||||
});
|
||||
|
||||
FullTextTranslationRepo.translate(
|
||||
accessToken: controller.userController.accessToken,
|
||||
request: FullTextTranslationRequestModel(
|
||||
text: widget.req.chosenContinuance,
|
||||
tgtLang: controller.languageController.userL1?.langCode ??
|
||||
widget.req.sourceTextLang,
|
||||
userL1: controller.languageController.userL1?.langCode ??
|
||||
widget.req.sourceTextLang,
|
||||
userL2: controller.languageController.userL2?.langCode ??
|
||||
widget.req.targetLang,
|
||||
),
|
||||
)
|
||||
.then((translationResponse) {
|
||||
res = ITFeedbackResponseModel(
|
||||
text: translationResponse.bestTranslation,
|
||||
);
|
||||
})
|
||||
.catchError((e) => error = e)
|
||||
.whenComplete(() {
|
||||
if (mounted) {
|
||||
setState(() => isLoadingFeedback = false);
|
||||
}
|
||||
try {
|
||||
final resp = await FullTextTranslationRepo.translate(
|
||||
accessToken: controller.userController.accessToken,
|
||||
request: FullTextTranslationRequestModel(
|
||||
text: widget.req.chosenContinuance,
|
||||
tgtLang: controller.languageController.userL1?.langCode ??
|
||||
widget.req.sourceTextLang,
|
||||
userL1: controller.languageController.userL1?.langCode ??
|
||||
widget.req.sourceTextLang,
|
||||
userL2: controller.languageController.userL2?.langCode ??
|
||||
widget.req.targetLang,
|
||||
),
|
||||
);
|
||||
res = ITFeedbackResponseModel(text: resp.bestTranslation);
|
||||
} catch (e, s) {
|
||||
error = e;
|
||||
ErrorHandler.logError(
|
||||
e: e,
|
||||
s: s,
|
||||
data: {
|
||||
"req": widget.req.toJson(),
|
||||
"choiceFeedback": widget.choiceFeedback,
|
||||
},
|
||||
);
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
isLoadingFeedback = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue