Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions Localization/Localizations/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -6522,13 +6522,12 @@
}
}
},
"Rule name already exists." : {
"extractionState" : "stale",
"Rule name already exists" : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "ルール名はすでに存在します"
"value" : "ルール名はすでに存在します\n"
}
},
"zh-Hans" : {
Expand All @@ -6546,15 +6545,11 @@
}
},
"Rule name cannot be empty" : {

},
"Rule name cannot be empty." : {
"extractionState" : "stale",
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "ルール名は空にできません"
"value" : "ルール名は空欄にできません"
}
},
"zh-Hans" : {
Expand Down
2 changes: 1 addition & 1 deletion qBitControl/Models/RSSFeed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import Foundation

struct RSSFeed: Decodable, Identifiable {
var id: UUID { UUID() }
var id: String { url ?? UUID().uuidString }
let url: String?
let uid: String?
let isLoading: Bool?
Expand Down
16 changes: 10 additions & 6 deletions qBitControl/Models/RSSRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ struct RSSRule: Codable {
}

class RSSRuleModel: ObservableObject, Identifiable {
struct RSSMatchItem: Identifiable {
let id = UUID()
var type: String
var title: String
}

let id = UUID()
var title: String = ""
@Published var rule: RSSRule
Expand All @@ -82,6 +88,10 @@ class RSSRuleModel: ObservableObject, Identifiable {
self.rule = rule
}

static func defauleAddRule() -> RSSRuleModel {
RSSRuleModel(title: "", rule: .defaultAdd)
}

func getArticlesMatching() {
guard !isLoading else { return }
isLoading = true
Expand All @@ -97,9 +107,3 @@ class RSSRuleModel: ObservableObject, Identifiable {
}
}
}

struct RSSMatchItem: Identifiable {
let id = UUID()
var type: String
var title: String
}
6 changes: 3 additions & 3 deletions qBitControl/ViewModels/RSSView/RSSRulesViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ class RSSRulesViewModel: ObservableObject {
guard !isLoading else { return }
isLoading = true
Task {
_ = await qBittorrent.removeRSSRule(name: name)
let success = await qBittorrent.removeRSSRule(name: name)
await MainActor.run {
isLoading = false
if let index = rssRules.firstIndex(where: { $0.title == name }) {
rssRules.remove(at: index)
if success {
rssRules.removeAll { $0.title == name }
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions qBitControl/Views/RSSViews/RSSRuleDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,15 @@ struct RSSRuleDetailView: View {
}

private func saveRule() {
guard validateName() else { return }
if isAdd, !validateName(){ return }
rule.rule.affectedFeeds = Array(selectedFeedURLs)
viewModel.setRSSRule(rule) { success in
if success {
guard success else { return }
viewModel.getRssRules()
if isAdd {
dismiss()
} else {
rule.getArticlesMatching()
viewModel.getRssRules()
if isAdd { dismiss() }
}
}
}
Expand Down
9 changes: 2 additions & 7 deletions qBitControl/Views/RSSViews/RSSRulesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ struct RSSRulesView: View {
rule.rule.enabled
}, set: {
rule.rule.enabled = $0
}))
.onChange(of: rule.rule.enabled) { _ in
viewModel.setRSSRule(rule)
}
}))
}.contextMenu {
ruleItemMenu(name: rule.title)
}
Expand All @@ -47,10 +45,7 @@ struct RSSRulesView: View {
content: {
NavigationView {
RSSRuleDetailView(
rule: RSSRuleModel(
title: "",
rule: .defaultAdd
),
rule: .defauleAddRule(),
isAdd: true
)
}
Expand Down