fix(delete): name the delete target and verify what its files back

"Delete from server" read identically for an episode, a season and a
whole show: same menu label, same dialog title, same red button, and a
body that named nothing. The menu header did not disambiguate either,
because MediaItem.displayTitle collapses an episode to its show name.
A reporter deleted a whole series from the detail hero's ⋮ believing it
acted on the episode he had highlighted, and the confirmation gave him
nothing to catch it with. Every one of those strings now names the kind,
and the body names the exact item — show, season and episode number, and
episode title.

Deleting a single item also destroyed files the confirmation never
mentioned: a Plex multi-episode file (S01E01-E03.mkv) takes its other
episodes with it, and a split item takes every part. The dialog now
reports that up front and, on success, emits deletion events for the
siblings the server destroyed so their rows do not linger.

The scope behind that warning is only asserted when it is established.
MediaItem.allPartFiles drops parts with no path, so a non-empty set
proves nothing about the ones it filtered out; a version is trusted only
when every part reports a file. A browse row that omits paths is missing
evidence rather than proof of a distinct file, so both the target and
each candidate sibling fall back to the detail endpoint before any
conclusion — otherwise a thin row, including the file-less part
PlexMappers fabricates for an empty payload, would look like a server
that withholds paths. When the answer cannot be established the dialog
says so in an error-tinted block and its button reads "Delete anyway",
separating a transient probe failure from a server that never sends
paths. It deliberately does not refuse: Plex withholds paths from
restricted users the server itself authorizes to delete, so failing
closed would take the feature away from them permanently.

Probing a season stays bounded in both directions. Siblings resolve one
at a time, so a season of thin rows cannot fan out a detail request per
episode, and expiry cancels the walk rather than merely abandoning it —
`Future.timeout` completes the future the caller awaits but leaves the
work behind it running, which would resume on the next sibling once the
outstanding request answered. A cooperative flag is checked before each
lookup, so at most the one already in flight outlives the deadline; the
neutral client exposes no abort handle for item lookups, so that one
cannot be recalled.

The spinner covering the probe was only barrierDismissible, which does
not stop system back. Back dismissed it and the cleanup pop then closed
the screen underneath, dropping the user out of the detail page
mid-flow. It now traps back, matching the non-dismissible contract its
own doc claims, which also repairs the log uploader and the file-info
sheet.

Coverage splits by what each layer owns. The dialog, its copy and the
DELETE wiring are backend-neutral and stay in the menu widget tests.
Plex — the backend multi-episode files actually come from — gets the
resolver over a real PlexClient and a mocked transport: a row with no
media at all, scope recovered from /library/metadata/{id}, siblings and
paths from /children, a Part that names no file, a sibling whose path
never resolves, the request count a sixty-episode thin season may cost,
and the rating key the DELETE carries. Those are plain async tests
because the Plex metadata cache is a real database whose I/O the widget
tester's fake clock never drives. Deadline behaviour needs the opposite,
so it is pinned separately under fakeAsync against a gated fake client,
with no wall-clock waiting anywhere.

close #1781
This commit is contained in:
edde746
2026-08-06 03:45:08 +02:00
parent 9d51a040c3
commit 1b6a811c07
52 changed files with 2278 additions and 259 deletions
+4 -8
View File
@@ -547,8 +547,6 @@ class _Translations$mediaMenu$zh_Hant extends Translations$mediaMenu$zh {
@override String get shufflePlay => '隨機播放';
@override String get shuffleNotAvailableOffline => '離線時無法隨機播放';
@override String get fileInfo => '檔案資訊';
@override String get deleteFromServer => '從伺服器刪除';
@override String get confirmDelete => '確定要從伺服器刪除此媒體及其檔案嗎?';
@override String get deleteMultipleWarning => '這將會刪除所有單集及其檔案。';
@override String get mediaDeletedSuccessfully => '媒體已成功刪除';
@override String get mediaFailedToDelete => '刪除媒體失敗';
@@ -2581,8 +2579,6 @@ extension on TranslationsZhHant {
'mediaMenu.shufflePlay' => '隨機播放',
'mediaMenu.shuffleNotAvailableOffline' => '離線時無法隨機播放',
'mediaMenu.fileInfo' => '檔案資訊',
'mediaMenu.deleteFromServer' => '從伺服器刪除',
'mediaMenu.confirmDelete' => '確定要從伺服器刪除此媒體及其檔案嗎?',
'mediaMenu.deleteMultipleWarning' => '這將會刪除所有單集及其檔案。',
'mediaMenu.mediaDeletedSuccessfully' => '媒體已成功刪除',
'mediaMenu.mediaFailedToDelete' => '刪除媒體失敗',
@@ -2701,10 +2697,10 @@ extension on TranslationsZhHant {
'videoControls.language' => '語言',
'videoControls.noSubtitlesFound' => '找不到字幕',
'videoControls.subtitleDownloaded' => '字幕下載成功',
_ => null,
} ?? switch (path) {
'videoControls.subtitleDownloadedNotApplied' => '字幕已下載,但無法套用',
'videoControls.subtitleDownloadFailed' => '字幕下載失敗',
_ => null,
} ?? switch (path) {
'videoControls.searchLanguages' => '搜尋語言…',
'messages.markedAsWatched' => '已標記為已觀看',
'messages.markedAsUnwatched' => '已標記為未觀看',
@@ -3215,10 +3211,10 @@ extension on TranslationsZhHant {
'watchTogether.failedToJoin' => '加入工作階段失敗',
'watchTogether.sessionCodeCopied' => '工作階段代碼已複製到剪貼簿',
'watchTogether.relayUnreachable' => '無法連線至中繼伺服器。ISP 封鎖可能會導致「一起看」無法使用。',
_ => null,
} ?? switch (path) {
'watchTogether.reconnectingToHost' => '正在重新連線至主持人…',
'watchTogether.currentPlayback' => '目前播放內容',
_ => null,
} ?? switch (path) {
'watchTogether.joinCurrentPlayback' => '加入目前播放點',
'watchTogether.joinCurrentPlaybackDescription' => '同步至主持人目前的觀看進度',
'watchTogether.failedToOpenCurrentPlayback' => '無法開啟目前播放點',