FIXME: Missing Freshly Created Songs to Fetch
This commit is contained in:
parent
da53e4507c
commit
75ae569a55
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user