get device position and staging config fixed

This commit is contained in:
2026-03-09 11:45:04 +01:00
parent 644d1c2abe
commit fd8574e631
15 changed files with 90 additions and 97 deletions

View File

@@ -1,5 +1,5 @@
{
"env": "staging",
"apiBaseUrl": "https://api-platform.pre.savefamilygps.net/gateway/api/",
"apiOrigin": "https://platform.pre.savefamilygps.net/"
}
"apiOrigin": "https://platform.pre.savefamilygps.net"
}

View File

@@ -34,7 +34,7 @@ class ControlPanelRemoteDatasourceImpl implements ControlPanelRemoteDatasource {
}) async {
try {
final response = await _repository.get<Map<String, dynamic>>(
'/positions/identificator/$deviceId/positions',
'/devices/identificator/$deviceId/positions',
);
final data = response.data;

View File

@@ -26,7 +26,7 @@ abstract class LatestPositionsItemResponseModel
required double longitude,
required int hpe,
int? ncell,
required int type,
required String type,
int? steps,
LatestPositionsAddressResponseModel? address,
required int createdAt,

View File

@@ -284,7 +284,7 @@ as List<LatestPositionsItemResponseModel>,
/// @nodoc
mixin _$LatestPositionsItemResponseModel {
String get id; String get deviceIdentificator; double get latitude; double get longitude; int get hpe; int? get ncell; int get type; int? get steps; LatestPositionsAddressResponseModel? get address; int get createdAt; int get positionDate; int? get positionDateOriginal; String? get frequentPlaceName; String get message; List<LatestPositionsNetworkResponseModel> get networks; bool get ignore; bool get suspect; bool get frequentPlace;
String get id; String get deviceIdentificator; double get latitude; double get longitude; int get hpe; int? get ncell; String get type; int? get steps; LatestPositionsAddressResponseModel? get address; int get createdAt; int get positionDate; int? get positionDateOriginal; String? get frequentPlaceName; String get message; List<LatestPositionsNetworkResponseModel> get networks; bool get ignore; bool get suspect; bool get frequentPlace;
/// Create a copy of LatestPositionsItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -317,7 +317,7 @@ abstract mixin class $LatestPositionsItemResponseModelCopyWith<$Res> {
factory $LatestPositionsItemResponseModelCopyWith(LatestPositionsItemResponseModel value, $Res Function(LatestPositionsItemResponseModel) _then) = _$LatestPositionsItemResponseModelCopyWithImpl;
@useResult
$Res call({
String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<LatestPositionsNetworkResponseModel> networks, bool ignore, bool suspect, bool frequentPlace
String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<LatestPositionsNetworkResponseModel> networks, bool ignore, bool suspect, bool frequentPlace
});
@@ -343,7 +343,7 @@ as double,longitude: null == longitude ? _self.longitude : longitude // ignore:
as double,hpe: null == hpe ? _self.hpe : hpe // ignore: cast_nullable_to_non_nullable
as int,ncell: freezed == ncell ? _self.ncell : ncell // ignore: cast_nullable_to_non_nullable
as int?,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as int,steps: freezed == steps ? _self.steps : steps // ignore: cast_nullable_to_non_nullable
as String,steps: freezed == steps ? _self.steps : steps // ignore: cast_nullable_to_non_nullable
as int?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
as LatestPositionsAddressResponseModel?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int,positionDate: null == positionDate ? _self.positionDate : positionDate // ignore: cast_nullable_to_non_nullable
@@ -451,7 +451,7 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<LatestPositionsNetworkResponseModel> networks, bool ignore, bool suspect, bool frequentPlace)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<LatestPositionsNetworkResponseModel> networks, bool ignore, bool suspect, bool frequentPlace)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _LatestPositionsItemResponseModel() when $default != null:
return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitude,_that.hpe,_that.ncell,_that.type,_that.steps,_that.address,_that.createdAt,_that.positionDate,_that.positionDateOriginal,_that.frequentPlaceName,_that.message,_that.networks,_that.ignore,_that.suspect,_that.frequentPlace);case _:
@@ -472,7 +472,7 @@ return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitud
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<LatestPositionsNetworkResponseModel> networks, bool ignore, bool suspect, bool frequentPlace) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<LatestPositionsNetworkResponseModel> networks, bool ignore, bool suspect, bool frequentPlace) $default,) {final _that = this;
switch (_that) {
case _LatestPositionsItemResponseModel():
return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitude,_that.hpe,_that.ncell,_that.type,_that.steps,_that.address,_that.createdAt,_that.positionDate,_that.positionDateOriginal,_that.frequentPlaceName,_that.message,_that.networks,_that.ignore,_that.suspect,_that.frequentPlace);case _:
@@ -492,7 +492,7 @@ return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitud
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<LatestPositionsNetworkResponseModel> networks, bool ignore, bool suspect, bool frequentPlace)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<LatestPositionsNetworkResponseModel> networks, bool ignore, bool suspect, bool frequentPlace)? $default,) {final _that = this;
switch (_that) {
case _LatestPositionsItemResponseModel() when $default != null:
return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitude,_that.hpe,_that.ncell,_that.type,_that.steps,_that.address,_that.createdAt,_that.positionDate,_that.positionDateOriginal,_that.frequentPlaceName,_that.message,_that.networks,_that.ignore,_that.suspect,_that.frequentPlace);case _:
@@ -516,7 +516,7 @@ class _LatestPositionsItemResponseModel implements LatestPositionsItemResponseMo
@override final double longitude;
@override final int hpe;
@override final int? ncell;
@override final int type;
@override final String type;
@override final int? steps;
@override final LatestPositionsAddressResponseModel? address;
@override final int createdAt;
@@ -568,7 +568,7 @@ abstract mixin class _$LatestPositionsItemResponseModelCopyWith<$Res> implements
factory _$LatestPositionsItemResponseModelCopyWith(_LatestPositionsItemResponseModel value, $Res Function(_LatestPositionsItemResponseModel) _then) = __$LatestPositionsItemResponseModelCopyWithImpl;
@override @useResult
$Res call({
String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<LatestPositionsNetworkResponseModel> networks, bool ignore, bool suspect, bool frequentPlace
String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, LatestPositionsAddressResponseModel? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<LatestPositionsNetworkResponseModel> networks, bool ignore, bool suspect, bool frequentPlace
});
@@ -594,7 +594,7 @@ as double,longitude: null == longitude ? _self.longitude : longitude // ignore:
as double,hpe: null == hpe ? _self.hpe : hpe // ignore: cast_nullable_to_non_nullable
as int,ncell: freezed == ncell ? _self.ncell : ncell // ignore: cast_nullable_to_non_nullable
as int?,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as int,steps: freezed == steps ? _self.steps : steps // ignore: cast_nullable_to_non_nullable
as String,steps: freezed == steps ? _self.steps : steps // ignore: cast_nullable_to_non_nullable
as int?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
as LatestPositionsAddressResponseModel?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int,positionDate: null == positionDate ? _self.positionDate : positionDate // ignore: cast_nullable_to_non_nullable

View File

@@ -31,7 +31,7 @@ _LatestPositionsItemResponseModel _$LatestPositionsItemResponseModelFromJson(
longitude: (json['longitude'] as num).toDouble(),
hpe: (json['hpe'] as num).toInt(),
ncell: (json['ncell'] as num?)?.toInt(),
type: (json['type'] as num).toInt(),
type: json['type'] as String,
steps: (json['steps'] as num?)?.toInt(),
address: json['address'] == null
? null

View File

@@ -13,7 +13,7 @@ abstract class PositionEntity with _$PositionEntity {
required double longitude,
required int hpe,
int? ncell,
required int type,
required String type,
int? steps,
AddressEntity? address,
required int createdAt,

View File

@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$PositionEntity {
String get id; String get deviceIdentificator; double get latitude; double get longitude; int get hpe; int? get ncell; int get type; int? get steps; AddressEntity? get address; int get createdAt; int get positionDate; int? get positionDateOriginal; String? get frequentPlaceName; String get message; List<NetworkEntity> get networks; bool get ignore; bool get suspect; bool get frequentPlace;
String get id; String get deviceIdentificator; double get latitude; double get longitude; int get hpe; int? get ncell; String get type; int? get steps; AddressEntity? get address; int get createdAt; int get positionDate; int? get positionDateOriginal; String? get frequentPlaceName; String get message; List<NetworkEntity> get networks; bool get ignore; bool get suspect; bool get frequentPlace;
/// Create a copy of PositionEntity
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -45,7 +45,7 @@ abstract mixin class $PositionEntityCopyWith<$Res> {
factory $PositionEntityCopyWith(PositionEntity value, $Res Function(PositionEntity) _then) = _$PositionEntityCopyWithImpl;
@useResult
$Res call({
String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<NetworkEntity> networks, bool ignore, bool suspect, bool frequentPlace
String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<NetworkEntity> networks, bool ignore, bool suspect, bool frequentPlace
});
@@ -71,7 +71,7 @@ as double,longitude: null == longitude ? _self.longitude : longitude // ignore:
as double,hpe: null == hpe ? _self.hpe : hpe // ignore: cast_nullable_to_non_nullable
as int,ncell: freezed == ncell ? _self.ncell : ncell // ignore: cast_nullable_to_non_nullable
as int?,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as int,steps: freezed == steps ? _self.steps : steps // ignore: cast_nullable_to_non_nullable
as String,steps: freezed == steps ? _self.steps : steps // ignore: cast_nullable_to_non_nullable
as int?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
as AddressEntity?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int,positionDate: null == positionDate ? _self.positionDate : positionDate // ignore: cast_nullable_to_non_nullable
@@ -179,7 +179,7 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<NetworkEntity> networks, bool ignore, bool suspect, bool frequentPlace)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<NetworkEntity> networks, bool ignore, bool suspect, bool frequentPlace)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _PositionEntity() when $default != null:
return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitude,_that.hpe,_that.ncell,_that.type,_that.steps,_that.address,_that.createdAt,_that.positionDate,_that.positionDateOriginal,_that.frequentPlaceName,_that.message,_that.networks,_that.ignore,_that.suspect,_that.frequentPlace);case _:
@@ -200,7 +200,7 @@ return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitud
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<NetworkEntity> networks, bool ignore, bool suspect, bool frequentPlace) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<NetworkEntity> networks, bool ignore, bool suspect, bool frequentPlace) $default,) {final _that = this;
switch (_that) {
case _PositionEntity():
return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitude,_that.hpe,_that.ncell,_that.type,_that.steps,_that.address,_that.createdAt,_that.positionDate,_that.positionDateOriginal,_that.frequentPlaceName,_that.message,_that.networks,_that.ignore,_that.suspect,_that.frequentPlace);case _:
@@ -220,7 +220,7 @@ return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitud
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<NetworkEntity> networks, bool ignore, bool suspect, bool frequentPlace)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<NetworkEntity> networks, bool ignore, bool suspect, bool frequentPlace)? $default,) {final _that = this;
switch (_that) {
case _PositionEntity() when $default != null:
return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitude,_that.hpe,_that.ncell,_that.type,_that.steps,_that.address,_that.createdAt,_that.positionDate,_that.positionDateOriginal,_that.frequentPlaceName,_that.message,_that.networks,_that.ignore,_that.suspect,_that.frequentPlace);case _:
@@ -244,7 +244,7 @@ class _PositionEntity implements PositionEntity {
@override final double longitude;
@override final int hpe;
@override final int? ncell;
@override final int type;
@override final String type;
@override final int? steps;
@override final AddressEntity? address;
@override final int createdAt;
@@ -293,7 +293,7 @@ abstract mixin class _$PositionEntityCopyWith<$Res> implements $PositionEntityCo
factory _$PositionEntityCopyWith(_PositionEntity value, $Res Function(_PositionEntity) _then) = __$PositionEntityCopyWithImpl;
@override @useResult
$Res call({
String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, int type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<NetworkEntity> networks, bool ignore, bool suspect, bool frequentPlace
String id, String deviceIdentificator, double latitude, double longitude, int hpe, int? ncell, String type, int? steps, AddressEntity? address, int createdAt, int positionDate, int? positionDateOriginal, String? frequentPlaceName, String message, List<NetworkEntity> networks, bool ignore, bool suspect, bool frequentPlace
});
@@ -319,7 +319,7 @@ as double,longitude: null == longitude ? _self.longitude : longitude // ignore:
as double,hpe: null == hpe ? _self.hpe : hpe // ignore: cast_nullable_to_non_nullable
as int,ncell: freezed == ncell ? _self.ncell : ncell // ignore: cast_nullable_to_non_nullable
as int?,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as int,steps: freezed == steps ? _self.steps : steps // ignore: cast_nullable_to_non_nullable
as String,steps: freezed == steps ? _self.steps : steps // ignore: cast_nullable_to_non_nullable
as int?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
as AddressEntity?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int,positionDate: null == positionDate ? _self.positionDate : positionDate // ignore: cast_nullable_to_non_nullable

View File

@@ -228,17 +228,30 @@ class _MapSection extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.read(themePortProvider);
final state = ref.watch(controlPanelViewModelProvider);
final vm = ref.read(controlPanelViewModelProvider.notifier);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
context.translate(I18n.watchesOnMap),
style: TextStyle(
fontSize: SizeUtils.getByScreen(small: 20, big: 19),
fontWeight: FontWeight.bold,
color: theme.getColorFor(ThemeCode.legacyPrimary),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
context.translate(I18n.watchesOnMap),
style: TextStyle(
fontSize: SizeUtils.getByScreen(small: 20, big: 19),
fontWeight: FontWeight.bold,
color: theme.getColorFor(ThemeCode.legacyPrimary),
),
),
IconButton(
onPressed: vm.refreshPositions,
icon: Icon(
Icons.refresh,
color: theme.getColorFor(ThemeCode.legacyPrimary),
),
),
],
),
SizedBox(height: SizeUtils.getByScreen(small: 4, big: 8)),
SizedBox(

View File

@@ -63,7 +63,10 @@ class ControlPanelViewModel extends Notifier<ControlPanelViewState> {
void _applyPositions(List<List<PositionEntity>> positionLists) {
final latestPositions = positionLists
.where((list) => list.isNotEmpty)
.map((list) => list.first)
.map((list) {
final valid = list.where((p) => p.latitude != 0 || p.longitude != 0);
return valid.isNotEmpty ? valid.last : list.last;
})
.toList();
final selectedPosition = state.selectedDevice != null
@@ -82,6 +85,22 @@ class ControlPanelViewModel extends Notifier<ControlPanelViewState> {
);
}
Future<void> refreshPositions() async {
if (state.devices.isEmpty) return;
try {
final positionLists = await Future.wait(
state.devices.map(
(d) => _repository.getLatestPositions(deviceId: d.identificator),
),
);
if (!ref.mounted) return;
_applyPositions(positionLists);
} catch (e) {
if (!ref.mounted) return;
state = state.copyWith(errorMessage: formatErrorMessage(e));
}
}
void setSelectedDevice(DeviceEntity device) {
final selectedPosition = state.positions
.where((p) => p.deviceIdentificator == device.identificator)

View File

@@ -92,7 +92,7 @@ class _DeviceMapState extends ConsumerState<DeviceMap> {
child: Align(
alignment: Alignment.topCenter,
child: SvgPicture.asset(
'assets/images/ui/location.svg',
'assets/shared/images/location.svg',
height: 80,
),
),

View File

@@ -28,21 +28,6 @@ class LegacyOnboardingScreen extends ConsumerWidget {
final viewModel = ref.read(legacyOnBoardingViewModelProvider.notifier);
final pageController = ref.watch(legacyOnboardingPageControllerProvider);
ref.listen(
legacyOnBoardingViewModelProvider.select((s) => s.isSessionValid),
(previous, isValid) {
if (isValid) {
navigationContract.goTo(AppRoutes.controlPanel);
}
},
);
if (state.isCheckingSession) {
return const Scaffold(
body: Center(child: CircularProgressIndicator()),
);
}
final isLast = state.cardIndex >= onboardingPages.length - 1;
void goToNext() {

View File

@@ -1,6 +1,5 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:legacy_auth/src/features/onboarding/presentation/onboarding_view_state.dart';
import 'package:sf_shared/sf_shared.dart';
final legacyOnBoardingViewModelProvider =
NotifierProvider.autoDispose<LegacyOnBoardingViewModel, LegacyOnboardingViewState>(
@@ -10,21 +9,9 @@ final legacyOnBoardingViewModelProvider =
class LegacyOnBoardingViewModel extends Notifier<LegacyOnboardingViewState> {
@override
LegacyOnboardingViewState build() {
_checkSession();
return const LegacyOnboardingViewState();
}
Future<void> _checkSession() async {
try {
await ref.read(getUserInfoUseCaseProvider).getUserInfo();
if (!ref.mounted) return;
state = state.copyWith(isCheckingSession: false, isSessionValid: true);
} catch (_) {
if (!ref.mounted) return;
state = state.copyWith(isCheckingSession: false, isSessionValid: false);
}
}
void onPageChanged(int index) {
state = state.copyWith(cardIndex: index);
}

View File

@@ -6,8 +6,5 @@ part 'onboarding_view_state.freezed.dart';
abstract class LegacyOnboardingViewState with _$LegacyOnboardingViewState {
const factory LegacyOnboardingViewState({
@Default(0) int cardIndex,
@Default(true) bool isCheckingSession,
@Default(false) bool isSessionValid,
String? error,
}) = _LegacyOnboardingViewState;
}

View File

@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$LegacyOnboardingViewState {
int get cardIndex; bool get isCheckingSession; bool get isSessionValid; String? get error;
int get cardIndex;
/// Create a copy of LegacyOnboardingViewState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $LegacyOnboardingViewStateCopyWith<LegacyOnboardingViewState> get copyWith => _$
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyOnboardingViewState&&(identical(other.cardIndex, cardIndex) || other.cardIndex == cardIndex)&&(identical(other.isCheckingSession, isCheckingSession) || other.isCheckingSession == isCheckingSession)&&(identical(other.isSessionValid, isSessionValid) || other.isSessionValid == isSessionValid)&&(identical(other.error, error) || other.error == error));
return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyOnboardingViewState&&(identical(other.cardIndex, cardIndex) || other.cardIndex == cardIndex));
}
@override
int get hashCode => Object.hash(runtimeType,cardIndex,isCheckingSession,isSessionValid,error);
int get hashCode => Object.hash(runtimeType,cardIndex);
@override
String toString() {
return 'LegacyOnboardingViewState(cardIndex: $cardIndex, isCheckingSession: $isCheckingSession, isSessionValid: $isSessionValid, error: $error)';
return 'LegacyOnboardingViewState(cardIndex: $cardIndex)';
}
@@ -45,7 +45,7 @@ abstract mixin class $LegacyOnboardingViewStateCopyWith<$Res> {
factory $LegacyOnboardingViewStateCopyWith(LegacyOnboardingViewState value, $Res Function(LegacyOnboardingViewState) _then) = _$LegacyOnboardingViewStateCopyWithImpl;
@useResult
$Res call({
int cardIndex, bool isCheckingSession, bool isSessionValid, String? error
int cardIndex
});
@@ -62,13 +62,10 @@ class _$LegacyOnboardingViewStateCopyWithImpl<$Res>
/// Create a copy of LegacyOnboardingViewState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? cardIndex = null,Object? isCheckingSession = null,Object? isSessionValid = null,Object? error = freezed,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? cardIndex = null,}) {
return _then(_self.copyWith(
cardIndex: null == cardIndex ? _self.cardIndex : cardIndex // ignore: cast_nullable_to_non_nullable
as int,isCheckingSession: null == isCheckingSession ? _self.isCheckingSession : isCheckingSession // ignore: cast_nullable_to_non_nullable
as bool,isSessionValid: null == isSessionValid ? _self.isSessionValid : isSessionValid // ignore: cast_nullable_to_non_nullable
as bool,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
as String?,
as int,
));
}
@@ -153,10 +150,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int cardIndex, bool isCheckingSession, bool isSessionValid, String? error)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int cardIndex)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _LegacyOnboardingViewState() when $default != null:
return $default(_that.cardIndex,_that.isCheckingSession,_that.isSessionValid,_that.error);case _:
return $default(_that.cardIndex);case _:
return orElse();
}
@@ -174,10 +171,10 @@ return $default(_that.cardIndex,_that.isCheckingSession,_that.isSessionValid,_th
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int cardIndex, bool isCheckingSession, bool isSessionValid, String? error) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int cardIndex) $default,) {final _that = this;
switch (_that) {
case _LegacyOnboardingViewState():
return $default(_that.cardIndex,_that.isCheckingSession,_that.isSessionValid,_that.error);case _:
return $default(_that.cardIndex);case _:
throw StateError('Unexpected subclass');
}
@@ -194,10 +191,10 @@ return $default(_that.cardIndex,_that.isCheckingSession,_that.isSessionValid,_th
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int cardIndex, bool isCheckingSession, bool isSessionValid, String? error)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int cardIndex)? $default,) {final _that = this;
switch (_that) {
case _LegacyOnboardingViewState() when $default != null:
return $default(_that.cardIndex,_that.isCheckingSession,_that.isSessionValid,_that.error);case _:
return $default(_that.cardIndex);case _:
return null;
}
@@ -209,13 +206,10 @@ return $default(_that.cardIndex,_that.isCheckingSession,_that.isSessionValid,_th
class _LegacyOnboardingViewState implements LegacyOnboardingViewState {
const _LegacyOnboardingViewState({this.cardIndex = 0, this.isCheckingSession = true, this.isSessionValid = false, this.error});
const _LegacyOnboardingViewState({this.cardIndex = 0});
@override@JsonKey() final int cardIndex;
@override@JsonKey() final bool isCheckingSession;
@override@JsonKey() final bool isSessionValid;
@override final String? error;
/// Create a copy of LegacyOnboardingViewState
/// with the given fields replaced by the non-null parameter values.
@@ -227,16 +221,16 @@ _$LegacyOnboardingViewStateCopyWith<_LegacyOnboardingViewState> get copyWith =>
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyOnboardingViewState&&(identical(other.cardIndex, cardIndex) || other.cardIndex == cardIndex)&&(identical(other.isCheckingSession, isCheckingSession) || other.isCheckingSession == isCheckingSession)&&(identical(other.isSessionValid, isSessionValid) || other.isSessionValid == isSessionValid)&&(identical(other.error, error) || other.error == error));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyOnboardingViewState&&(identical(other.cardIndex, cardIndex) || other.cardIndex == cardIndex));
}
@override
int get hashCode => Object.hash(runtimeType,cardIndex,isCheckingSession,isSessionValid,error);
int get hashCode => Object.hash(runtimeType,cardIndex);
@override
String toString() {
return 'LegacyOnboardingViewState(cardIndex: $cardIndex, isCheckingSession: $isCheckingSession, isSessionValid: $isSessionValid, error: $error)';
return 'LegacyOnboardingViewState(cardIndex: $cardIndex)';
}
@@ -247,7 +241,7 @@ abstract mixin class _$LegacyOnboardingViewStateCopyWith<$Res> implements $Legac
factory _$LegacyOnboardingViewStateCopyWith(_LegacyOnboardingViewState value, $Res Function(_LegacyOnboardingViewState) _then) = __$LegacyOnboardingViewStateCopyWithImpl;
@override @useResult
$Res call({
int cardIndex, bool isCheckingSession, bool isSessionValid, String? error
int cardIndex
});
@@ -264,13 +258,10 @@ class __$LegacyOnboardingViewStateCopyWithImpl<$Res>
/// Create a copy of LegacyOnboardingViewState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? cardIndex = null,Object? isCheckingSession = null,Object? isSessionValid = null,Object? error = freezed,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? cardIndex = null,}) {
return _then(_LegacyOnboardingViewState(
cardIndex: null == cardIndex ? _self.cardIndex : cardIndex // ignore: cast_nullable_to_non_nullable
as int,isCheckingSession: null == isCheckingSession ? _self.isCheckingSession : isCheckingSession // ignore: cast_nullable_to_non_nullable
as bool,isSessionValid: null == isSessionValid ? _self.isSessionValid : isSessionValid // ignore: cast_nullable_to_non_nullable
as bool,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
as String?,
as int,
));
}

View File

@@ -21,11 +21,12 @@ class TreezorTokenInterceptor extends Interceptor {
_handling = true;
_onTokenExpired();
Future.delayed(const Duration(seconds: 2), () => _handling = false);
} else if (err.response?.statusCode == 401) {
_handling = true;
_onUnauthorized();
Future.delayed(const Duration(seconds: 2), () => _handling = false);
}
// else if (err.response?.statusCode == 401) {
// _handling = true;
// _onUnauthorized();
// Future.delayed(const Duration(seconds: 2), () => _handling = false);
// }
// } else if (err.response?.statusCode == 500) {
// _handling = true;
// _onTokenExpired();