Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
fix: Contextless translation steup
Browse files Browse the repository at this point in the history
  • Loading branch information
reasje committed Jul 16, 2024
1 parent 1dba531 commit 3760d73
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 0 additions & 2 deletions lib/core/src/background_process/dapp_hooks_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class DAppHooksService {
if (isLoggedIn && MXCChains.isMXCChains(chainId) && wifiHooksEnabled) {
await AXSNotification()
.setupFlutterNotifications(shouldInitFirebase: false);
await contextLessTranslationUseCase.setupTranslator();

await dAppHooksUseCase.sendWifiInfo(
account!,
Expand Down Expand Up @@ -77,7 +76,6 @@ class DAppHooksService {
if (isLoggedIn && MXCChains.isMXCChains(chainId) && minerHooksEnabled) {
await AXSNotification()
.setupFlutterNotifications(shouldInitFirebase: false);
await contextLessTranslationUseCase.setupTranslator();

await dAppHooksUseCase.executeMinerAutoClaim(
account: account!,
Expand Down
1 change: 0 additions & 1 deletion lib/core/src/background_process/notifications_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class NotificationsService {
if (isLoggedIn && MXCChains.isMXCChains(chainId) && serviceEnabled) {
await AXSNotification()
.setupFlutterNotifications(shouldInitFirebase: false);
await contextLessTranslationUseCase.setupTranslator();

if (lowBalanceLimitEnabled) {
await backgroundFetchConfigUseCase.checkLowBalance(
Expand Down
14 changes: 10 additions & 4 deletions lib/features/common/app/contextless_translation_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@ import 'package:datadashwallet/features/settings/settings.dart';
class ContextLessTranslationUseCase extends ReactiveUseCase {
ContextLessTranslationUseCase(
this._languageUseCase,
);
) {
setupTranslator();
}

final LanguageUseCase _languageUseCase;

bool initialized = false;
static Map<String, dynamic>? _currentTranslations;

Future<void> setupTranslator() async {
final Locale currentLocale =
_languageUseCase.currentLocale.value?.toLocale() ?? window.locale;
await loadTranslations(currentLocale);
if (!initialized) {
final Locale currentLocale =
_languageUseCase.currentLocale.value?.toLocale() ?? window.locale;
await loadTranslations(currentLocale);
initialized = true;
}
}

Future<void> loadTranslations(Locale locale) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ class DAppHooksUseCase extends ReactiveUseCase {
required Account account,
required DateTime minerAutoClaimTime}) async {
try {

AXSNotification()
.showNotification(cTranslate('auto_claim_started'), null);

Expand Down

0 comments on commit 3760d73

Please sign in to comment.