Skip to content

Commit

Permalink
Guard snippet.content in Raw Actions
Browse files Browse the repository at this point in the history
- The snippet.content should already exist in this context, so we just guard it
and skip it, as there is no need to throw errors in these scenarios.
  • Loading branch information
Carlos Cabanero committed Jul 5, 2023
1 parent 4b94e0a commit 35e422c
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions Blink/Snippets/SearchModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,30 +173,26 @@ class SearchModel: ObservableObject {
}

func insertRawSnippet() {
guard let snippet = currentSelection
// The snippet should only be selectable if the content is already there,
// as it has already been part of a search and cached.
guard let snippet = currentSelection,
let content = try? snippet.content
else {
return
}
do {
let content = try snippet.content
sendContentToReceiver(content: content)
} catch {
// TODO show error
}

sendContentToReceiver(content: content)
}

func copyRawSnippet() {
guard let snippet = currentSelection
guard let snippet = currentSelection,
let content = try? snippet.content
else {
return
}
do {
let content = try snippet.content
UIPasteboard.general.string = content
self.close()
} catch {
// TODO show error
}

UIPasteboard.general.string = content
self.close()
}

func editSelectionOrCreate() {
Expand Down

0 comments on commit 35e422c

Please sign in to comment.