Skip to content

Commit

Permalink
Warn users when copying that some apps cannot handle pasting animated…
Browse files Browse the repository at this point in the history
… GIFs (#195)
  • Loading branch information
sindresorhus committed Jun 21, 2020
1 parent 4e7b4ff commit 648422e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Gifski/ConversionCompletedViewController.swift
Expand Up @@ -120,6 +120,21 @@ final class ConversionCompletedViewController: NSViewController {
self.copyButton.title = "Copied!"
self.copyButton.isEnabled = false

App.runOnce(identifier: "copyWarning") {
NSAlert.showModal(
for: self.copyButton.window,
message: "The GIF was copied to the clipboard.",
informativeText: "However…",
buttonTitles: ["Continue"]
)

NSAlert.showModal(
for: self.copyButton.window,
message: "Please read!",
informativeText: "Many apps like Chrome and Slack do not properly handle copied animated GIFs and will paste them as non-animated PNG.\n\nInstead, drag and drop the GIF into such apps."
)
}

delay(seconds: 1) { [weak self] in
guard let self = self else {
return
Expand Down
11 changes: 11 additions & 0 deletions Gifski/util.swift
Expand Up @@ -1495,6 +1495,17 @@ struct App {
}
}

extension App {
static func runOnce(identifier: String, _ execute: () -> Void) {
let key = "SS_App_runOnce__\(identifier)"

if !UserDefaults.standard.bool(forKey: key) {
UserDefaults.standard.set(true, forKey: key)
execute()
}
}
}


/// Convenience for opening URLs.
extension URL {
Expand Down

0 comments on commit 648422e

Please sign in to comment.