mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-23 10:02:46 +02:00
67df1a3e95
Merge commit 'af0b6d4be985d9f26e5111d3fa01389c7321949f' into feature/7276_FOSS_Merge_1_27_11 # Conflicts: # Config/AppVersion.xcconfig # Gemfile.lock # IDETemplateMacros.plist # Podfile # Podfile.lock # README.md # Riot/Modules/Authentication/AuthenticationCoordinator.swift # Riot/Modules/Room/CellData/RoomBubbleCellData.m # Riot/target.yml # RiotNSE/NotificationService.swift # RiotSwiftUI/Modules/Authentication/ServerSelection/AuthenticationServerSelectionModels.swift # RiotSwiftUI/Modules/Authentication/ServerSelection/AuthenticationServerSelectionViewModel.swift # RiotSwiftUI/Modules/Authentication/ServerSelection/Coordinator/AuthenticationServerSelectionCoordinator.swift # RiotSwiftUI/Modules/Authentication/ServerSelection/View/AuthenticationServerSelectionScreen.swift # RiotSwiftUI/Modules/Room/CompletionSuggestion/Service/CompletionSuggestionService.swift # fastlane/Fastfile
77 lines
3.1 KiB
Swift
77 lines
3.1 KiB
Swift
//
|
|
// Copyright 2023, 2024 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
// Please see LICENSE files in the repository root for full details.
|
|
//
|
|
|
|
import Combine
|
|
|
|
final class MockPollHistoryService: PollHistoryServiceProtocol {
|
|
lazy var nextBatchPublishers: [AnyPublisher<TimelinePollDetails, Error>] = [
|
|
(activePollsData + pastPollsData)
|
|
.publisher
|
|
.setFailureType(to: Error.self)
|
|
.eraseToAnyPublisher()
|
|
]
|
|
|
|
func nextBatch() -> AnyPublisher<TimelinePollDetails, Error> {
|
|
nextBatchPublishers.isEmpty ? Empty().eraseToAnyPublisher() : nextBatchPublishers.removeFirst()
|
|
}
|
|
|
|
var updatesPublisher: AnyPublisher<TimelinePollDetails, Never> = Empty().eraseToAnyPublisher()
|
|
var updates: AnyPublisher<TimelinePollDetails, Never> {
|
|
updatesPublisher
|
|
}
|
|
|
|
var hasNextBatch = true
|
|
|
|
var fetchedUpToPublisher: AnyPublisher<Date, Never> = Just(.init()).eraseToAnyPublisher()
|
|
var fetchedUpTo: AnyPublisher<Date, Never> {
|
|
fetchedUpToPublisher
|
|
}
|
|
|
|
var livePollsPublisher: AnyPublisher<TimelinePollDetails, Never> = Empty().eraseToAnyPublisher()
|
|
var livePolls: AnyPublisher<TimelinePollDetails, Never> {
|
|
livePollsPublisher
|
|
}
|
|
}
|
|
|
|
private extension MockPollHistoryService {
|
|
var activePollsData: [TimelinePollDetails] {
|
|
(1...3)
|
|
.map { index in
|
|
TimelinePollDetails(id: "a\(index)",
|
|
question: "Do you like the active poll number \(index)?",
|
|
answerOptions: [],
|
|
closed: false,
|
|
startDate: .init().addingTimeInterval(TimeInterval(-index) * 3600 * 24),
|
|
totalAnswerCount: 30,
|
|
type: .disclosed,
|
|
showParticipants: false,
|
|
eventType: .started,
|
|
maxAllowedSelections: 1,
|
|
hasBeenEdited: false,
|
|
hasDecryptionError: false)
|
|
}
|
|
}
|
|
|
|
var pastPollsData: [TimelinePollDetails] {
|
|
(1...3)
|
|
.map { index in
|
|
TimelinePollDetails(id: "p\(index)",
|
|
question: "Do you like the active poll number \(index)?",
|
|
answerOptions: [.init(id: "id", text: "Yes, of course!", count: 20, winner: true, selected: true, voters: [])],
|
|
closed: true,
|
|
startDate: .init().addingTimeInterval(TimeInterval(-index) * 3600 * 24),
|
|
totalAnswerCount: 30,
|
|
type: .disclosed,
|
|
showParticipants: false,
|
|
eventType: .started,
|
|
maxAllowedSelections: 1,
|
|
hasBeenEdited: false,
|
|
hasDecryptionError: false)
|
|
}
|
|
}
|
|
}
|