mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Make duplicate warning if changed to any bookmarks from NONE
This commit is contained in:
parent
e1141c3a45
commit
8694a13faf
2 changed files with 33 additions and 29 deletions
|
@ -55,10 +55,10 @@ import com.lagradost.cloudstream3.utils.Coroutines.ioWork
|
||||||
import com.lagradost.cloudstream3.utils.Coroutines.ioWorkSafe
|
import com.lagradost.cloudstream3.utils.Coroutines.ioWorkSafe
|
||||||
import com.lagradost.cloudstream3.utils.Coroutines.main
|
import com.lagradost.cloudstream3.utils.Coroutines.main
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.deleteBookmarkedData
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.deleteBookmarkedData
|
||||||
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.getAllBookmarkedData
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.getAllFavorites
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.getAllFavorites
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.getAllSubscriptions
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.getAllSubscriptions
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.getBookmarkedData
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.getBookmarkedData
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.getBookmarkedDataByWatchType
|
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.getDub
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.getDub
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.getFavoritesData
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.getFavoritesData
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.getLastWatched
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.getLastWatched
|
||||||
|
@ -837,12 +837,13 @@ class ResultViewModel2 : ViewModel() {
|
||||||
|
|
||||||
val currentStatus = getResultWatchState(currentId)
|
val currentStatus = getResultWatchState(currentId)
|
||||||
|
|
||||||
// If the status is not actually changing, set this to an empty
|
// If the current status is "NONE" and the new status is not "NONE",
|
||||||
// list so that we don't show the duplicate warning dialog, but we
|
// fetch the bookmarked data to check for duplicates, otherwise set this
|
||||||
// still want to refresh the data anyway
|
// to an empty list, so that we don't show the duplicate warning dialog,
|
||||||
val bookmarkedData = if (status == currentStatus) {
|
// but we still want to update the current bookmark and refresh the data anyway.
|
||||||
emptyList()
|
val bookmarkedData = if (currentStatus == WatchType.NONE && status != WatchType.NONE) {
|
||||||
} else getBookmarkedDataByWatchType(status)
|
getAllBookmarkedData()
|
||||||
|
} else emptyList()
|
||||||
|
|
||||||
checkAndWarnDuplicates(
|
checkAndWarnDuplicates(
|
||||||
context,
|
context,
|
||||||
|
@ -864,6 +865,10 @@ class ResultViewModel2 : ViewModel() {
|
||||||
|
|
||||||
setResultWatchState(currentId, status.internalId)
|
setResultWatchState(currentId, status.internalId)
|
||||||
|
|
||||||
|
// We don't need to store if WatchType.NONE.
|
||||||
|
// The key is removed in setResultWatchState, we don't want to
|
||||||
|
// re-add it again here if it was just removed.
|
||||||
|
if (status != WatchType.NONE) {
|
||||||
val current = getBookmarkedData(currentId)
|
val current = getBookmarkedData(currentId)
|
||||||
|
|
||||||
setBookmarkedData(
|
setBookmarkedData(
|
||||||
|
@ -881,8 +886,11 @@ class ResultViewModel2 : ViewModel() {
|
||||||
response.syncData
|
response.syncData
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentStatus != status) {
|
||||||
MainActivity.bookmarksUpdatedEvent(true)
|
MainActivity.bookmarksUpdatedEvent(true)
|
||||||
|
}
|
||||||
|
|
||||||
_watchStatus.postValue(status)
|
_watchStatus.postValue(status)
|
||||||
|
|
||||||
|
|
|
@ -589,14 +589,10 @@ object DataStoreHelper {
|
||||||
return getKey("$currentAccount/$RESULT_WATCH_STATE_DATA", id.toString())
|
return getKey("$currentAccount/$RESULT_WATCH_STATE_DATA", id.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getBookmarkedDataByWatchType(watchType: WatchType): List<BookmarkedData> {
|
fun getAllBookmarkedData(): List<BookmarkedData> {
|
||||||
val allBookmarkedData: List<BookmarkedData> =
|
return getKeys("$currentAccount/$RESULT_WATCH_STATE_DATA")?.mapNotNull {
|
||||||
getKeys("$currentAccount/$RESULT_WATCH_STATE_DATA")?.mapNotNull {
|
|
||||||
getKey(it)
|
getKey(it)
|
||||||
} ?: emptyList()
|
} ?: emptyList()
|
||||||
|
|
||||||
return allBookmarkedData
|
|
||||||
.filter { getResultWatchState(it.id ?: return emptyList()) == watchType }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAllSubscriptions(): List<SubscribedData> {
|
fun getAllSubscriptions(): List<SubscribedData> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue