Fixes/improves showing delete button (#1353)

## Description
Fixes the delete button not showing on the movie detail page. Also fixes
some edge cases where button may not appear when toggling on the media
management setting.

Adds the delete button to album & artist pages. Previously, it was only
in the context menu.

### Related issues
Fixes #1343

### Testing
Emulator

## Screenshots
N/A

## AI or LLM usage
None
This commit is contained in:
Damontecres 2026-05-06 11:49:27 -04:00 • committed by GitHub
parent 461bad1ddd
commit 8107a82a6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 65 additions and 25 deletions

View file

@ -6,12 +6,15 @@ import androidx.lifecycle.viewModelScope
import com.github.damontecres.wholphin.data.ServerRepository
import com.github.damontecres.wholphin.data.model.BaseItem
import com.github.damontecres.wholphin.preferences.AppPreferences
import com.github.damontecres.wholphin.ui.combinePair
import com.github.damontecres.wholphin.ui.launchIO
import com.github.damontecres.wholphin.ui.showToast
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.collectLatest
import org.jellyfin.sdk.api.client.ApiClient
import org.jellyfin.sdk.api.client.extensions.libraryApi
import org.jellyfin.sdk.model.api.BaseItemKind
@ -68,6 +71,16 @@ class MediaManagementService
}
}
suspend fun collectCanDelete(
itemFlow: Flow<BaseItem?>,
update: (Boolean) -> Unit,
) {
itemFlow.combinePair(userPreferencesService.flow).collectLatest { (item, prefs) ->
val canDelete = item?.let { canDelete(item, prefs.appPreferences) } ?: false
update.invoke(canDelete)
}
}
/**
* Delete the item.
*