-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clicking between top and new categories quickly causes the app to crash #2
Comments
Unfortunately I'm not being able to reproduce the issue, can you provide a screen recording and a crash report? Thanks a lot for opening the issue! |
|
@samcat116 I've never been able to reproduce this, but I did add some changes that I think might help the issue – can you check whether this is still a problem or not in the v0.1.0 release? Thanks in advance! |
I was able to reproduce this issue by jumping back and forth from the first and second item some 20 times or so. It's an index out of bounds error here:
|
Thanks for the hint, @NSMyself! Can you (or maybe @samcat116) check this build to check if the issue is fixed? Thanks! |
@goranmoomin I'm sorry but would it be possible to commit this code on a different branch? |
@NSMyself If you're building it yourself due to security concerns, this is the patch that you can apply to the code. diff --git a/HackerNews/Info.plist b/HackerNews/Info.plist
index e2a340e..63dd663 100644
--- a/HackerNews/Info.plist
+++ b/HackerNews/Info.plist
@@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>0.1.0</string>
<key>CFBundleVersion</key>
- <string>57</string>
+ <string>60</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSMainStoryboardFile</key>
diff --git a/HackerNews/ItemList/ItemListViewController.swift b/HackerNews/ItemList/ItemListViewController.swift
index e094c5a..1b847ed 100644
--- a/HackerNews/ItemList/ItemListViewController.swift
+++ b/HackerNews/ItemList/ItemListViewController.swift
@@ -13,9 +13,7 @@ class ItemListViewController: NSViewController {
var delegate: ItemListViewControllerDelegate?
- var items: [TopLevelItem] = [] {
- didSet { DispatchQueue.main.async { self.itemListTableView.reloadData() } }
- }
+ var items: [TopLevelItem] = [] { didSet { self.itemListTableView.reloadData() } }
var category: HNAPI.Category! { didSet { reloadData() } }
func reloadData() {
@@ -24,11 +22,12 @@ class ItemListViewController: NSViewController {
let category = category!
APIClient.shared.items(category: category) { result in
guard self.category == category else { return }
- DispatchQueue.main.async { self.spinner.stopAnimation(self) }
- switch result {
- case .success(let items): self.items = items
- case .failure(let error):
- DispatchQueue.main.async { NSApplication.shared.presentError(error) }
+ DispatchQueue.main.async {
+ self.spinner.stopAnimation(self)
+ switch result {
+ case .success(let items): self.items = items
+ case .failure(let error): NSApplication.shared.presentError(error)
+ }
}
}
}
@@ -49,8 +48,8 @@ class ItemListViewController: NSViewController {
items = []
spinner.startAnimation(self)
APIClient.shared.items(query: query) { result in
+ guard sender.stringValue == query else { return }
DispatchQueue.main.async {
- guard sender.stringValue == query else { return }
self.spinner.stopAnimation(self)
switch result {
case .success(let items): self.items = items Thanks. |
After launching the app, clicking between these two categories a couple of times causes the app to crash. This happens every time I open the app.
The text was updated successfully, but these errors were encountered: