Clarify app version

This commit is contained in:
Hillel Coren 2020-04-10 15:12:34 +03:00
parent 70af7bdd80
commit 6d1c7d2996
5 changed files with 18 additions and 39 deletions

View File

@ -67,6 +67,11 @@ class StartSaving {}
class StopSaving {} class StopSaving {}
class ServerVersionUpdated {
ServerVersionUpdated({this.version});
final String version;
}
class LoadStaticSuccess implements PersistStatic { class LoadStaticSuccess implements PersistStatic {
LoadStaticSuccess({this.data}); LoadStaticSuccess({this.data});

View File

@ -40,7 +40,6 @@ AppState appReducer(AppState state, dynamic action) {
..isLoading = loadingReducer(state.isLoading, action) ..isLoading = loadingReducer(state.isLoading, action)
..isSaving = savingReducer(state.isSaving, action) ..isSaving = savingReducer(state.isSaving, action)
..lastError = lastErrorReducer(state.lastError, action) ..lastError = lastErrorReducer(state.lastError, action)
..serverVersion = serverVersionReducer(state.serverVersion, action)
..authState.replace(authReducer(state.authState, action)) ..authState.replace(authReducer(state.authState, action))
..staticState.replace(staticReducer(state.staticState, action)) ..staticState.replace(staticReducer(state.staticState, action))
..userCompanyStates[state.uiState.selectedCompanyIndex] = companyReducer( ..userCompanyStates[state.uiState.selectedCompanyIndex] = companyReducer(
@ -50,11 +49,6 @@ AppState appReducer(AppState state, dynamic action) {
state.prefState, action, state.uiState.selectedCompanyIndex))); state.prefState, action, state.uiState.selectedCompanyIndex)));
} }
final serverVersionReducer = combineReducers<String>([
// TODO re-enable this
//TypedReducer<String, LoadStaticSuccess>(_loadStaticSuccess),
]);
final lastErrorReducer = combineReducers<String>([ final lastErrorReducer = combineReducers<String>([
TypedReducer<String, ClearLastError>((state, action) { TypedReducer<String, ClearLastError>((state, action) {
return ''; return '';

View File

@ -66,7 +66,6 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
isLoading: false, isLoading: false,
isSaving: false, isSaving: false,
isTesting: false, isTesting: false,
serverVersion: '',
lastError: '', lastError: '',
authState: AuthState(), authState: AuthState(),
staticState: StaticState(), staticState: StaticState(),
@ -89,8 +88,6 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
String get lastError; String get lastError;
String get serverVersion;
AuthState get authState; AuthState get authState;
StaticState get staticState; StaticState get staticState;
@ -141,6 +138,9 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
String get accentColor => String get accentColor =>
user?.userCompany?.settings?.accentColor ?? kDefaultAccentColor; user?.userCompany?.settings?.accentColor ?? kDefaultAccentColor;
String get appVersion =>
'${account.currentVersion}-${kAppVersion.split('.').last}';
List<HistoryRecord> get historyList => List<HistoryRecord> get historyList =>
prefState.companyPrefs[uiState.selectedCompanyIndex].historyList prefState.companyPrefs[uiState.selectedCompanyIndex].historyList
.where((history) { .where((history) {
@ -477,7 +477,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
final int patch = int.parse(parts[2]); final int patch = int.parse(parts[2]);
try { try {
final serverParts = serverVersion.split('.'); final serverParts = account.currentVersion.split('.');
final int serverMajor = int.parse(serverParts[0]); final int serverMajor = int.parse(serverParts[0]);
final int serverMinor = int.parse(serverParts[1]); final int serverMinor = int.parse(serverParts[1]);
final int serverPatch = int.parse(serverParts[2]); final int serverPatch = int.parse(serverParts[2]);

View File

@ -30,9 +30,6 @@ class _$AppStateSerializer implements StructuredSerializer<AppState> {
'lastError', 'lastError',
serializers.serialize(object.lastError, serializers.serialize(object.lastError,
specifiedType: const FullType(String)), specifiedType: const FullType(String)),
'serverVersion',
serializers.serialize(object.serverVersion,
specifiedType: const FullType(String)),
'authState', 'authState',
serializers.serialize(object.authState, serializers.serialize(object.authState,
specifiedType: const FullType(AuthState)), specifiedType: const FullType(AuthState)),
@ -81,10 +78,6 @@ class _$AppStateSerializer implements StructuredSerializer<AppState> {
result.lastError = serializers.deserialize(value, result.lastError = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
break; break;
case 'serverVersion':
result.serverVersion = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'authState': case 'authState':
result.authState.replace(serializers.deserialize(value, result.authState.replace(serializers.deserialize(value,
specifiedType: const FullType(AuthState)) as AuthState); specifiedType: const FullType(AuthState)) as AuthState);
@ -124,8 +117,6 @@ class _$AppState extends AppState {
@override @override
final String lastError; final String lastError;
@override @override
final String serverVersion;
@override
final AuthState authState; final AuthState authState;
@override @override
final StaticState staticState; final StaticState staticState;
@ -144,7 +135,6 @@ class _$AppState extends AppState {
this.isSaving, this.isSaving,
this.isTesting, this.isTesting,
this.lastError, this.lastError,
this.serverVersion,
this.authState, this.authState,
this.staticState, this.staticState,
this.prefState, this.prefState,
@ -163,9 +153,6 @@ class _$AppState extends AppState {
if (lastError == null) { if (lastError == null) {
throw new BuiltValueNullFieldError('AppState', 'lastError'); throw new BuiltValueNullFieldError('AppState', 'lastError');
} }
if (serverVersion == null) {
throw new BuiltValueNullFieldError('AppState', 'serverVersion');
}
if (authState == null) { if (authState == null) {
throw new BuiltValueNullFieldError('AppState', 'authState'); throw new BuiltValueNullFieldError('AppState', 'authState');
} }
@ -198,7 +185,6 @@ class _$AppState extends AppState {
isSaving == other.isSaving && isSaving == other.isSaving &&
isTesting == other.isTesting && isTesting == other.isTesting &&
lastError == other.lastError && lastError == other.lastError &&
serverVersion == other.serverVersion &&
authState == other.authState && authState == other.authState &&
staticState == other.staticState && staticState == other.staticState &&
prefState == other.prefState && prefState == other.prefState &&
@ -215,12 +201,10 @@ class _$AppState extends AppState {
$jc( $jc(
$jc( $jc(
$jc( $jc(
$jc( $jc($jc(0, isLoading.hashCode),
$jc($jc(0, isLoading.hashCode), isSaving.hashCode),
isSaving.hashCode), isTesting.hashCode),
isTesting.hashCode), lastError.hashCode),
lastError.hashCode),
serverVersion.hashCode),
authState.hashCode), authState.hashCode),
staticState.hashCode), staticState.hashCode),
prefState.hashCode), prefState.hashCode),
@ -248,11 +232,6 @@ class AppStateBuilder implements Builder<AppState, AppStateBuilder> {
String get lastError => _$this._lastError; String get lastError => _$this._lastError;
set lastError(String lastError) => _$this._lastError = 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 _authState;
AuthStateBuilder get authState => AuthStateBuilder get authState =>
_$this._authState ??= new AuthStateBuilder(); _$this._authState ??= new AuthStateBuilder();
@ -287,7 +266,6 @@ class AppStateBuilder implements Builder<AppState, AppStateBuilder> {
_isSaving = _$v.isSaving; _isSaving = _$v.isSaving;
_isTesting = _$v.isTesting; _isTesting = _$v.isTesting;
_lastError = _$v.lastError; _lastError = _$v.lastError;
_serverVersion = _$v.serverVersion;
_authState = _$v.authState?.toBuilder(); _authState = _$v.authState?.toBuilder();
_staticState = _$v.staticState?.toBuilder(); _staticState = _$v.staticState?.toBuilder();
_prefState = _$v.prefState?.toBuilder(); _prefState = _$v.prefState?.toBuilder();
@ -321,7 +299,6 @@ class AppStateBuilder implements Builder<AppState, AppStateBuilder> {
isSaving: isSaving, isSaving: isSaving,
isTesting: isTesting, isTesting: isTesting,
lastError: lastError, lastError: lastError,
serverVersion: serverVersion,
authState: authState.build(), authState: authState.build(),
staticState: staticState.build(), staticState: staticState.build(),
prefState: prefState.build(), prefState: prefState.build(),

View File

@ -459,7 +459,8 @@ class SidebarFooter extends StatelessWidget {
if (state.prefState.isMenuCollapsed) ...[ if (state.prefState.isMenuCollapsed) ...[
Expanded(child: SizedBox()) Expanded(child: SizedBox())
] else ...[ ] else ...[
if (account.currentVersion != account.latestVersion) if (account.currentVersion != account.latestVersion &&
account.latestVersion != '0.0.0')
IconButton( IconButton(
icon: Icon( icon: Icon(
Icons.warning, Icons.warning,
@ -628,6 +629,8 @@ void _showUpdate(BuildContext context) {
void _showAbout(BuildContext context) async { void _showAbout(BuildContext context) async {
//final packageInfo = await PackageInfo.fromPlatform(); //final packageInfo = await PackageInfo.fromPlatform();
final Store<AppState> store = StoreProvider.of<AppState>(context);
final state = store.state;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final ThemeData themeData = Theme.of(context); final ThemeData themeData = Theme.of(context);
final TextStyle aboutTextStyle = themeData.textTheme.bodyText2; final TextStyle aboutTextStyle = themeData.textTheme.bodyText2;
@ -643,7 +646,7 @@ void _showAbout(BuildContext context) async {
height: 40.0, height: 40.0,
), ),
//applicationVersion: 'Version: ${packageInfo.version}', //applicationVersion: 'Version: ${packageInfo.version}',
applicationVersion: 'Version: $kAppVersion', applicationVersion: 'Version: ${state.appVersion}',
applicationLegalese: '© ${DateTime.now().year} Invoice Ninja', applicationLegalese: '© ${DateTime.now().year} Invoice Ninja',
children: <Widget>[ children: <Widget>[
Padding( Padding(