Skip to content

Commit 6932007

Browse files
committed
Rename To shared, Test Inserted Order
1 parent 9f60f95 commit 6932007

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

CodeEdit/Features/Documents/Controllers/CodeEditDocumentController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ final class CodeEditDocumentController: NSDocumentController {
7171
print("Unable to open document '\(url)': \(errorMessage)")
7272
}
7373

74-
RecentProjectsStore.default.documentOpened(at: url)
74+
RecentProjectsStore.shared.documentOpened(at: url)
7575
completionHandler(document, documentWasAlreadyOpen, error)
7676
}
7777
}

CodeEdit/Features/Welcome/Model/RecentProjectsStore.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import CoreSpotlight
1616
/// ``RecentProjectsStore/didUpdateNotification`` notification.
1717
class RecentProjectsStore {
1818
/// The default projects store, uses the `UserDefaults.standard` storage location.
19-
static let `default` = RecentProjectsStore()
19+
static let shared = RecentProjectsStore()
2020

2121
private static let projectsdDefaultsKey = "recentProjectPaths"
2222
static let didUpdateNotification = Notification.Name("RecentProjectsStore.didUpdate")

CodeEdit/Features/Welcome/Views/RecentProjectsListView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ struct RecentProjectsListView: View {
1919
init(openDocument: @escaping (URL?, @escaping () -> Void) -> Void, dismissWindow: @escaping () -> Void) {
2020
self.openDocument = openDocument
2121
self.dismissWindow = dismissWindow
22-
self._recentProjects = .init(initialValue: RecentProjectsStore.default.recentURLs())
23-
self._selection = .init(initialValue: Set(RecentProjectsStore.default.recentURLs().prefix(1)))
22+
self._recentProjects = .init(initialValue: RecentProjectsStore.shared.recentURLs())
23+
self._selection = .init(initialValue: Set(RecentProjectsStore.shared.recentURLs().prefix(1)))
2424
}
2525

2626
var listEmptyView: some View {
@@ -91,10 +91,10 @@ struct RecentProjectsListView: View {
9191
}
9292

9393
func removeRecentProjects() {
94-
recentProjects = RecentProjectsStore.default.removeRecentProjects(selection)
94+
recentProjects = RecentProjectsStore.shared.removeRecentProjects(selection)
9595
}
9696

9797
func updateRecentProjects() {
98-
recentProjects = RecentProjectsStore.default.recentURLs()
98+
recentProjects = RecentProjectsStore.shared.recentURLs()
9999
}
100100
}

CodeEditTests/Features/Welcome/RecentProjectsTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ class RecentProjectsTests {
3232
store.documentOpened(at: URL(filePath: "Directory/file.txt", directoryHint: .notDirectory))
3333

3434
#expect(store.recentURLs().count == 2)
35+
#expect(store.recentURLs()[0].path(percentEncoded: false) == "Directory/")
36+
#expect(store.recentURLs()[1].path(percentEncoded: false) == "Directory/file.txt")
3537
}
3638

3739
@Test
3840
func maxesOutAt100Items() {
39-
for idx in 0..<200 {
41+
for idx in 0..<101 {
4042
store.documentOpened(
4143
at: URL(
4244
filePath: "file\(idx).txt",

0 commit comments

Comments
 (0)