diff --git a/lib/src/data/repositories/streamelements_repository_impl.dart b/lib/src/data/repositories/streamelements_repository_impl.dart index 32000aca..44b3482b 100644 --- a/lib/src/data/repositories/streamelements_repository_impl.dart +++ b/lib/src/data/repositories/streamelements_repository_impl.dart @@ -190,7 +190,7 @@ class StreamelementsRepositoryImpl extends StreamelementsRepository { //refresh the access token to be sure the token is going to be valid after starting the app DataState creds = await refreshAccessToken(seCredentials); - if (creds.error == null) { + if (creds is DataSuccess) { seCredentials = creds.data!; } else { return DataFailed("Error refreshing SE Token"); diff --git a/lib/src/presentation/controllers/home_view_controller.dart b/lib/src/presentation/controllers/home_view_controller.dart index 91e0bec2..7960a87f 100644 --- a/lib/src/presentation/controllers/home_view_controller.dart +++ b/lib/src/presentation/controllers/home_view_controller.dart @@ -99,14 +99,14 @@ class HomeViewController extends GetxController timerRefreshToken = Timer.periodic(const Duration(seconds: 13000), (Timer t) { homeEvents.refreshAccessToken(twitchData: twitchData!).then((value) => { - if (value.error == null) {twitchData = value.data!} + if (value is DataSuccess) {twitchData = value.data} }); if (seCredentials.value != null) { homeEvents .refreshSeAccessToken(seCredentials: seCredentials.value!) .then((value) => { - if (value.error == null) {seCredentials.value = value.data!} + if (value is DataSuccess) {seCredentials.value = value.data} }); } }); @@ -129,8 +129,8 @@ class HomeViewController extends GetxController Future setStreamElementsCredentials() async { DataState seCreds = await homeEvents.getSeCredentialsFromLocal(); - if (seCreds.error == null) { - seCredentials.value = seCreds.data!; + if (seCreds is DataSuccess) { + seCredentials.value = seCreds.data; await setSeMe(seCredentials.value!); } } @@ -138,8 +138,8 @@ class HomeViewController extends GetxController Future setSeMe(SeCredentials seCreds) async { DataState seMeResult = await homeEvents.getSeMe(seCredentials.value!.accessToken); - if (seMeResult.error == null) { - seMe.value = seMeResult.data!; + if (seMeResult is DataSuccess) { + seMe.value = seMeResult.data; } } @@ -350,7 +350,7 @@ class HomeViewController extends GetxController Future> getSettings() async { DataState settings = await homeEvents.getSettings(); - if (settings.error != null) { + if (settings is DataFailed){ return DataFailed(''); } await applySettings(settings.data!); diff --git a/lib/src/presentation/controllers/login_view_controller.dart b/lib/src/presentation/controllers/login_view_controller.dart index 869c8dd8..f4c95c9e 100644 --- a/lib/src/presentation/controllers/login_view_controller.dart +++ b/lib/src/presentation/controllers/login_view_controller.dart @@ -34,7 +34,7 @@ class LoginViewController extends GetxController { await loginEvents.getTwitchFromLocal(); isLoading.value = false; - if (twitchCredsResult.error == null) { + if (twitchCredsResult is DataSuccess) { Get.offAllNamed(Routes.home, arguments: [twitchCredsResult.data]); } @@ -45,7 +45,7 @@ class LoginViewController extends GetxController { isLoading.value = true; TwitchAuthParams params = const TwitchAuthParams(); await loginEvents.getTwitchOauth(params: params).then((value) { - if (value.error == null) { + if (value is DataSuccess) { Get.offAllNamed(Routes.home, arguments: [value.data]); } }); diff --git a/lib/src/presentation/controllers/realtime_irl_view_controller.dart b/lib/src/presentation/controllers/realtime_irl_view_controller.dart index c8d929eb..25f89de8 100644 --- a/lib/src/presentation/controllers/realtime_irl_view_controller.dart +++ b/lib/src/presentation/controllers/realtime_irl_view_controller.dart @@ -30,7 +30,7 @@ class RealtimeIrlViewController extends GetxController { Future start() async { timerRtIrl = Timer.periodic(const Duration(seconds: 4), (Timer t) async { DataState p = await determinePosition(); - if (p.error == null && realtimeIrl.status == RtIrlStatus.updating) { + if (p is DataSuccess && realtimeIrl.status == RtIrlStatus.updating) { realtimeIrl.updatePosition(p.data!); } }); diff --git a/lib/src/presentation/controllers/streamelements_view_controller.dart b/lib/src/presentation/controllers/streamelements_view_controller.dart index be144d3d..ed966c75 100644 --- a/lib/src/presentation/controllers/streamelements_view_controller.dart +++ b/lib/src/presentation/controllers/streamelements_view_controller.dart @@ -101,7 +101,7 @@ class StreamelementsViewController extends GetxController if (jwt != null) { DataState> songQueue = await streamelementsEvents.getSongQueue(jwt!, me.id); - if (songQueue.error == null) { + if (songQueue is DataSuccess) { songRequestQueue.value = songQueue.data ?? []; } }