From c89837c0f8de8afc054b11cb1e5ba5449371290e Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Mon, 20 Jun 2022 19:13:33 -0700 Subject: [PATCH] [Play Count] Remember added count across sessions Remember if play count was already tracked for the current file across restarts, if resume playback after restart is enabled. Signed-off-by: Christopher Snowhill --- Application/AppController.m | 2 ++ DataModel.xcdatamodeld/DataModel.xcdatamodel/contents | 3 ++- Playlist/PlaylistController.m | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Application/AppController.m b/Application/AppController.m index 2f781769a..b2d54fb09 100644 --- a/Application/AppController.m +++ b/Application/AppController.m @@ -217,7 +217,9 @@ BOOL kAppControllerShuttingDown = NO; [playbackController playEntryAtIndex:pe.index startPaused:(lastStatus == CogStatusPaused) andSeekTo:@(pe.currentPosition)]; } else { pe.current = NO; + pe.stopAfter = NO; pe.currentPosition = 0.0; + pe.countAdded = NO; [playlistController commitPersistentStore]; } } diff --git a/DataModel.xcdatamodeld/DataModel.xcdatamodel/contents b/DataModel.xcdatamodeld/DataModel.xcdatamodel/contents index 0ba1e36ce..5d003293b 100644 --- a/DataModel.xcdatamodeld/DataModel.xcdatamodel/contents +++ b/DataModel.xcdatamodeld/DataModel.xcdatamodel/contents @@ -23,6 +23,7 @@ + @@ -67,7 +68,7 @@ - + \ No newline at end of file diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index 68d7576e3..84cb48547 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -246,6 +246,9 @@ static void *playlistControllerContext = &playlistControllerContext; } - (void)updatePlayCountForTrack:(PlaylistEntry *)pe { + if(pe.countAdded) return; + pe.countAdded = YES; + PlayCount *pc = pe.playCountItem; if(pc) { @@ -1393,6 +1396,7 @@ static void *playlistControllerContext = &playlistControllerContext; currentEntry.current = NO; currentEntry.stopAfter = NO; currentEntry.currentPosition = 0.0; + currentEntry.countAdded = NO; } if(pe) {