Skip to content

Commit

Permalink
- Fixes 2 space indents #1747
Browse files Browse the repository at this point in the history
- Fixes usaved data on preview toggle
- Fixes related to iOS codebase
  • Loading branch information
glushchenko committed Aug 16, 2024
1 parent 5dbac0a commit f9a69c1
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 31 deletions.
2 changes: 1 addition & 1 deletion FSNotes iOS/View/NotesTableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ class NotesTableView: UITableView,
let lockUnlockImage = UIImage(systemName: lockUnlockImageName)
actions.append(UIAction(title: lockUnlockTitle, image: lockUnlockImage, identifier: UIAction.Identifier("lockUnlock"), handler: handler))

if note.isEncrypted() {
if note.isEncrypted() && !note.project.isEncrypted {
let removeEncryptionTitle = NSLocalizedString("Remove Encryption", comment: "")
let removeEncryptionImage = UIImage(systemName: "lock.slash")
actions.append(UIAction(title: removeEncryptionTitle, image: removeEncryptionImage, identifier: UIAction.Identifier("removeEncryption"), handler: handler))
Expand Down
16 changes: 8 additions & 8 deletions FSNotes iOS/ViewController+More.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ extension ViewController: UIDocumentPickerDelegate {
case .Inbox:
popoverActions = [.importNote, .settingsFolder, .createFolder, .multipleSelection, .openInFiles, .settingsRepository]
case .All, .Todo:
popoverActions = [.settingsFolder, .multipleSelection]
popoverActions = [.settingsFolder, .createFolder, .multipleSelection]
case .Trash:
popoverActions = [.settingsFolder, .multipleSelection, .openInFiles, .emptyBin]
case .Project:
popoverActions = [.importNote, .settingsFolder, .createFolder, .removeFolder, .renameFolder, .multipleSelection, .openInFiles, .settingsRepository, .encryptFolder]
case .Tag:
popoverActions = [.removeTag, .renameTag, .multipleSelection]
case .Untagged:
popoverActions = [.multipleSelection]
popoverActions = [.createFolder, .multipleSelection]
case .ProjectEncryptedLocked:
popoverActions = [.unLockFolder, .decryptFolder, .settingsFolder, .removeFolder, .renameFolder, .multipleSelection, .openInFiles, .settingsRepository]
case .ProjectEncryptedUnlocked:
Expand Down Expand Up @@ -589,7 +589,11 @@ extension ViewController: UIDocumentPickerDelegate {
}

private func createFolder(selectedProject: Project?) {
guard let selectedProject = selectedProject else { return }
guard var selectedProject = selectedProject else { return }

if selectedProject.isVirtual {
selectedProject = self.storage.getDefault()!
}

let mvc = UIApplication.getVC()
let alertController = UIAlertController(title: NSLocalizedString("Create folder:", comment: ""), message: nil, preferredStyle: .alert)
Expand Down Expand Up @@ -804,8 +808,6 @@ extension ViewController: UIDocumentPickerDelegate {
private func openInFiles(selectedProject: Project?) {
guard let selectedProject = selectedProject else { return }

let mvc = UIApplication.getVC()

guard let path = selectedProject.url.path.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlPathAllowed) else { return }

if let projectUrl = URL(string: "shareddocuments://" + path) {
Expand All @@ -816,13 +818,11 @@ extension ViewController: UIDocumentPickerDelegate {
private func openGitSettings(selectedProject: Project?) {
guard let selectedProject = selectedProject else { return }

let vc = UIApplication.getVC()
let storage = Storage.shared()
let projectController = AppDelegate.getGitVC(for: selectedProject)
let controller = UINavigationController(rootViewController: projectController)

self.dismiss(animated: true, completion: nil)
vc.present(controller, animated: true, completion: nil)
UIApplication.getVC().present(controller, animated: true, completion: nil)
}

private func emptyBin() {
Expand Down
4 changes: 3 additions & 1 deletion FSNotes iOS/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ViewController: UIViewController, UISearchBarDelegate, UIGestureRecognizer

// Project for import picker
public var selectedProject: Project?
private var initialLoadingState = false
public var initialLoadingState = false

override func viewWillAppear(_ animated: Bool) {
configureSearchController()
Expand Down Expand Up @@ -1480,6 +1480,8 @@ class ViewController: UIViewController, UISearchBarDelegate, UIGestureRecognizer

storage = Storage.shared()
sidebarTableView.reloadSidebar()

initialLoadingState = false
viewDidLoad()
}

Expand Down
8 changes: 4 additions & 4 deletions FSNotes.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4588,7 +4588,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 638;
CURRENT_PROJECT_VERSION = 639;
DEVELOPMENT_TEAM = 866P6MTE92;
EMBED_ASSET_PACKS_IN_PRODUCT_BUNDLE = YES;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -4605,7 +4605,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 6.9.2;
MARKETING_VERSION = 6.9.3;
OTHER_SWIFT_FLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = co.fluder.FSNotes;
PRODUCT_NAME = FSNotes;
Expand All @@ -4628,7 +4628,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 638;
CURRENT_PROJECT_VERSION = 639;
DEPLOYMENT_LOCATION = NO;
DEVELOPMENT_TEAM = 866P6MTE92;
EMBED_ASSET_PACKS_IN_PRODUCT_BUNDLE = YES;
Expand All @@ -4646,7 +4646,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 6.9.2;
MARKETING_VERSION = 6.9.3;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = co.fluder.FSNotes;
PRODUCT_NAME = FSNotes;
Expand Down
3 changes: 2 additions & 1 deletion FSNotes/Business/Note.swift
Original file line number Diff line number Diff line change
Expand Up @@ -913,11 +913,12 @@ public class Note: NSObject {
}

public func save(attributed: NSAttributedString) {
let copy = attributed.copy() as? NSAttributedString
modifiedLocalAt = Date()

let operation = BlockOperation()
operation.addExecutionBlock({
if let copy = attributed.copy() as? NSAttributedString {
if let copy = copy {
let mutable = NSMutableAttributedString(attributedString: copy)
self.save(content: mutable)

Expand Down
1 change: 0 additions & 1 deletion FSNotes/Business/Storage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class Storage {
public var shouldMovePrompt = false

private var trashURL = URL(string: String())
private var archiveURL = URL(string: String())

private let lastNewsDate = "2023-05-25"
public var isCrashedLastTime = false
Expand Down
15 changes: 8 additions & 7 deletions FSNotes/Helpers/FileSystemEventManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -246,19 +246,20 @@ class FileSystemEventManager {
return
}

guard var fsContent = note.getContent() else { return }

// Trying load content from encrypted note with current password
if note.url.pathExtension == "etp", let password = note.password, note.unLock(password: password) {
fsContent = note.content
}

guard let modificationDate = note.getFileModifiedDate(),
let creationDate = note.getFileCreationDate() else { return }

if modificationDate.isGreaterThan(note.modifiedLocalAt) {
note.modifiedLocalAt = modificationDate
note.cacheHash = nil

guard var fsContent = note.getContent() else { return }

// Trying load content from encrypted note with current password
if note.url.pathExtension == "etp", let password = note.password, note.unLock(password: password) {
fsContent = note.content
}

note.content = NSMutableAttributedString(attributedString: fsContent)

// tags changes
Expand Down
8 changes: 2 additions & 6 deletions FSNotes/View/MPreviewView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ class MPreviewView: WKWebView, WKUIDelegate, WKNavigationDelegate {
if note.container == .encryptedTextPack && !note.isUnlocked() {
evc.unLock(notes: [note])
} else if note.content.length == 0 {
evc.vcEditor?.disablePreviewEditorAndNote()

evc.refillEditArea()
evc.disablePreview()
evc.focusEditArea()
}
}
Expand All @@ -93,9 +91,7 @@ class MPreviewView: WKWebView, WKUIDelegate, WKNavigationDelegate {
if event.keyCode == kVK_Return {
DispatchQueue.main.async {
if let evc = self.editorVC {
evc.vcEditor?.disablePreviewEditorAndNote()

evc.refillEditArea()
evc.disablePreview()
evc.focusEditArea()
}
}
Expand Down
2 changes: 0 additions & 2 deletions FSNotes/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -872,8 +872,6 @@ class ViewController: EditorViewController,
refillEditArea()
}



@IBAction func noteUp(_ sender: NSMenuItem) {
NSApp.mainWindow?.makeFirstResponder(notesTableView)

Expand Down
1 change: 1 addition & 0 deletions FSNotesCore/Shared/NSTextStorage++.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ extension NSTextStorage {
value.count > 1,

value.starts(with: " ")
|| value.starts(with: " ")
|| value.starts(with: "\t")
|| value.starts(with: "* ")
|| value.starts(with: "- ")
Expand Down

0 comments on commit f9a69c1

Please sign in to comment.