Skip to content

Commit

Permalink
fix: conform pagemap extension to sequence protocol (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhayab authored Jul 26, 2024
1 parent 1430cf9 commit a921ecb
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 17 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
6 changes: 3 additions & 3 deletions .github/workflows/pods.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ jobs:
- uses: actions/checkout@v2
- name: Select Xcode version
run: sudo xcode-select -s '/Applications/Xcode_14.2.app/Contents/Developer'
- name: lint Insights
- name: lint Core
run: pod lib lint --subspec="Core" --allow-warnings
lint-UI:
runs-on: macos-12
steps:
- uses: actions/checkout@v2
- name: Select Xcode version
run: sudo xcode-select -s '/Applications/Xcode_14.2.app/Contents/Developer'
- name: lint Insights
- name: lint UI
run: pod lib lint --subspec="UI" --allow-warnings
lint-SwiftUI:
runs-on: macos-12
steps:
- uses: actions/checkout@v2
- name: Select Xcode version
run: sudo xcode-select -s '/Applications/Xcode_14.2.app/Contents/Developer'
- name: lint Insights
- name: lint SwiftUI
run: pod lib lint --subspec="SwiftUI" --allow-warnings
17 changes: 14 additions & 3 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@ jobs:
env:
ALGOLIA_APPLICATION_ID_1: ${{ secrets.ALGOLIA_APPLICATION_ID_1 }}
ALGOLIA_ADMIN_KEY_1: ${{ secrets.ALGOLIA_ADMIN_KEY_1 }}
ALGOLIA_PLACES_APPLICATION_ID: ${{ secrets.ALGOLIA_PLACES_APPLICATION_ID }}
ALGOLIA_PLACES_API_KEY: ${{ secrets.ALGOLIA_PLACES_API_KEY }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Select Xcode version
run: sudo xcode-select -s '/Applications/Xcode_14.2.app/Contents/Developer'
- name: Build project
run: swift build
- name: Run tests
run: swift test
test-xcode-16:
runs-on: macos-14
env:
ALGOLIA_APPLICATION_ID_1: ${{ secrets.ALGOLIA_APPLICATION_ID_1 }}
ALGOLIA_ADMIN_KEY_1: ${{ secrets.ALGOLIA_ADMIN_KEY_1 }}
steps:
- uses: actions/checkout@v4
- name: Select Xcode version
run: sudo xcode-select -s '/Applications/Xcode_16.0.app/Contents/Developer'
- name: Build project
run: swift build
- name: Run tests
run: swift test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## OS X Finder
.DS_Store

## Environment variables
.env

## Build generated
build/
DerivedData
Expand Down
1 change: 1 addition & 0 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github "apple/swift-log" ~> 1.4
github "algolia/algoliasearch-client-swift" ~> 8.18
github "apple/swift-protobuf" == 1.20.0
github "algolia/instantsearch-telemetry-native" ~> 0.1.3
1 change: 1 addition & 0 deletions InstantSearch.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Pod::Spec.new do |s|
ss.dependency 'AlgoliaSearchClient', '~> 8.18'
ss.dependency 'Logging'
ss.dependency 'InstantSearch/Insights'
ss.dependency 'SwiftProtobuf', '1.20.0'
ss.dependency 'InstantSearchTelemetry', '~> 0.1.3'
ss.ios.deployment_target = '14.0'
ss.osx.deployment_target = '11.0'
Expand Down
4 changes: 3 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ let package = Package(
from: "8.18.2"),
.package(url: "https://github.com/apple/swift-log",
from: "1.5.4"),
.package(url: "https://github.com/apple/swift-protobuf",
.exact("1.20.0")),
.package(name: "InstantSearchTelemetry",
url: "https://github.com/algolia/instantsearch-telemetry-native",
from: "0.1.3")
.exact("0.1.3"))
],
targets: [
.target(
Expand Down
5 changes: 3 additions & 2 deletions Sources/InstantSearchCore/Pagination/PageMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ struct PageMap<Item> {
// MARK: SequenceType

extension PageMap: Sequence {
public func makeIterator() -> IndexingIterator<PageMap> {
return IndexingIterator(_elements: self)
public func makeIterator() -> IndexingIterator<[Item?]> {
let elements = (self.startIndex..<self.endIndex).map { self[$0] }
return IndexingIterator(_elements: elements)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public class MultiIndexSearcher: Searcher, SequencerDelegate, SearchResultObserv
processingQueue.maxConcurrentOperationCount = 1
processingQueue.qualityOfService = .userInitiated

pageLoaders = indexQueryStates.enumerated().map { [weak self] index, _ in
pageLoaders = indexQueryStates.indices.map { [weak self] index in
return PageLoaderProxy(setPage: { self?.indexQueryStates[index].query.page = $0 }, launchSearch: { self?.search() })
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public extension SortByConnector {
controller: Controller,
presenter: @escaping IndexNamePresenter = DefaultPresenter.IndexName.present) where Controller.SegmentKey == Int {
let enumeratedIndices = indicesNames
.enumerated()
.map { $0 }
.indices
.map { ($0, indicesNames[$0]) }
let items = [Int: IndexName](uniqueKeysWithValues: enumeratedIndices)
let interactor = SortByInteractor(items: items)
interactor.selected = selected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class SortByConnector {

set {
let enumeratedIndices = newValue
.enumerated()
.map { $0 }
.indices
.map { ($0, newValue[$0]) }
interactor.items = [Int: IndexName](uniqueKeysWithValues: enumeratedIndices)
}
}
Expand Down Expand Up @@ -76,8 +76,8 @@ public class SortByConnector {
indicesNames: [IndexName],
selected: Int? = nil) {
let enumeratedIndices = indicesNames
.enumerated()
.map { $0 }
.indices
.map { ($0, indicesNames[0]) }
let items = [Int: IndexName](uniqueKeysWithValues: enumeratedIndices)
let interactor = SortByInteractor(items: items)
interactor.selected = selected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ class DecodingErrorPrettyPrinterTests: XCTestCase {
return
}
let prettyPrinter = DecodingErrorPrettyPrinter(decodingError: decodingError)
XCTAssertEqual(prettyPrinter.description, "Decoding error: 'age': Expected Int value but found null instead.")
XCTAssertTrue(
prettyPrinter.description
== "Decoding error: 'age': Expected Int value but found null instead."
|| prettyPrinter.description
== "Decoding error: 'age': Cannot get unkeyed decoding container -- found null value instead"
)
}
}

Expand Down

0 comments on commit a921ecb

Please sign in to comment.