Skip to content

Commit

Permalink
Migrate private session link from legacy ios app
Browse files Browse the repository at this point in the history
  • Loading branch information
workwithnano committed Dec 17, 2023
1 parent 171fdb8 commit 1b45a42
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion MainConfig.xcconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
MARKETING_VERSION = 2.0.0
CURRENT_PROJECT_VERSION = 12 // this needs to be increased with each version change as well (not set to 1 when version is updated)
CURRENT_PROJECT_VERSION = 13 // this needs to be increased with each version change as well (not set to 1 when version is updated)
15 changes: 15 additions & 0 deletions Shared (Extension)/Resources/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,21 @@ browser.action.onClicked.addListener((tab) => {
});
});

browser.runtime.onInstalled.addListener(function(details){
if (!(details.previousVersion.startsWith("1") == true && browser.runtime.getManifest().version.startsWith("2") == true)) {
return
}

browser.storage.local.get("privateSessionLink", function(value) {
var privateSessionLink = value.privateSessionLink;
if (typeof(privateSessionLink) !== "undefined") {
browser.runtime.sendNativeMessage(extensionId, {"type": "migratePrivateSessionLink", "privateSessionLink": privateSessionLink}, function(response){
// no-op
});
}
});
});

// Checks every 5 seconds for a new engine. There's no other way to get new
// info from the app without forcing Safari to come to the foreground
(function loop() {
Expand Down
5 changes: 5 additions & 0 deletions Shared (Extension)/SafariWebExtensionHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ class SafariWebExtensionHandler: ResponderObject, NSExtensionRequestHandling {
responseData["errorMessage"] = "Kagi app not found"
}
break
case "migratePrivateSessionLink":
if let previousPrivateSessionLink = messageDict["privateSessionLink"] as? String {
Preferences.shared.setPrivateSessionLink(previousPrivateSessionLink, profile: nil)
}
break
default:
break
}
Expand Down

0 comments on commit 1b45a42

Please sign in to comment.