Fix a crash opening Search when a video is in history under several sources

watchEntriesMap() built its dictionary with uniqueKeysWithValues, but the
same video ID can be recorded under more than one source scope, which
trapped on the duplicate key (3 crash logs from build 270, all in
SearchView.loadWatchEntries). Keep the most recent entry instead.

The subscription metadata map in Manage Channels had the same shape (a
channel subscribed under several account scopes), as did the server
history hydration map; both now tolerate duplicates.
This commit is contained in:
Arkadiusz Fal
2026-10-14 09:24:56 +02:00
parent fd6a97ce5c
commit e5cea1b6c8
3 changed files with 9 additions and 4 deletions

View File

@@ -263,8 +263,10 @@ struct ManageChannelsView: View {
if let syncChannels = subscriptionService?.fetchSubscriptionsSync() {
channels = syncChannels
}
// A channel can be subscribed under several account scopes.
subscriptionMetadata = Dictionary(
uniqueKeysWithValues: (dataManager?.subscriptions() ?? []).map { ($0.channelID, $0) }
(dataManager?.subscriptions() ?? []).map { ($0.channelID, $0) },
uniquingKeysWith: { first, _ in first }
)
}
.task {