mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
chore(server,mobile): remove device info entity (#1527)
* chore(server): remove unused device info code * chore: generate open api * remove any DeviceTypeEnum usage from mobile * chore: coverage * fix: drop device info table --------- Co-authored-by: Fynn Petersen-Frey <zody22@gmail.com>
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
class AuthenticationState {
|
||||
final String deviceId;
|
||||
final DeviceTypeEnum deviceType;
|
||||
final String userId;
|
||||
final String userEmail;
|
||||
final bool isAuthenticated;
|
||||
@@ -13,7 +10,6 @@ class AuthenticationState {
|
||||
final String profileImagePath;
|
||||
AuthenticationState({
|
||||
required this.deviceId,
|
||||
required this.deviceType,
|
||||
required this.userId,
|
||||
required this.userEmail,
|
||||
required this.isAuthenticated,
|
||||
@@ -26,7 +22,6 @@ class AuthenticationState {
|
||||
|
||||
AuthenticationState copyWith({
|
||||
String? deviceId,
|
||||
DeviceTypeEnum? deviceType,
|
||||
String? userId,
|
||||
String? userEmail,
|
||||
bool? isAuthenticated,
|
||||
@@ -38,7 +33,6 @@ class AuthenticationState {
|
||||
}) {
|
||||
return AuthenticationState(
|
||||
deviceId: deviceId ?? this.deviceId,
|
||||
deviceType: deviceType ?? this.deviceType,
|
||||
userId: userId ?? this.userId,
|
||||
userEmail: userEmail ?? this.userEmail,
|
||||
isAuthenticated: isAuthenticated ?? this.isAuthenticated,
|
||||
@@ -52,7 +46,7 @@ class AuthenticationState {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AuthenticationState(deviceId: $deviceId, deviceType: $deviceType, userId: $userId, userEmail: $userEmail, isAuthenticated: $isAuthenticated, firstName: $firstName, lastName: $lastName, isAdmin: $isAdmin, shouldChangePassword: $shouldChangePassword, profileImagePath: $profileImagePath)';
|
||||
return 'AuthenticationState(deviceId: $deviceId, userId: $userId, userEmail: $userEmail, isAuthenticated: $isAuthenticated, firstName: $firstName, lastName: $lastName, isAdmin: $isAdmin, shouldChangePassword: $shouldChangePassword, profileImagePath: $profileImagePath)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -61,7 +55,6 @@ class AuthenticationState {
|
||||
|
||||
return other is AuthenticationState &&
|
||||
other.deviceId == deviceId &&
|
||||
other.deviceType == deviceType &&
|
||||
other.userId == userId &&
|
||||
other.userEmail == userEmail &&
|
||||
other.isAuthenticated == isAuthenticated &&
|
||||
@@ -75,7 +68,6 @@ class AuthenticationState {
|
||||
@override
|
||||
int get hashCode {
|
||||
return deviceId.hashCode ^
|
||||
deviceType.hashCode ^
|
||||
userId.hashCode ^
|
||||
userEmail.hashCode ^
|
||||
isAuthenticated.hashCode ^
|
||||
|
||||
@@ -3,24 +3,22 @@ import 'dart:io';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_udid/flutter_udid.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/shared/models/store.dart';
|
||||
import 'package:immich_mobile/modules/login/models/authentication_state.model.dart';
|
||||
import 'package:immich_mobile/shared/models/user.dart';
|
||||
import 'package:immich_mobile/shared/providers/api.provider.dart';
|
||||
import 'package:immich_mobile/shared/services/api.service.dart';
|
||||
import 'package:immich_mobile/shared/services/device_info.service.dart';
|
||||
import 'package:immich_mobile/utils/hash.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
||||
AuthenticationNotifier(
|
||||
this._deviceInfoService,
|
||||
this._apiService,
|
||||
) : super(
|
||||
AuthenticationState(
|
||||
deviceId: "",
|
||||
deviceType: DeviceTypeEnum.ANDROID,
|
||||
userId: "",
|
||||
userEmail: "",
|
||||
firstName: '',
|
||||
@@ -32,7 +30,6 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
||||
),
|
||||
);
|
||||
|
||||
final DeviceInfoService _deviceInfoService;
|
||||
final ApiService _apiService;
|
||||
|
||||
Future<bool> login(
|
||||
@@ -146,9 +143,9 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
||||
}
|
||||
|
||||
if (userResponseDto != null) {
|
||||
var deviceInfo = await _deviceInfoService.getDeviceInfo();
|
||||
Store.put(StoreKey.deviceId, deviceInfo["deviceId"]);
|
||||
Store.put(StoreKey.deviceIdHash, fastHash(deviceInfo["deviceId"]));
|
||||
final deviceId = await FlutterUdid.consistentUdid;
|
||||
Store.put(StoreKey.deviceId, deviceId);
|
||||
Store.put(StoreKey.deviceIdHash, fastHash(deviceId));
|
||||
Store.put(StoreKey.currentUser, User.fromDto(userResponseDto));
|
||||
Store.put(StoreKey.serverUrl, serverUrl);
|
||||
Store.put(StoreKey.accessToken, accessToken);
|
||||
@@ -162,8 +159,7 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
||||
profileImagePath: userResponseDto.profileImagePath,
|
||||
isAdmin: userResponseDto.isAdmin,
|
||||
shouldChangePassword: userResponseDto.shouldChangePassword,
|
||||
deviceId: deviceInfo["deviceId"],
|
||||
deviceType: deviceInfo["deviceType"],
|
||||
deviceId: deviceId,
|
||||
);
|
||||
}
|
||||
return true;
|
||||
@@ -173,7 +169,6 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
|
||||
final authenticationProvider =
|
||||
StateNotifierProvider<AuthenticationNotifier, AuthenticationState>((ref) {
|
||||
return AuthenticationNotifier(
|
||||
ref.watch(deviceInfoServiceProvider),
|
||||
ref.watch(apiServiceProvider),
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user