Skip to content

Commit

Permalink
completion calls on main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
cplepage committed Feb 22, 2024
1 parent 167f5f8 commit 969685b
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 14 deletions.
24 changes: 20 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions platform/electron/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.cache
.env
out
esbuild
*.tgz
Expand Down
13 changes: 12 additions & 1 deletion platform/electron/forge.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require('dotenv').config();

module.exports = {
packagerConfig: {
icon: "icons/icon",
Expand All @@ -6,7 +8,16 @@ module.exports = {
],
extraResource: [
"../../Demo.zip"
]
],
osxSign: {
identity: process.env.APPLE_ID
},
osxNotarize: {
tool: 'notarytool',
appleApiKey: process.env.APPLE_API_KEY,
appleApiKeyId: process.env.APPLE_API_KEY_ID,
appleApiIssuer: process.env.APPLE_API_ISSUER
}
},
rebuildConfig: {},
makers: [
Expand Down
1 change: 1 addition & 0 deletions platform/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@electron-forge/maker-zip": "^7.2.0",
"@electron-forge/plugin-auto-unpack-natives": "^7.2.0",
"@types/tar": "^6.1.11",
"dotenv": "^16.4.5",
"electron": "28.2.3",
"esbuild": "^0.20.0",
"tar": "^6.2.0"
Expand Down
8 changes: 4 additions & 4 deletions platform/ios/xcode/FullStacked.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 6;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"FullStacked/Preview Content\"";
DEVELOPMENT_TEAM = QD7Y9DQ5V4;
ENABLE_PREVIEWS = YES;
Expand All @@ -332,7 +332,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.0;
MARKETING_VERSION = 0.1.0;
PRODUCT_BUNDLE_IDENTIFIER = editor.FullStacked;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -348,7 +348,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 6;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"FullStacked/Preview Content\"";
DEVELOPMENT_TEAM = QD7Y9DQ5V4;
ENABLE_PREVIEWS = YES;
Expand All @@ -368,7 +368,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.0;
MARKETING_VERSION = 0.1.0;
PRODUCT_BUNDLE_IDENTIFIER = editor.FullStacked;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
8 changes: 5 additions & 3 deletions platform/ios/xcode/FullStacked/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,11 @@ class RequestHandler: NSObject, WKURLSchemeHandler {
: nil
)!

urlSchemeTask.didReceive(response)
urlSchemeTask.didReceive(responseBody == nil ? Data() : responseBody!)
urlSchemeTask.didFinish()
DispatchQueue.main.async {
urlSchemeTask.didReceive(response)
urlSchemeTask.didReceive(responseBody == nil ? Data() : responseBody!)
urlSchemeTask.didFinish()
}
}
)
}
Expand Down
15 changes: 13 additions & 2 deletions platform/ios/xcode/FullStacked/JavaScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,16 @@ class JavaScript {
}

let task = URLSession.shared.dataTask(with: request) { data, response, error in
if error != nil {
self.logFn("[\"Fetch Error for \(urlStr)\"]")
onCompletion.call(withArguments: [[:], ""])
return
}

let headers = (response as! HTTPURLResponse).allHeaderFields as! [String: String]
onCompletion.call(withArguments: [headers, Array(data!)])
DispatchQueue.main.async {
onCompletion.call(withArguments: [headers, Array(data!)])
}
}
task.resume()
}
Expand Down Expand Up @@ -182,9 +190,12 @@ class JavaScript {
onCompletion.call(withArguments: [[:], ""])
return
}

let headers = (response as! HTTPURLResponse).allHeaderFields as! [String: String]
let body = String(data: data!, encoding: .utf8)!
onCompletion.call(withArguments: [headers, body])
DispatchQueue.main.async {
onCompletion.call(withArguments: [headers, body])
}
}
task.resume()
}
Expand Down

0 comments on commit 969685b

Please sign in to comment.