Skip to content

Commit

Permalink
- Fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
glushchenko committed Jun 17, 2024
1 parent e2e36f2 commit 814948c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
19 changes: 13 additions & 6 deletions FSNotes/Business/Note.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 ""
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions FSNotes/Business/Storage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class Storage {
#endif

checkWelcome()
loadNotesCloudPins()

plainWriter.maxConcurrentOperationCount = 1
plainWriter.qualityOfService = .userInteractive
Expand Down
4 changes: 2 additions & 2 deletions FSNotes/View/TitleTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions FSNotesCore/Shared/Extensions/String+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions FSNotesCore/Shared/NameHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 814948c

Please sign in to comment.