Skip to content

Commit

Permalink
Fix Windows 10 visual bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tangenx committed May 5, 2022
1 parent e935096 commit 99adb93
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
38 changes: 37 additions & 1 deletion lib/components/discord_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:hive_flutter/hive_flutter.dart';
import 'package:lfdi/handlers/discord_websocket/websocket_manager.dart';
import 'package:lfdi/main.dart';
import 'package:spotify/spotify.dart';
import 'package:oauth2/oauth2.dart' as oauth2;

class DiscordForm extends ConsumerStatefulWidget {
const DiscordForm({Key? key}) : super(key: key);
Expand Down Expand Up @@ -116,6 +115,28 @@ class _DiscordFormState extends ConsumerState<DiscordForm> {
return;
}

// Check lastfm
final lastfmApiKey = box.get('apiKey');
final lastfmUsername = box.get('username');

if (lastfmUsername == null ||
lastfmApiKey == null ||
lastfmUsername.isEmpty ||
lastfmApiKey.isEmpty) {
setState(() {
processing = false;
});

showSnackbar(
context,
const Snackbar(
content: Text(
'Set up Last.fm firstly.',
),
),
);
}

if (discordFormKey.currentState!.validate()) {
setState(() {
processing = true;
Expand All @@ -127,6 +148,9 @@ class _DiscordFormState extends ConsumerState<DiscordForm> {
DiscordWebSocketManager webSocketManager =
ref.read(discordGatewayProvider);

webSocketManager.lastFmApiKey = lastfmApiKey;
webSocketManager.lastFmUsername = lastfmUsername;

if (webSocketManager.identifyIsSent) {
webSocketManager.reinit();
}
Expand Down Expand Up @@ -217,6 +241,18 @@ class _DiscordFormState extends ConsumerState<DiscordForm> {
webSocketManager.spotifyApi = SpotifyApi(
SpotifyApiCredentials(spotifyApiKey, spotifyApiSecret),
);

if (!webSocketManager.initialized) {
webSocketManager.init();

final priorUsing = box.get('priorUsing');

if (priorUsing == 'discord') {
if (!webSocketManager.started) {
webSocketManager.startUpdating();
}
}
}
}

showSnackbar(
Expand Down
1 change: 0 additions & 1 deletion lib/handlers/track_handler.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:lfdi/constants.dart';
import 'package:spotify/spotify.dart' as spotify;

class TrackHandler {
static Track getTrack(Map response) {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/get_window_effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ WindowEffect getWindowEffect() {

// Windows 10 1803 and higher
if (buildNumber >= 17134 && buildNumber < 22000) {
return WindowEffect.acrylic;
return WindowEffect.disabled;
}

// Windows 11+
Expand Down

0 comments on commit 99adb93

Please sign in to comment.