FIXME: Missing Freshly Created Songs to Fetch

This commit is contained in:
Fawkes100 2025-01-19 19:49:20 +01:00
parent da53e4507c
commit 75ae569a55
2 changed files with 8 additions and 4 deletions

View File

@ -165,7 +165,7 @@ public class SongSyncRepository {
});
}
public void markSongsAsRemotelyModified(List<String> serverIDs) {
public void markSongsAsRemotelyModified(List<String> serverIDs, LoadDataCallback<List<Song>> callback) {
Executors.newSingleThreadExecutor().execute(() -> {
List<Song> songs = songDao.getSongsByServerIDs(serverIDs);
List<Song> createdSongs = new ArrayList<>();
@ -189,6 +189,7 @@ public class SongSyncRepository {
}
songDao.updateSongs(songs);
songDao.insertSongs(createdSongs);
callback.onResult(createdSongs);
});
}

View File

@ -90,14 +90,17 @@ public class SongSyncModule {
songSyncService.fetchRemoteModifiedSongs(LocalDateTime.now().minusDays(35), new SongSyncRepository.LoadDataCallback<FetchResponse>() {
@Override
public void onResult(FetchResponse result) {
songSyncRepository.markSongsAsRemotelyModified(result.getServerIDs());
getRemotelyModifiedSongData();
songSyncRepository.markSongsAsRemotelyModified(result.getServerIDs(), createdSongs -> {
getRemotelyModifiedSongData(createdSongs);
});
}
});
}
public void getRemotelyModifiedSongData() {
public void getRemotelyModifiedSongData(List<Song> freshlyCreatedSongs) {
songSyncRepository.loadRemotelyModifiedSongs(songs -> {
songs.addAll(freshlyCreatedSongs);
if(songs.isEmpty()) {
syncViewModel.finishFetching();
} else {