Skip to content

Commit

Permalink
fix: reset for ios
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed Dec 16, 2021
1 parent 7f202cc commit 62b7d23
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions ios/Plugin/CapacitorUpdater.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ extension URL {
}

@objc public func reset() {
UserDefaults.standard.set("", forKey: "lastPathHot")
UserDefaults.standard.set("", forKey: "lastPathPersist")
UserDefaults.standard.set("capacitor://localhost", forKey: "lastPathHot")
UserDefaults.standard.set("capacitor://localhost", forKey: "lastPathPersist")
}
}
10 changes: 3 additions & 7 deletions ios/Plugin/CapacitorUpdaterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
let pathHot = implementation.getLastPathHot()
let pathPersist = implementation.getLastPathPersist()
if (pathHot != "" && pathPersist != "") {
if (defaults.string(forKey: "serverBasePathOriginal") == nil) {
defaults.set(vc.getServerBasePath(), forKey: "serverBasePathOriginal")
}
defaults.set(String(pathPersist.suffix(10)), forKey: "serverBasePath")
vc.setServerBasePath(path: pathHot)
return call.resolve()
Expand Down Expand Up @@ -72,11 +69,10 @@ public class CapacitorUpdaterPlugin: CAPPlugin {

if let vc = bridge.viewController as? CAPBridgeViewController {
let defaults = UserDefaults.standard
let serverBasePathOriginal = defaults.string(forKey: "serverBasePathOriginal") ?? ""
print("RESET", serverBasePathOriginal, implementation.getLastPathHot())
implementation.reset()
vc.setServerBasePath(path: serverBasePathOriginal)
defaults.set(serverBasePathOriginal, forKey: "serverBasePath")
let pathPersist = implementation.getLastPathPersist()
vc.setServerBasePath(path: pathPersist)
defaults.set(pathPersist, forKey: "serverBasePath")
DispatchQueue.main.async {
bridge.webView?.reload()
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "capacitor-updater",
"version": "1.0.21",
"version": "1.0.22",
"license": "AGPL-3.0-only",
"description": "Download app update from url",
"main": "dist/plugin.cjs.js",
Expand Down

0 comments on commit 62b7d23

Please sign in to comment.