From aa42551c7c74bf661cd2ab74ada5ac3cc3e8faed Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sat, 26 Mar 2022 13:50:01 +0100 Subject: [PATCH] Fix #81 --- Shared/Favorites/DropFavorite.swift | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Shared/Favorites/DropFavorite.swift b/Shared/Favorites/DropFavorite.swift index 568b2343..31b237ba 100644 --- a/Shared/Favorites/DropFavorite.swift +++ b/Shared/Favorites/DropFavorite.swift @@ -11,10 +11,18 @@ struct DropFavorite: DropDelegate { return } - let from = favorites.firstIndex(of: current!)! - let to = favorites.firstIndex(of: item)! + guard let current = current else { + return + } - guard favorites[to].id != current!.id else { + let from = favorites.firstIndex(of: current) + let to = favorites.firstIndex(of: item) + + guard let from = from, let to = to else { + return + } + + guard favorites[to].id != current.id else { return }