|
|
|
|
@ -128,6 +128,7 @@ class NiaPreferencesDataSource @Inject constructor(
|
|
|
|
|
bookmarkedNewsResourceIds.put(newsResourceId, true)
|
|
|
|
|
} else {
|
|
|
|
|
bookmarkedNewsResourceIds.remove(newsResourceId)
|
|
|
|
|
bookmarkNotes.remove(newsResourceId)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -136,6 +137,26 @@ class NiaPreferencesDataSource @Inject constructor(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
suspend fun setBookmarkNote(newsResourceId: String, note: String) {
|
|
|
|
|
try {
|
|
|
|
|
userPreferences.updateData {
|
|
|
|
|
it.copy { bookmarkNotes.put(newsResourceId, note) }
|
|
|
|
|
}
|
|
|
|
|
} catch (ioException: IOException) {
|
|
|
|
|
Log.e("NiaPreferences", "Failed to update bookmark note", ioException)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
suspend fun removeBookmarkNote(newsResourceId: String) {
|
|
|
|
|
try {
|
|
|
|
|
userPreferences.updateData {
|
|
|
|
|
it.copy { bookmarkNotes.remove(newsResourceId) }
|
|
|
|
|
}
|
|
|
|
|
} catch (ioException: IOException) {
|
|
|
|
|
Log.e("NiaPreferences", "Failed to remove bookmark note", ioException)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
suspend fun setNewsResourceViewed(newsResourceId: String, viewed: Boolean) {
|
|
|
|
|
setNewsResourcesViewed(listOf(newsResourceId), viewed)
|
|
|
|
|
}
|
|
|
|
|
|