diff --git a/lib/episodes/episode_detail.dart b/lib/episodes/episode_detail.dart index 719d572..75bcda6 100644 --- a/lib/episodes/episode_detail.dart +++ b/lib/episodes/episode_detail.dart @@ -425,14 +425,14 @@ class _MenuBarState extends State { return await dbHelper.isLiked(episode.enclosureUrl); } - Widget _buttonOnMenu(Widget widget, VoidCallback onTap) => Material( + Widget _buttonOnMenu({Widget child, VoidCallback onTap}) => Material( color: Colors.transparent, child: InkWell( onTap: onTap, child: Container( height: 50.0, padding: EdgeInsets.symmetric(horizontal: 15.0), - child: widget), + child: child), ), ); @@ -499,49 +499,55 @@ class _MenuBarState extends State { builder: (context, snapshot) { return (!snapshot.data) ? _buttonOnMenu( - Icon( + child: Icon( Icons.favorite_border, color: Colors.grey[700], - ), () async { - await saveLiked(widget.episodeItem.enclosureUrl); - OverlayEntry _overlayEntry; - _overlayEntry = _createOverlayEntry(); - Overlay.of(context).insert(_overlayEntry); - await Future.delayed(Duration(seconds: 2)); - _overlayEntry?.remove(); - }) + ), + onTap: () async { + await saveLiked( + widget.episodeItem.enclosureUrl); + OverlayEntry _overlayEntry; + _overlayEntry = _createOverlayEntry(); + Overlay.of(context).insert(_overlayEntry); + await Future.delayed(Duration(seconds: 2)); + _overlayEntry?.remove(); + }) : _buttonOnMenu( - Icon( + child: Icon( Icons.favorite, color: Colors.red, ), - () => + onTap: () => setUnliked(widget.episodeItem.enclosureUrl)); }, ), DownloadButton(episode: widget.episodeItem), - Selector>( - selector: (_, audio) => audio.queue.playlist, + Selector, bool>>( + selector: (_, audio) => + Tuple2(audio.queue.playlist, audio.queueUpdate), builder: (_, data, __) { - return data.contains(widget.episodeItem) + return data.item1.contains(widget.episodeItem) ? _buttonOnMenu( - Icon(Icons.playlist_add_check, - color: context.accentColor), () { - audio.delFromPlaylist(widget.episodeItem); - Fluttertoast.showToast( - msg: s.toastRemovePlaylist, - gravity: ToastGravity.BOTTOM, - ); - }) + child: Icon(Icons.playlist_add_check, + color: context.accentColor), + onTap: () { + audio.delFromPlaylist(widget.episodeItem); + Fluttertoast.showToast( + msg: s.toastRemovePlaylist, + gravity: ToastGravity.BOTTOM, + ); + }) : _buttonOnMenu( - Icon(Icons.playlist_add, color: Colors.grey[700]), - () { - Fluttertoast.showToast( - msg: s.toastAddPlaylist, - gravity: ToastGravity.BOTTOM, - ); - audio.addToPlaylist(widget.episodeItem); - }); + child: Icon(Icons.playlist_add, + color: Colors.grey[700]), + onTap: () { + audio.addToPlaylist(widget.episodeItem); + Fluttertoast.showToast( + msg: s.toastAddPlaylist, + gravity: ToastGravity.BOTTOM, + ); + }); }, ), FutureBuilder( diff --git a/lib/local_storage/sqflite_localpodcast.dart b/lib/local_storage/sqflite_localpodcast.dart index 7d60c1b..cade9a4 100644 --- a/lib/local_storage/sqflite_localpodcast.dart +++ b/lib/local_storage/sqflite_localpodcast.dart @@ -982,7 +982,7 @@ class DBHelper { await txn.rawUpdate( "UPDATE Episodes SET is_new = 0 WHERE enclosure_url = ?", [url]); }); - print('remove new episode'); + print('remove new episode $url'); } Future> getLikedRssItem(int i, int sortBy) async { diff --git a/lib/state/audio_state.dart b/lib/state/audio_state.dart index e016bfc..ceb2191 100644 --- a/lib/state/audio_state.dart +++ b/lib/state/audio_state.dart @@ -464,6 +464,7 @@ class AudioPlayerNotifier extends ChangeNotifier { await AudioService.addQueueItem(episodeNew.toMediaItem()); } await _queue.addToPlayList(episodeNew); + _queueUpdate = !_queueUpdate; notifyListeners(); } } diff --git a/lib/type/playlist.dart b/lib/type/playlist.dart index fe7d8db..51416cb 100644 --- a/lib/type/playlist.dart +++ b/lib/type/playlist.dart @@ -5,9 +5,7 @@ import 'episodebrief.dart'; class Playlist { String name; DBHelper dbHelper = DBHelper(); - List _playlist; - List get playlist => _playlist; KeyValueStorage storage = KeyValueStorage('playlist'); @@ -17,7 +15,6 @@ class Playlist { _playlist = []; } else { _playlist = []; - for (var url in urls) { var episode = await dbHelper.getRssItemWithUrl(url); if (episode != null) _playlist.add(episode); @@ -35,7 +32,9 @@ class Playlist { if (!_playlist.contains(episodeBrief)) { _playlist.add(episodeBrief); await savePlaylist(); - dbHelper.removeEpisodeNewMark(episodeBrief.enclosureUrl); + if (episodeBrief.isNew == 1) { + await dbHelper.removeEpisodeNewMark(episodeBrief.enclosureUrl); + } } } @@ -43,7 +42,9 @@ class Playlist { if (!_playlist.contains(episodeBrief)) { _playlist.insert(index, episodeBrief); await savePlaylist(); - dbHelper.removeEpisodeNewMark(episodeBrief.enclosureUrl); + if (episodeBrief.isNew == 1) { + await dbHelper.removeEpisodeNewMark(episodeBrief.enclosureUrl); + } } } diff --git a/lib/util/extension_helper.dart b/lib/util/extension_helper.dart index ca8c99f..1f2b747 100644 --- a/lib/util/extension_helper.dart +++ b/lib/util/extension_helper.dart @@ -27,7 +27,9 @@ extension IntExtension on int { final s = context.s; var date = DateTime.fromMillisecondsSinceEpoch(this, isUtc: true); var difference = DateTime.now().toUtc().difference(date); - if (difference.inHours < 24) { + if (difference.inMinutes < 30) { + return s.hoursAgo(0); + } else if (difference.inHours < 24) { return s.hoursAgo(difference.inHours); } else if (difference.inDays < 7) { return s.daysAgo(difference.inDays);