1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-12-23 05:16:58 +00:00

do not mark as seen more than once

This commit is contained in:
Austin Huang 2021-07-08 20:40:59 -04:00
parent c82080acf4
commit 525cf37907
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F

View File

@ -473,7 +473,9 @@ class StoryFragmentViewModel : ViewModel() {
fun markAsSeen(storyMedia: StoryMedia): LiveData<Resource<Story?>> {
val data = MutableLiveData<Resource<Story?>>()
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 {
storiesRepository.seen(
csrfToken!!,
@ -483,7 +485,6 @@ class StoryFragmentViewModel : ViewModel() {
storyMedia.takenAt,
System.currentTimeMillis() / 1000
)
val oldStory = currentStory.value!!
val newStory = oldStory.copy(seen = storyMedia.takenAt)
data.postValue(success(newStory))
} catch (e: Exception) {