Skip to content

Commit 88d33a5

Browse files
tomerdneonichuyim-lee
authored
Apply suggestions from code review
Co-authored-by: Boris Bügling <[email protected]> Co-authored-by: Yim Lee <[email protected]>
1 parent 986f88b commit 88d33a5

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Sources/PackageCollections/Model/Collection.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ extension PackageCollectionsModel {
7777

7878
/// URL of the source file
7979
public let url: URL
80+
81+
public init(type: PackageCollectionsModel.CollectionSourceType = .feed, url: URL) {
82+
self.type = type
83+
self.url = url
84+
}
8085
}
8186

8287
/// Represents the source type of a `PackageCollection`

Sources/PackageCollections/PackageCollections+Storage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extension PackageCollections.Storage {
2929
}
3030
}
3131

32-
if let closabe = self.collections as? Closable {
32+
if let closable = self.collections as? Closable {
3333
do {
3434
try closabe.close()
3535
} catch {

Sources/PackageCollections/PackageCollections.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ internal struct PackageCollections: PackageCollectionsProtocol {
4141
if identifiers.isEmpty {
4242
return callback(.success([]))
4343
}
44-
let groupOrder = identifiers.enumerated().reduce([PackageCollectionsModel.CollectionIdentifier: Int]()) { partial, element in
45-
var map = partial
44+
let collectionOrder = identifiers.enumerated().reduce([PackageCollectionsModel.CollectionIdentifier: Int]()) { partial, element in
45+
var dictionary = partial
4646
map[element.element] = element.offset
4747
return map
4848
}
@@ -51,7 +51,7 @@ internal struct PackageCollections: PackageCollectionsProtocol {
5151
case .failure(let error):
5252
callback(.failure(error))
5353
case .success(var groups):
54-
// re-order by storage order which reflects the user's election
54+
// re-order by profile order which reflects the user's election
5555
groups.sort(by: { lhs, rhs in groupOrder[lhs.identifier] ?? 0 < groupOrder[rhs.identifier] ?? 0 })
5656
callback(.success(groups))
5757
}
@@ -176,7 +176,7 @@ internal struct PackageCollections: PackageCollectionsProtocol {
176176
return callback(.failure(UnknownProvider(source.type)))
177177
}
178178
provider.get(source, callback: callback)
179-
case .success(let group):
179+
case .success(let collection):
180180
callback(.success(group))
181181
}
182182
}

0 commit comments

Comments
 (0)