Skip to content

Commit 7adf5c1

Browse files
committed
Remove debug logging from live chat polling
1 parent 9eb7172 commit 7adf5c1

1 file changed

Lines changed: 1 addition & 18 deletions

File tree

app/src/main/java/org/schabi/newpipe/viewmodels/CommentsViewModel.kt

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.schabi.newpipe.viewmodels
22

3-
import android.util.Log
43
import androidx.lifecycle.SavedStateHandle
54
import androidx.lifecycle.ViewModel
65
import androidx.lifecycle.viewModelScope
@@ -31,23 +30,12 @@ import org.schabi.newpipe.util.KEY_URL
3130
import org.schabi.newpipe.viewmodels.util.Resource
3231

3332
class CommentsViewModel(savedStateHandle: SavedStateHandle) : ViewModel() {
34-
companion object {
35-
private const val TAG = "CommentsViewModel"
36-
}
37-
3833
val uiState = savedStateHandle.getStateFlow(KEY_URL, "")
3934
.map {
4035
try {
4136
val info = CommentsInfo.getInfo(it)
42-
Log.i(
43-
TAG,
44-
"Loaded CommentsInfo: disabled=${info.isCommentsDisabled}, " +
45-
"liveChat=${info.isLiveChat}, items=${info.relatedItems.size}, " +
46-
"nextPage=${info.nextPage != null}"
47-
)
4837
Resource.Success(CommentInfo(info))
4938
} catch (e: Exception) {
50-
Log.e(TAG, "Failed to load comments", e)
5139
Resource.Error(e)
5240
}
5341
}
@@ -63,7 +51,6 @@ class CommentsViewModel(savedStateHandle: SavedStateHandle) : ViewModel() {
6351
.filterIsInstance<Resource.Success<CommentInfo>>()
6452
.flatMapLatest {
6553
val info = it.data
66-
Log.i(TAG, "flatMapLatest: isLiveChat=${info.isLiveChat}, items=${info.comments.size}")
6754
if (info.isLiveChat) {
6855
_liveChatItems.value = info.comments
6956
startLiveChatPolling(info)
@@ -79,29 +66,25 @@ class CommentsViewModel(savedStateHandle: SavedStateHandle) : ViewModel() {
7966

8067
private fun startLiveChatPolling(info: CommentInfo) {
8168
var nextPage = info.nextPage
82-
Log.i(TAG, "startLiveChatPolling() items=${info.comments.size}, nextPage=${nextPage != null}")
8369

8470
viewModelScope.launch(Dispatchers.IO) {
8571
while (isActive) {
8672
delay(3000)
8773
if (nextPage == null) {
88-
Log.d(TAG, "liveChatPolling: nextPage is null, skipping")
8974
continue
9075
}
9176
try {
92-
Log.d(TAG, "liveChatPolling: fetching more items...")
9377
val result = CommentsInfo.getMoreItems(
9478
NewPipe.getService(info.serviceId),
9579
info.url,
9680
nextPage
9781
)
98-
Log.i(TAG, "liveChatPolling: fetched ${result.items.size} items, nextPage=${result.nextPage != null}")
9982
if (result.items.isNotEmpty()) {
10083
_liveChatItems.value = result.items + _liveChatItems.value
10184
}
10285
nextPage = result.nextPage
10386
} catch (e: Exception) {
104-
Log.e(TAG, "liveChatPolling: failed to fetch more items", e)
87+
// Silently ignore polling errors
10588
}
10689
}
10790
}

0 commit comments

Comments
 (0)