nextNoteVault #23

Merged
sebastian merged 57 commits from nextNoteVault into master 2025-05-10 06:23:23 +00:00
2 changed files with 8 additions and 4 deletions
Showing only changes of commit 75ae569a55 - Show all commits

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 {