diff --git a/lib/redux/app/app_actions.dart b/lib/redux/app/app_actions.dart index f034ce1fd..ecb95184b 100644 --- a/lib/redux/app/app_actions.dart +++ b/lib/redux/app/app_actions.dart @@ -67,6 +67,11 @@ class StartSaving {} class StopSaving {} +class ServerVersionUpdated { + ServerVersionUpdated({this.version}); + final String version; +} + class LoadStaticSuccess implements PersistStatic { LoadStaticSuccess({this.data}); diff --git a/lib/redux/app/app_reducer.dart b/lib/redux/app/app_reducer.dart index 7959fb853..85db69008 100644 --- a/lib/redux/app/app_reducer.dart +++ b/lib/redux/app/app_reducer.dart @@ -40,7 +40,6 @@ AppState appReducer(AppState state, dynamic action) { ..isLoading = loadingReducer(state.isLoading, action) ..isSaving = savingReducer(state.isSaving, action) ..lastError = lastErrorReducer(state.lastError, action) - ..serverVersion = serverVersionReducer(state.serverVersion, action) ..authState.replace(authReducer(state.authState, action)) ..staticState.replace(staticReducer(state.staticState, action)) ..userCompanyStates[state.uiState.selectedCompanyIndex] = companyReducer( @@ -50,11 +49,6 @@ AppState appReducer(AppState state, dynamic action) { state.prefState, action, state.uiState.selectedCompanyIndex))); } -final serverVersionReducer = combineReducers([ - // TODO re-enable this - //TypedReducer(_loadStaticSuccess), -]); - final lastErrorReducer = combineReducers([ TypedReducer((state, action) { return ''; diff --git a/lib/redux/app/app_state.dart b/lib/redux/app/app_state.dart index e106cf3a1..5fba505d5 100644 --- a/lib/redux/app/app_state.dart +++ b/lib/redux/app/app_state.dart @@ -66,7 +66,6 @@ abstract class AppState implements Built { isLoading: false, isSaving: false, isTesting: false, - serverVersion: '', lastError: '', authState: AuthState(), staticState: StaticState(), @@ -89,8 +88,6 @@ abstract class AppState implements Built { String get lastError; - String get serverVersion; - AuthState get authState; StaticState get staticState; @@ -141,6 +138,9 @@ abstract class AppState implements Built { String get accentColor => user?.userCompany?.settings?.accentColor ?? kDefaultAccentColor; + String get appVersion => + '${account.currentVersion}-${kAppVersion.split('.').last}'; + List get historyList => prefState.companyPrefs[uiState.selectedCompanyIndex].historyList .where((history) { @@ -477,7 +477,7 @@ abstract class AppState implements Built { final int patch = int.parse(parts[2]); try { - final serverParts = serverVersion.split('.'); + final serverParts = account.currentVersion.split('.'); final int serverMajor = int.parse(serverParts[0]); final int serverMinor = int.parse(serverParts[1]); final int serverPatch = int.parse(serverParts[2]); diff --git a/lib/redux/app/app_state.g.dart b/lib/redux/app/app_state.g.dart index faa5abffa..aca5a3aba 100644 --- a/lib/redux/app/app_state.g.dart +++ b/lib/redux/app/app_state.g.dart @@ -30,9 +30,6 @@ class _$AppStateSerializer implements StructuredSerializer { 'lastError', serializers.serialize(object.lastError, specifiedType: const FullType(String)), - 'serverVersion', - serializers.serialize(object.serverVersion, - specifiedType: const FullType(String)), 'authState', serializers.serialize(object.authState, specifiedType: const FullType(AuthState)), @@ -81,10 +78,6 @@ class _$AppStateSerializer implements StructuredSerializer { result.lastError = serializers.deserialize(value, specifiedType: const FullType(String)) as String; break; - case 'serverVersion': - result.serverVersion = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - break; case 'authState': result.authState.replace(serializers.deserialize(value, specifiedType: const FullType(AuthState)) as AuthState); @@ -124,8 +117,6 @@ class _$AppState extends AppState { @override final String lastError; @override - final String serverVersion; - @override final AuthState authState; @override final StaticState staticState; @@ -144,7 +135,6 @@ class _$AppState extends AppState { this.isSaving, this.isTesting, this.lastError, - this.serverVersion, this.authState, this.staticState, this.prefState, @@ -163,9 +153,6 @@ class _$AppState extends AppState { if (lastError == null) { throw new BuiltValueNullFieldError('AppState', 'lastError'); } - if (serverVersion == null) { - throw new BuiltValueNullFieldError('AppState', 'serverVersion'); - } if (authState == null) { throw new BuiltValueNullFieldError('AppState', 'authState'); } @@ -198,7 +185,6 @@ class _$AppState extends AppState { isSaving == other.isSaving && isTesting == other.isTesting && lastError == other.lastError && - serverVersion == other.serverVersion && authState == other.authState && staticState == other.staticState && prefState == other.prefState && @@ -215,12 +201,10 @@ class _$AppState extends AppState { $jc( $jc( $jc( - $jc( - $jc($jc(0, isLoading.hashCode), - isSaving.hashCode), - isTesting.hashCode), - lastError.hashCode), - serverVersion.hashCode), + $jc($jc(0, isLoading.hashCode), + isSaving.hashCode), + isTesting.hashCode), + lastError.hashCode), authState.hashCode), staticState.hashCode), prefState.hashCode), @@ -248,11 +232,6 @@ class AppStateBuilder implements Builder { String get lastError => _$this._lastError; set lastError(String lastError) => _$this._lastError = lastError; - String _serverVersion; - String get serverVersion => _$this._serverVersion; - set serverVersion(String serverVersion) => - _$this._serverVersion = serverVersion; - AuthStateBuilder _authState; AuthStateBuilder get authState => _$this._authState ??= new AuthStateBuilder(); @@ -287,7 +266,6 @@ class AppStateBuilder implements Builder { _isSaving = _$v.isSaving; _isTesting = _$v.isTesting; _lastError = _$v.lastError; - _serverVersion = _$v.serverVersion; _authState = _$v.authState?.toBuilder(); _staticState = _$v.staticState?.toBuilder(); _prefState = _$v.prefState?.toBuilder(); @@ -321,7 +299,6 @@ class AppStateBuilder implements Builder { isSaving: isSaving, isTesting: isTesting, lastError: lastError, - serverVersion: serverVersion, authState: authState.build(), staticState: staticState.build(), prefState: prefState.build(), diff --git a/lib/ui/app/menu_drawer.dart b/lib/ui/app/menu_drawer.dart index b728225bd..7a4c6bb93 100644 --- a/lib/ui/app/menu_drawer.dart +++ b/lib/ui/app/menu_drawer.dart @@ -459,7 +459,8 @@ class SidebarFooter extends StatelessWidget { if (state.prefState.isMenuCollapsed) ...[ Expanded(child: SizedBox()) ] else ...[ - if (account.currentVersion != account.latestVersion) + if (account.currentVersion != account.latestVersion && + account.latestVersion != '0.0.0') IconButton( icon: Icon( Icons.warning, @@ -628,6 +629,8 @@ void _showUpdate(BuildContext context) { void _showAbout(BuildContext context) async { //final packageInfo = await PackageInfo.fromPlatform(); + final Store store = StoreProvider.of(context); + final state = store.state; final localization = AppLocalization.of(context); final ThemeData themeData = Theme.of(context); final TextStyle aboutTextStyle = themeData.textTheme.bodyText2; @@ -643,7 +646,7 @@ void _showAbout(BuildContext context) async { height: 40.0, ), //applicationVersion: 'Version: ${packageInfo.version}', - applicationVersion: 'Version: $kAppVersion', + applicationVersion: 'Version: ${state.appVersion}', applicationLegalese: '© ${DateTime.now().year} Invoice Ninja', children: [ Padding(