Correct changing languages
This commit is contained in:
parent
5f87c90f84
commit
8c6dba446f
|
|
@ -100,16 +100,16 @@ class AuthRepository {
|
|||
}
|
||||
|
||||
Future<LoginResponse> refresh(
|
||||
{String url, String token, int updatedAt}) async {
|
||||
{@required String url,
|
||||
@required String token,
|
||||
@required int updatedAt,
|
||||
@required bool includeStatic}) async {
|
||||
url = formatApiUrl(url) + '/refresh';
|
||||
|
||||
bool includeStatic = false;
|
||||
if (updatedAt > 0) {
|
||||
|
||||
// TODO re-enable this
|
||||
//url += '?updated_at=$updatedAt';
|
||||
|
||||
includeStatic =
|
||||
includeStatic = includeStatic ||
|
||||
DateTime.now().millisecondsSinceEpoch - (updatedAt * 1000) >
|
||||
kMillisecondsToRefreshStaticData;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -136,10 +136,12 @@ class RefreshData implements StartLoading {
|
|||
RefreshData({
|
||||
this.completer,
|
||||
this.clearData = false,
|
||||
this.includeStatic = false,
|
||||
});
|
||||
|
||||
final Completer completer;
|
||||
final bool clearData;
|
||||
final bool includeStatic;
|
||||
}
|
||||
|
||||
class ClearData {}
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ Middleware<AppState> _createRefreshRequest(AuthRepository repository) {
|
|||
url: url,
|
||||
token: token,
|
||||
updatedAt: updatedAt - kUpdatedAtBufferSeconds,
|
||||
includeStatic: action.includeStatic,
|
||||
)
|
||||
.then((data) {
|
||||
if (action.clearData) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
|
|
@ -6,10 +8,12 @@ import 'package:invoiceninja_flutter/data/models/client_model.dart';
|
|||
import 'package:invoiceninja_flutter/data/models/company_model.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/group_model.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/client/client_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/company/company_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/group/group_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/app_builder.dart';
|
||||
import 'package:invoiceninja_flutter/ui/settings/localization_settings.dart';
|
||||
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
|
|
@ -61,7 +65,14 @@ class LocalizationSettingsVM {
|
|||
switch (settingsUIState.entityType) {
|
||||
case EntityType.company:
|
||||
final completer = snackBarCompleter<Null>(
|
||||
context, AppLocalization.of(context).savedSettings);
|
||||
context, AppLocalization.of(context).savedSettings)
|
||||
..future.then<dynamic>((value) {
|
||||
store.dispatch(RefreshData(
|
||||
includeStatic: true,
|
||||
completer: Completer<dynamic>()
|
||||
..future.then((dynamic value) =>
|
||||
AppBuilder.of(context).rebuild())));
|
||||
});
|
||||
store.dispatch(SaveCompanyRequest(
|
||||
completer: completer, company: settingsUIState.company));
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue