This commit is contained in:
Marek
2026-04-05 22:20:51 +02:00
parent a67e1393d7
commit 375169f496
9 changed files with 40 additions and 1 deletions

View File

@@ -15,6 +15,9 @@ interface VideoApi {
@POST("videos/{id}/download")
suspend fun triggerDownload(@Path("id") id: Int): Map<String, String>
@retrofit2.http.DELETE("videos")
suspend fun deleteNotDownloaded(@Query("profile_id") profileId: Int): Map<String, Int>
@GET("profiles")
suspend fun getProfiles(): List<Profile>
}

View File

@@ -13,6 +13,11 @@ class VideoRepository(private val api: VideoApi = ApiClient.api) {
response["status"] ?: "unknown"
}
suspend fun deleteNotDownloaded(profileId: Int): Result<Int> = runCatching {
val response = api.deleteNotDownloaded(profileId)
response["deleted"] ?: 0
}
suspend fun getProfiles(): Result<List<Profile>> = runCatching { api.getProfiles() }
fun getStreamUrl(videoId: Int): String = "${ApiClient.BASE_URL}videos/$videoId/stream"

View File

@@ -2,6 +2,7 @@ package com.youtubeapp.ui.navigation
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.DeleteSweep
import androidx.compose.material.icons.filled.Download
import androidx.compose.material.icons.filled.Person
import androidx.compose.material.icons.filled.VideoLibrary
@@ -64,6 +65,9 @@ fun AppNavigation() {
TopAppBar(
title = { Text("YouTube App") },
actions = {
IconButton(onClick = { viewModel.deleteNotDownloaded() }) {
Icon(Icons.Default.DeleteSweep, contentDescription = "Aufraeumen")
}
IconButton(onClick = { showProfileMenu = true }) {
Icon(Icons.Default.Person, contentDescription = "Profil")
}

View File

@@ -126,6 +126,14 @@ class VideoViewModel : ViewModel() {
}
}
fun deleteNotDownloaded() {
val profileId = _state.value.selectedProfileId ?: return
viewModelScope.launch {
repository.deleteNotDownloaded(profileId)
loadAllVideos()
}
}
fun deleteLocalVideo(videoId: Int) {
localStorage?.deleteLocalFile(videoId)
_state.value = _state.value.copy(downloadStatus = "Lokal gelöscht")