Skip to content

Commit

Permalink
Formatted the files.
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmicRaptor committed Nov 6, 2024

Verified

This commit was signed with the committer’s verified signature.
tameTNT Luca
1 parent a2b3c22 commit eb755f0
Showing 4 changed files with 129 additions and 123 deletions.
11 changes: 6 additions & 5 deletions lib/expose/expose_service.dart
Original file line number Diff line number Diff line change
@@ -8,8 +8,9 @@ class ExposeService {
required FlutterDiscordRPC? discordRPC,
required LastFMAuthorized? lastFm,
required bool lastFmEnabled,
})
: _discordRPC = discordRPC, _lastFm = lastFm, _lastFmEnabled = lastFmEnabled;
}) : _discordRPC = discordRPC,
_lastFm = lastFm,
_lastFmEnabled = lastFmEnabled;

final FlutterDiscordRPC? _discordRPC;
final LastFMAuthorized? _lastFm;
@@ -31,7 +32,7 @@ class ExposeService {
additionalInfo: additionalInfo,
imageUrl: imageUrl,
);
if(_lastFmEnabled){
if (_lastFmEnabled) {
await _exposeTitleToLastfm(
title: title,
artist: artist,
@@ -70,7 +71,7 @@ class ExposeService {
Future<void> _exposeTitleToLastfm({
required String title,
required String artist,
}) async{
}) async {
try {
await _lastFm?.scrobble(
track: title,
@@ -106,4 +107,4 @@ class ExposeService {
await disconnectFromDiscord();
await _errorController.close();
}
}
}
70 changes: 34 additions & 36 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -108,44 +108,42 @@ void registerServicesAndViewModels({
),
dispose: (s) => s.dispose(),
)
..registerFactory<LastFM>(
(){
final apiKey = sharedPreferences.getString(kLastFmApiKey) ?? '';
final apiSecret = sharedPreferences.getString(klastFmSecret) ?? '';
final sessionKey = sharedPreferences.getString(kLastFmSessionKey);
final username = sharedPreferences.getString(kLastFmUsername);
..registerFactory<LastFM>(() {
final apiKey = sharedPreferences.getString(kLastFmApiKey) ?? '';
final apiSecret = sharedPreferences.getString(klastFmSecret) ?? '';
final sessionKey = sharedPreferences.getString(kLastFmSessionKey);
final username = sharedPreferences.getString(kLastFmUsername);

if (sessionKey != null && username != null) {
return LastFMAuthorized(
apiKey, secret: apiSecret,
sessionKey: sessionKey,
username: username,
);
} else {
return LastFMUnauthorized(apiKey, apiSecret);
}
}
)
if (sessionKey != null && username != null) {
return LastFMAuthorized(
apiKey,
secret: apiSecret,
sessionKey: sessionKey,
username: username,
);
} else {
return LastFMUnauthorized(apiKey, apiSecret);
}
})
..registerLazySingleton<ExposeService>(
(){
final sessionKey = sharedPreferences.getString(kLastFmSessionKey);
final lastFMEnabled =
sharedPreferences.getBool(kEnableLastFmScrobbling) ?? false;
if(sessionKey != null){
return ExposeService(
discordRPC: allowDiscordRPC ? di<FlutterDiscordRPC>() : null,
lastFm: di<LastFM>() as LastFMAuthorized,
lastFmEnabled: lastFMEnabled,
);
}
else {
return ExposeService(
discordRPC: allowDiscordRPC ? di<FlutterDiscordRPC>() : null,
lastFm: null,
lastFmEnabled: lastFMEnabled,
);
}
},
() {
final sessionKey = sharedPreferences.getString(kLastFmSessionKey);
final lastFMEnabled =
sharedPreferences.getBool(kEnableLastFmScrobbling) ?? false;
if (sessionKey != null) {
return ExposeService(
discordRPC: allowDiscordRPC ? di<FlutterDiscordRPC>() : null,
lastFm: di<LastFM>() as LastFMAuthorized,
lastFmEnabled: lastFMEnabled,
);
} else {
return ExposeService(
discordRPC: allowDiscordRPC ? di<FlutterDiscordRPC>() : null,
lastFm: null,
lastFmEnabled: lastFMEnabled,
);
}
},
dispose: (s) => s.dispose(),
)
..registerLazySingleton<PlayerService>(
14 changes: 9 additions & 5 deletions lib/settings/settings_service.dart
Original file line number Diff line number Diff line change
@@ -45,35 +45,39 @@ class SettingsService {
String? get lastFmUsername => _preferences.getString(kLastFmUsername);
void setEnableLastFmScrobbling(bool value) {
_preferences.setBool(kEnableLastFmScrobbling, value).then(
(saved) {
(saved) {
if (saved) _propertiesChangedController.add(true);
},
);
}

void setLastFmApiKey(String value) {
_preferences.setString(kLastFmApiKey, value).then(
(saved) {
(saved) {
if (saved) _propertiesChangedController.add(true);
},
);
}

void setLastFmSecret(String value) {
_preferences.setString(klastFmSecret, value).then(
(saved) {
(saved) {
if (saved) _propertiesChangedController.add(true);
},
);
}

void setLastFmSessionKey(String value) {
_preferences.setString(kLastFmSessionKey, value).then(
(saved) {
(saved) {
if (saved) _propertiesChangedController.add(true);
},
);
}

void setLastFmUsername(String value) {
_preferences.setString(kLastFmUsername, value).then(
(saved) {
(saved) {
if (saved) _propertiesChangedController.add(true);
},
);
Loading

0 comments on commit eb755f0

Please sign in to comment.