Skip to content

Commit

Permalink
code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
LezdCS committed Jun 8, 2024
1 parent bc41c2e commit f4ad50b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<SeCredentials> creds = await refreshAccessToken(seCredentials);
if (creds.error == null) {
if (creds is DataSuccess) {
seCredentials = creds.data!;
} else {
return DataFailed("Error refreshing SE Token");
Expand Down
14 changes: 7 additions & 7 deletions lib/src/presentation/controllers/home_view_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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}
});
}
});
Expand All @@ -129,17 +129,17 @@ class HomeViewController extends GetxController
Future<void> setStreamElementsCredentials() async {
DataState<SeCredentials> seCreds =
await homeEvents.getSeCredentialsFromLocal();
if (seCreds.error == null) {
seCredentials.value = seCreds.data!;
if (seCreds is DataSuccess) {
seCredentials.value = seCreds.data;
await setSeMe(seCredentials.value!);
}
}

Future<void> setSeMe(SeCredentials seCreds) async {
DataState<SeMe> seMeResult =
await homeEvents.getSeMe(seCredentials.value!.accessToken);
if (seMeResult.error == null) {
seMe.value = seMeResult.data!;
if (seMeResult is DataSuccess) {
seMe.value = seMeResult.data;
}
}

Expand Down Expand Up @@ -350,7 +350,7 @@ class HomeViewController extends GetxController

Future<DataState<Settings>> getSettings() async {
DataState<Settings> settings = await homeEvents.getSettings();
if (settings.error != null) {
if (settings is DataFailed){
return DataFailed('');
}
await applySettings(settings.data!);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/presentation/controllers/login_view_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand All @@ -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]);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class RealtimeIrlViewController extends GetxController {
Future start() async {
timerRtIrl = Timer.periodic(const Duration(seconds: 4), (Timer t) async {
DataState<Position> p = await determinePosition();
if (p.error == null && realtimeIrl.status == RtIrlStatus.updating) {
if (p is DataSuccess && realtimeIrl.status == RtIrlStatus.updating) {
realtimeIrl.updatePosition(p.data!);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class StreamelementsViewController extends GetxController
if (jwt != null) {
DataState<List<SeSong>> songQueue =
await streamelementsEvents.getSongQueue(jwt!, me.id);
if (songQueue.error == null) {
if (songQueue is DataSuccess) {
songRequestQueue.value = songQueue.data ?? [];
}
}
Expand Down

0 comments on commit f4ad50b

Please sign in to comment.