Skip to content

Commit

Permalink
- Fixes some crashes related to git history
Browse files Browse the repository at this point in the history
  • Loading branch information
glushchenko committed Jan 31, 2023
1 parent 3adf372 commit 04c37e8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 28 deletions.
16 changes: 8 additions & 8 deletions FSNotes.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4842,7 +4842,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 558;
CURRENT_PROJECT_VERSION = 559;
DEVELOPMENT_TEAM = 866P6MTE92;
EMBED_ASSET_PACKS_IN_PRODUCT_BUNDLE = YES;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -4859,7 +4859,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 6.1.2;
MARKETING_VERSION = 6.1.3;
PRODUCT_BUNDLE_IDENTIFIER = co.fluder.FSNotes;
PRODUCT_NAME = FSNotes;
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -4881,7 +4881,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 558;
CURRENT_PROJECT_VERSION = 559;
DEPLOYMENT_LOCATION = NO;
DEVELOPMENT_TEAM = 866P6MTE92;
EMBED_ASSET_PACKS_IN_PRODUCT_BUNDLE = YES;
Expand All @@ -4899,7 +4899,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 6.1.2;
MARKETING_VERSION = 6.1.3;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = co.fluder.FSNotes;
PRODUCT_NAME = FSNotes;
Expand Down Expand Up @@ -5242,7 +5242,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 558;
CURRENT_PROJECT_VERSION = 559;
DEVELOPMENT_TEAM = 866P6MTE92;
EMBED_ASSET_PACKS_IN_PRODUCT_BUNDLE = YES;
ENABLE_NS_ASSERTIONS = NO;
Expand All @@ -5258,7 +5258,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 6.1.2;
MARKETING_VERSION = 6.1.3;
OTHER_SWIFT_FLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = co.fluder.FSNotes;
PRODUCT_NAME = FSNotes;
Expand All @@ -5280,7 +5280,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 558;
CURRENT_PROJECT_VERSION = 559;
DEPLOYMENT_LOCATION = NO;
DEVELOPMENT_TEAM = 866P6MTE92;
EMBED_ASSET_PACKS_IN_PRODUCT_BUNDLE = YES;
Expand All @@ -5297,7 +5297,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 6.1.2;
MARKETING_VERSION = 6.1.3;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = co.fluder.FSNotes;
PRODUCT_NAME = FSNotes;
Expand Down
6 changes: 2 additions & 4 deletions FSNotes/ViewController+Git.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,16 @@ extension EditorViewController {
}

@IBAction private func pull(_ sender: Any) {
guard let vc = ViewController.shared() else { return }

let storage = Storage.sharedInstance()
let projects = storage.getProjects()

// Skip on high load
if vc.gitQueue.operationCount > 5 {
if let qty = ViewController.shared()?.gitQueue.operationCount, qty > 5 {
print("Pull skipped")
return
}

vc.gitQueue.addOperation({
ViewController.shared()?.gitQueue.addOperation({
for project in projects {
if project.isTrash {
continue
Expand Down
30 changes: 14 additions & 16 deletions FSNotes/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1975,27 +1975,25 @@ class ViewController: EditorViewController,

guard notes.count == 0x01 else { return }

DispatchQueue.global().async {
DispatchQueue.main.async {
do {
if let repository = try note.project.getRepository() {
let commits = self.getCommits(from: repository, by: note)

DispatchQueue.main.async {
guard commits.count > 0 else {
historyMenu?.isEnabled = false
return
}

for commit in commits {
let menuItem = NSMenuItem()
menuItem.title = commit.getDate()
menuItem.representedObject = commit
menuItem.action = #selector(vc.checkoutRevision(_:))
historyMenu?.submenu?.addItem(menuItem)
}

historyMenu?.isEnabled = true
guard commits.count > 0 else {
historyMenu?.isEnabled = false
return
}

for commit in commits {
let menuItem = NSMenuItem()
menuItem.title = commit.getDate()
menuItem.representedObject = commit
menuItem.action = #selector(vc.checkoutRevision(_:))
historyMenu?.submenu?.addItem(menuItem)
}

historyMenu?.isEnabled = true
}
} catch {
print(error)
Expand Down

0 comments on commit 04c37e8

Please sign in to comment.