From 525cf379073076486ca5e1c91f539e683ec6b853 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Thu, 8 Jul 2021 20:40:59 -0400 Subject: [PATCH] do not mark as seen more than once --- .../awais/instagrabber/viewmodels/StoryFragmentViewModel.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/viewmodels/StoryFragmentViewModel.kt b/app/src/main/java/awais/instagrabber/viewmodels/StoryFragmentViewModel.kt index 8979705e..00717239 100644 --- a/app/src/main/java/awais/instagrabber/viewmodels/StoryFragmentViewModel.kt +++ b/app/src/main/java/awais/instagrabber/viewmodels/StoryFragmentViewModel.kt @@ -473,7 +473,9 @@ class StoryFragmentViewModel : ViewModel() { fun markAsSeen(storyMedia: StoryMedia): LiveData> { val data = MutableLiveData>() 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) {