Support source filter editing

The API for filter is undocumented on the Selfoss API reference, but does exist. We can now allow users setting and modifying filters inside the application.
This commit is contained in:
davidoskky committed 2025-04-12 23:58:12 +02:00
1 parent ceba58e98f
commit b1259fdc92
6 files changed
+34 -7

No files matched your search

@@ -102,6 +102,7 @@ class SelfossModel {
override var error: String? = null,
override var icon: String? = null,
var params: SourceParams? = null,
var filter: String? = null,
) : Source
@Serializable
@@ -368,6 +368,7 @@ class Repository(
url: String,
spout: String,
tags: String,
filter: String,
): Boolean {
var response = false
if (connectivityService.isNetworkAvailable()) {
@@ -377,6 +378,7 @@ class Repository(
url,
spout,
tags,
filter,
).isSuccess == true
}
@@ -389,10 +391,11 @@ class Repository(
url: String,
spout: String,
tags: String,
filter: String,
): Boolean {
var response = false
if (connectivityService.isNetworkAvailable()) {
response = api.updateSourceForVersion(id, title, url, spout, tags).isSuccess == true
response = api.updateSourceForVersion(id, title, url, spout, tags, filter).isSuccess == true
}
return response
@@ -638,12 +638,13 @@ class SelfossApi(
url: String,
spout: String,
tags: String,
filter: String,
): SuccessResponse =
maybeResponse(
if (appSettingsService.getApiVersion() > 1) {
createSource("tags[]", title, url, spout, tags)
createSource("tags[]", title, url, spout, tags, filter)
} else {
createSource("tags", title, url, spout, tags)
createSource("tags", title, url, spout, tags, filter)
},
)
@@ -653,6 +654,7 @@ class SelfossApi(
url: String,
spout: String,
tags: String,
filter: String,
): HttpResponse? =
client.tryToSubmitForm(
url = url("/source"),
@@ -665,6 +667,7 @@ class SelfossApi(
append("title", title)
append("url", url)
append("spout", spout)
append("filter", filter)
append(tagsParamName, tags)
},
block = {
@@ -694,12 +697,13 @@ class SelfossApi(
url: String,
spout: String,
tags: String,
filter: String,
): SuccessResponse =
maybeResponse(
if (appSettingsService.getApiVersion() > 1) {
updateSource(id, "tags[]", title, url, spout, tags)
updateSource(id, "tags[]", title, url, spout, tags, filter)
} else {
updateSource(id, "tags", title, url, spout, tags)
updateSource(id, "tags", title, url, spout, tags, filter)
},
)
@@ -710,6 +714,7 @@ class SelfossApi(
url: String,
spout: String,
tags: String,
filter: String,
): HttpResponse? =
client.tryToSubmitForm(
url = url("/source/$id"),
@@ -723,6 +728,7 @@ class SelfossApi(
append("url", url)
append("spout", spout)
append(tagsParamName, tags)
append("filter", filter)
},
block = {
if (appSettingsService