CutBox.app

Coverage Report

Created: 2024-03-12 03:40

.../Source/App/Preferences/PreferencesAdvancedView+ClearHistory.swift
Line
Count
Source
1
//
2
//  PreferencesAdvancedView+ClearHistory.swift
3
//  CutBox
4
//
5
//  Created by Jason Milkins on 15/8/23.
6
//  Copyright © 2023 ocodo. All rights reserved.
7
//
8
9
import RxCocoa
10
import RxSwift
11
12
extension PreferencesAdvancedView {
13
50
    func setupClearHistoryControls() {
14
50
        clearHistoryDropDown.removeAllItems()
15
350
        clearHistoryDropDown.addItems(withTitles: clearHistoryOptions.map { $0.title })
16
50
        clearHistoryActionButton.title = "preferences_history_clear_history_button".l7n
17
50
        clearHistoryActionButton.rx.tap
18
50
            .bind(onNext: clearHistoryActionClicked)
$s15CutBoxUnitTests23PreferencesAdvancedViewC25setupClearHistoryControlsyyFyycACcfu_
Line
Count
Source
18
50
            .bind(onNext: clearHistoryActionClicked)
Unexecuted instantiation: $s15CutBoxUnitTests23PreferencesAdvancedViewC25setupClearHistoryControlsyyFyycACcfu_yycfu0_
19
50
            .disposed(by: disposeBag)
20
50
    }
21
22
1
    func clearHistoryActionClicked() {
23
1
        let selectedIndex = self.clearHistoryDropDown.indexOfSelectedItem
24
1
        if let offset = self.clearHistoryOptions[selectedIndex].offset {
25
1
            if dialogFactory.suppressibleConfirmationDialog(
26
1
                messageText: "\(clearHistoryOptions[selectedIndex].title.l7n)?",
27
1
                informativeText: "confirm_warning_clear_history".l7n,
28
1
                dialogName: .clearHistoryActionClicked) {
29
1
                prefs.events.onNext(.historyClearByOffset(offset: offset))
30
1
            }
31
1
        }
32
1
    }
33
}