From a4f0eeadecc3bad5016c7dac8658a127e26ec237 Mon Sep 17 00:00:00 2001 From: Charlie Fish Date: Sat, 27 Jan 2024 13:43:34 -0700 Subject: [PATCH] mute: don't mutate string when adding hashtag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently there is an issue where if you try to mute a hashtag, it will mutate the `new_text` variable. This patch fixes that so that we aren’t mutating `new_text`. Lighting-address: fishcharlie@strike.me Signed-off-by: Charlie Fish Reviewed-by: William Casarin Signed-off-by: William Casarin --- damus/Views/Muting/AddMuteItemView.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/damus/Views/Muting/AddMuteItemView.swift b/damus/Views/Muting/AddMuteItemView.swift index 73a058d7..428611da 100644 --- a/damus/Views/Muting/AddMuteItemView.swift +++ b/damus/Views/Muting/AddMuteItemView.swift @@ -65,8 +65,7 @@ struct AddMuteItemView: View { } } else if new_text.starts(with: "#") { // Remove the starting `#` character - new_text.removeFirst() - return .hashtag(Hashtag(hashtag: new_text), expiration_date) + return .hashtag(Hashtag(hashtag: String("\(new_text)".dropFirst())), expiration_date) } else { return .word(new_text, expiration_date) }