mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 06:37:30 +00:00
do not mark as seen more than once
This commit is contained in:
parent
c82080acf4
commit
525cf37907
@ -473,7 +473,9 @@ class StoryFragmentViewModel : ViewModel() {
|
|||||||
fun markAsSeen(storyMedia: StoryMedia): LiveData<Resource<Story?>> {
|
fun markAsSeen(storyMedia: StoryMedia): LiveData<Resource<Story?>> {
|
||||||
val data = MutableLiveData<Resource<Story?>>()
|
val data = MutableLiveData<Resource<Story?>>()
|
||||||
data.postValue(loading(null))
|
data.postValue(loading(null))
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
val oldStory = currentStory.value!!
|
||||||
|
if (oldStory.seen != null && oldStory.seen >= storyMedia.takenAt) data.postValue(success(null))
|
||||||
|
else viewModelScope.launch(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
storiesRepository.seen(
|
storiesRepository.seen(
|
||||||
csrfToken!!,
|
csrfToken!!,
|
||||||
@ -483,7 +485,6 @@ class StoryFragmentViewModel : ViewModel() {
|
|||||||
storyMedia.takenAt,
|
storyMedia.takenAt,
|
||||||
System.currentTimeMillis() / 1000
|
System.currentTimeMillis() / 1000
|
||||||
)
|
)
|
||||||
val oldStory = currentStory.value!!
|
|
||||||
val newStory = oldStory.copy(seen = storyMedia.takenAt)
|
val newStory = oldStory.copy(seen = storyMedia.takenAt)
|
||||||
data.postValue(success(newStory))
|
data.postValue(success(newStory))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
Loading…
Reference in New Issue
Block a user