From 814948cdd46091739b7c975bf86f129ba32c8ca5 Mon Sep 17 00:00:00 2001 From: glushchenko Date: Mon, 17 Jun 2024 18:00:28 +0300 Subject: [PATCH] - Fixes and improvements --- FSNotes/Business/Note.swift | 19 +++++++++++++------ FSNotes/Business/Storage.swift | 1 + FSNotes/View/TitleTextField.swift | 4 ++-- FSNotesCore/Shared/Extensions/String+.swift | 4 ++-- FSNotesCore/Shared/NameHelper.swift | 4 ++-- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/FSNotes/Business/Note.swift b/FSNotes/Business/Note.swift index bfeba6b53..a9d86236c 100644 --- a/FSNotes/Business/Note.swift +++ b/FSNotes/Business/Note.swift @@ -359,8 +359,8 @@ public class Note: NSObject { func getNewURL(name: String) -> URL { let escapedName = name - .replacingOccurrences(of: ":", with: "-") - .replacingOccurrences(of: "/", with: ":") + .replacingOccurrences(of: ":", with: "") + .replacingOccurrences(of: "/", with: "") var newUrl = url.deletingLastPathComponent() newUrl.appendPathComponent(escapedName + "." + url.pathExtension) @@ -866,12 +866,15 @@ public class Note: NSObject { .deletingPathExtension() .pathComponents .last! - .replacingOccurrences(of: ":", with: "/") + .replacingOccurrences(of: ":", with: "") + .replacingOccurrences(of: "/", with: "") } } private func loadFileName() { - fileName = url.deletingPathExtension().lastPathComponent.replacingOccurrences(of: ":", with: "/") + fileName = url.deletingPathExtension().lastPathComponent + .replacingOccurrences(of: ":", with: "") + .replacingOccurrences(of: "/", with: "") } public func getFileName() -> String { @@ -1144,7 +1147,9 @@ public class Note: NSObject { } func getTitleWithoutLabel() -> String { - let title = url.deletingPathExtension().pathComponents.last!.replacingOccurrences(of: ":", with: "/") + let title = url.deletingPathExtension().pathComponents.last! + .replacingOccurrences(of: ":", with: "") + .replacingOccurrences(of: "/", with: "") if title.isValidUUID { return "" @@ -1513,7 +1518,9 @@ public class Note: NSObject { } private func loadTitleFromFileName() { - let fileName = url.deletingPathExtension().pathComponents.last!.replacingOccurrences(of: ":", with: "/") + let fileName = url.deletingPathExtension().pathComponents.last! + .replacingOccurrences(of: ":", with: "") + .replacingOccurrences(of: "/", with: "") self.title = fileName diff --git a/FSNotes/Business/Storage.swift b/FSNotes/Business/Storage.swift index 411b69ed9..41e9d7d26 100644 --- a/FSNotes/Business/Storage.swift +++ b/FSNotes/Business/Storage.swift @@ -87,6 +87,7 @@ class Storage { #endif checkWelcome() + loadNotesCloudPins() plainWriter.maxConcurrentOperationCount = 1 plainWriter.qualityOfService = .userInteractive diff --git a/FSNotes/View/TitleTextField.swift b/FSNotes/View/TitleTextField.swift index 636d71a7f..5ebf6198c 100644 --- a/FSNotes/View/TitleTextField.swift +++ b/FSNotes/View/TitleTextField.swift @@ -71,8 +71,8 @@ class TitleTextField: NSTextField { let fileName = currentTitle .trimmingCharacters(in: CharacterSet.whitespaces) - .replacingOccurrences(of: ":", with: "-") - .replacingOccurrences(of: "/", with: ":") + .replacingOccurrences(of: ":", with: "") + .replacingOccurrences(of: "/", with: "") let dst = note.project.url .appendingPathComponent(fileName) diff --git a/FSNotesCore/Shared/Extensions/String+.swift b/FSNotesCore/Shared/Extensions/String+.swift index 45adffced..4a1998b5d 100644 --- a/FSNotesCore/Shared/Extensions/String+.swift +++ b/FSNotesCore/Shared/Extensions/String+.swift @@ -136,8 +136,8 @@ public extension String { func trunc(length: Int) -> String { let result = self - .replacingOccurrences(of: ":", with: "-") - .replacingOccurrences(of: "/", with: ":") + .replacingOccurrences(of: ":", with: "") + .replacingOccurrences(of: "/", with: "") return (result.count > length) ? String(result.prefix(length)) : result } diff --git a/FSNotesCore/Shared/NameHelper.swift b/FSNotesCore/Shared/NameHelper.swift index da35e49c9..660dfe054 100644 --- a/FSNotesCore/Shared/NameHelper.swift +++ b/FSNotesCore/Shared/NameHelper.swift @@ -19,8 +19,8 @@ class NameHelper { var postfix = postfix var name = name .trimmingCharacters(in: CharacterSet.whitespaces) - .replacingOccurrences(of: ":", with: "-") - .replacingOccurrences(of: "/", with: ":") + .replacingOccurrences(of: ":", with: "") + .replacingOccurrences(of: "/", with: "") if name.isEmpty { name = defaultName