fix logout
This commit is contained in:
parent
c28256f258
commit
019961ca85
|
@ -88,6 +88,10 @@ class DeezerAPI {
|
|||
};
|
||||
|
||||
Future<void> logout() async {
|
||||
// actual logout from deezer API
|
||||
await dio.get('https://www.deezer.com/logout.php');
|
||||
await dio.get('https://auth.deezer.com/logout');
|
||||
|
||||
// delete all cookies
|
||||
await cookieJar.deleteAll();
|
||||
updateHeaders();
|
||||
|
@ -332,11 +336,16 @@ class DeezerAPI {
|
|||
return SearchResults.fromPrivateJson(data['results']);
|
||||
}
|
||||
|
||||
Future<List<Track>> getTracks(List<String> ids) async {
|
||||
final data = await callApi('song.getListData', params: {'sng_ids': ids});
|
||||
|
||||
return (data['results']['data'] as List)
|
||||
.map<Track>((t) => Track.fromPrivateJson(t as Map))
|
||||
.toList(growable: false);
|
||||
}
|
||||
|
||||
Future<Track> track(String id) async {
|
||||
Map<dynamic, dynamic> data = await callApi('song.getListData', params: {
|
||||
'sng_ids': [id]
|
||||
});
|
||||
return Track.fromPrivateJson(data['results']['data'][0]);
|
||||
return (await getTracks([id]))[0];
|
||||
}
|
||||
|
||||
//Get album details, tracks
|
||||
|
|
|
@ -293,12 +293,12 @@ class _LoginMainWrapperState extends State<LoginMainWrapper> {
|
|||
|
||||
Future _logOut() async {
|
||||
await deezerAPI.logout();
|
||||
await settings.save();
|
||||
await Cache.wipe();
|
||||
setState(() {
|
||||
settings.arl = null;
|
||||
settings.offlineMode = false;
|
||||
});
|
||||
await settings.save();
|
||||
await Cache.wipe();
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -362,15 +362,9 @@ class LoginBrowser extends StatefulWidget {
|
|||
class _LoginBrowserState extends State<LoginBrowser> {
|
||||
late final WebViewController _controller;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_controller = WebViewController()
|
||||
..clearLocalStorage()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
..setBackgroundColor(const Color(0x00000000))
|
||||
// Chrome on Android 14
|
||||
|
@ -419,6 +413,14 @@ class _LoginBrowserState extends State<LoginBrowser> {
|
|||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// clear everything
|
||||
unawaited(_controller.clearCache());
|
||||
unawaited(_controller.clearLocalStorage());
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:async/async.dart';
|
||||
import 'package:audio_service/audio_service.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:freezer/api/deezer.dart';
|
||||
import 'package:freezer/api/definitions.dart';
|
||||
import 'package:freezer/api/pipe_api.dart';
|
||||
import 'package:freezer/api/player/audio_handler.dart';
|
||||
|
@ -49,13 +47,13 @@ class LyricsWidget extends StatefulWidget {
|
|||
class _LyricsWidgetState extends State<LyricsWidget>
|
||||
with WidgetsBindingObserver {
|
||||
StreamSubscription? _mediaItemSub;
|
||||
StreamSubscription? _playbackStateSub;
|
||||
StreamSubscription? _positionSub;
|
||||
int? _currentIndex = -1;
|
||||
Duration _nextOffset = Duration.zero;
|
||||
Duration _currentOffset = Duration.zero;
|
||||
String? _currentTrackId;
|
||||
final ScrollController _controller = ScrollController();
|
||||
static const double height = 90.0;
|
||||
static const double height = 110.0;
|
||||
static const double additionalTranslationHeight = 40.0;
|
||||
BoxConstraints? _widgetConstraints;
|
||||
Lyrics? _lyrics;
|
||||
|
@ -106,8 +104,8 @@ class _LyricsWidgetState extends State<LyricsWidget>
|
|||
_lyrics = lyrics;
|
||||
});
|
||||
|
||||
// SchedulerBinding.instance.addPostFrameCallback(
|
||||
// (_) => _updatePosition(audioHandler.playbackState.value.position));
|
||||
SchedulerBinding.instance.addPostFrameCallback(
|
||||
(_) => _updatePosition(audioHandler.playbackState.value.position));
|
||||
} on DioException catch (e) {
|
||||
if (e.type != DioExceptionType.cancel) rethrow;
|
||||
} catch (e) {
|
||||
|
@ -148,8 +146,7 @@ class _LyricsWidgetState extends State<LyricsWidget>
|
|||
.then((_) => _animatedScroll = false);
|
||||
}
|
||||
|
||||
void _updatePosition(PlaybackState playbackState) {
|
||||
final position = playbackState.position;
|
||||
void _updatePosition(Duration position) {
|
||||
if (_loading) return;
|
||||
if (!_syncedLyrics) return;
|
||||
if (position < _nextOffset && position > _currentOffset) return;
|
||||
|
@ -174,9 +171,8 @@ class _LyricsWidgetState extends State<LyricsWidget>
|
|||
}
|
||||
|
||||
void _makeSubscriptions() {
|
||||
if (_mediaItemSub != null || _playbackStateSub != null) return;
|
||||
|
||||
_playbackStateSub = audioHandler.playbackState.listen(_updatePosition);
|
||||
if (_mediaItemSub != null || _positionSub != null) return;
|
||||
_positionSub = AudioService.position.listen(_updatePosition);
|
||||
|
||||
/// Track change = reload new lyrics
|
||||
_mediaItemSub = audioHandler.mediaItem.listen((mediaItem) {
|
||||
|
@ -188,9 +184,9 @@ class _LyricsWidgetState extends State<LyricsWidget>
|
|||
|
||||
void _cancelSubscriptions() {
|
||||
_mediaItemSub?.cancel();
|
||||
_playbackStateSub?.cancel();
|
||||
_positionSub?.cancel();
|
||||
_mediaItemSub = null;
|
||||
_playbackStateSub = null;
|
||||
_positionSub = null;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -301,7 +297,7 @@ class _LyricsWidgetState extends State<LyricsWidget>
|
|||
: 0.0),
|
||||
itemCount: _lyrics!.lyrics!.length,
|
||||
itemBuilder: (BuildContext context, int i) {
|
||||
return Container(
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius.circular(8.0),
|
||||
|
@ -318,49 +314,41 @@ class _LyricsWidgetState extends State<LyricsWidget>
|
|||
_lyrics!.lyrics![i].offset!)
|
||||
: null,
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: _currentIndex == i
|
||||
? EdgeInsets.zero
|
||||
: const EdgeInsets
|
||||
.symmetric(
|
||||
horizontal: 16.0),
|
||||
child: Column(
|
||||
mainAxisSize:
|
||||
MainAxisSize.min,
|
||||
children: [
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
_lyrics!.lyrics![i].text!,
|
||||
textAlign: _syncedLyrics
|
||||
? TextAlign.center
|
||||
: TextAlign.start,
|
||||
style: TextStyle(
|
||||
fontSize: _syncedLyrics
|
||||
? 26.0
|
||||
: 20.0,
|
||||
fontWeight:
|
||||
(_currentIndex == i)
|
||||
? FontWeight
|
||||
.bold
|
||||
: FontWeight
|
||||
.normal),
|
||||
),
|
||||
if (_showTranslation)
|
||||
Text(
|
||||
_lyrics!.lyrics![i].text!,
|
||||
textAlign: _syncedLyrics
|
||||
? TextAlign.center
|
||||
: TextAlign.start,
|
||||
style: TextStyle(
|
||||
fontSize:
|
||||
_syncedLyrics
|
||||
? 26.0
|
||||
: 20.0,
|
||||
fontWeight:
|
||||
(_currentIndex ==
|
||||
i)
|
||||
? FontWeight
|
||||
.bold
|
||||
: FontWeight
|
||||
.normal),
|
||||
),
|
||||
if (_showTranslation)
|
||||
Text(
|
||||
_lyrics!.lyrics![i]
|
||||
.translated!,
|
||||
style: TextStyle(
|
||||
color: Color.lerp(
|
||||
Theme.of(
|
||||
context)
|
||||
.colorScheme
|
||||
.onBackground,
|
||||
Colors.black,
|
||||
0.12),
|
||||
fontSize: 20.0)),
|
||||
],
|
||||
),
|
||||
_lyrics!.lyrics![i]
|
||||
.translated!,
|
||||
textAlign:
|
||||
TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Color.lerp(
|
||||
Theme.of(
|
||||
context)
|
||||
.colorScheme
|
||||
.onBackground,
|
||||
Colors.black,
|
||||
0.12),
|
||||
fontSize: 20.0)),
|
||||
],
|
||||
),
|
||||
)));
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue