Use /sources/stats in the home #133
@ -63,8 +63,79 @@ class SelfossModel {
|
||||
fun isPublicModeEnabled() = publicMode ?: false
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class Source(
|
||||
AmineB marked this conversation as resolved
|
||||
val id: Int,
|
||||
val title: String,
|
||||
var unread: Int?,
|
||||
var tags: List<String>?,
|
||||
var spout: String?,
|
||||
var error: String?,
|
||||
var icon: String?,
|
||||
var params: SourceParams?
|
||||
AmineB marked this conversation as resolved
AmineB
commented
I don't understand why this is needed ? I don't understand why this is needed ?
|
||||
) {
|
||||
|
||||
constructor(sourceDetail: SourceDetail) : this(
|
||||
AmineB marked this conversation as resolved
AmineB
commented
This should be an extension function This should be an extension function `fun SourceDetail.toSource(): Source`
AmineB
commented
Ignore this. Ignore this.
|
||||
id = sourceDetail.id,
|
||||
AmineB marked this conversation as resolved
AmineB
commented
This should be an "abstract" method. This should be an "abstract" method.
|
||||
title = sourceDetail.title,
|
||||
unread = null,
|
||||
tags = sourceDetail.tags,
|
||||
spout = sourceDetail.spout,
|
||||
error = sourceDetail.error,
|
||||
icon = sourceDetail.icon,
|
||||
params = sourceDetail.params
|
||||
AmineB marked this conversation as resolved
AmineB
commented
This should not be here. This should not be here.
|
||||
)
|
||||
|
||||
AmineB marked this conversation as resolved
AmineB
commented
This should not be here. This should not be here.
|
||||
constructor(sourceStat: SourceStats) : this(
|
||||
AmineB marked this conversation as resolved
AmineB
commented
This should be an extension function This should be an extension function `fun SourceStats.toSource(): Source`
AmineB
commented
Ignore this. Ignore this.
|
||||
id = sourceStat.id,
|
||||
title = sourceStat.title,
|
||||
unread = sourceStat.unread,
|
||||
AmineB marked this conversation as resolved
AmineB
commented
What are these two methods ? What are these two methods ?
|
||||
tags = null,
|
||||
spout = null,
|
||||
error = null,
|
||||
icon = null,
|
||||
params = null
|
||||
)
|
||||
|
||||
fun update(sourceStat: SourceStats) {
|
||||
if (this.id != sourceStat.id || this.title != sourceStat.title) {
|
||||
throw Exception()
|
||||
}
|
||||
this.unread = sourceStat.unread
|
||||
}
|
||||
|
||||
fun update(sourceDetail: SourceDetail) {
|
||||
if (this.id != sourceDetail.id || this.title != sourceDetail.title) {
|
||||
throw Exception()
|
||||
}
|
||||
this.tags = sourceDetail.tags
|
||||
this.spout = sourceDetail.spout
|
||||
AmineB marked this conversation as resolved
AmineB
commented
`SourceStats` class should not contain `SourceDetail` update.
|
||||
this.error = sourceDetail.error
|
||||
this.icon = sourceDetail.icon
|
||||
this.params = sourceDetail.params
|
||||
}
|
||||
|
||||
fun update(source: Source) {
|
||||
if (this.id != source.id || this.title != source.title) {
|
||||
throw Exception()
|
||||
}
|
||||
this.unread = source.unread
|
||||
this.tags = source.tags
|
||||
this.spout = source.spout
|
||||
this.error = source.error
|
||||
this.icon = source.icon
|
||||
this.params = source.params
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class SourceStats(
|
||||
val id: Int,
|
||||
val title: String,
|
||||
val unread: Int
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class SourceDetail(
|
||||
val id: Int,
|
||||
val title: String,
|
||||
@Serializable(with = TagsListSerializer::class)
|
||||
|
@ -16,7 +16,8 @@ fun SOURCE.toView(): SelfossModel.Source =
|
||||
SelfossModel.Source(
|
||||
this.id.toInt(),
|
||||
this.title,
|
||||
this.tags.split(","),
|
||||
this.unread?.toInt(),
|
||||
this.tags?.split(","),
|
||||
this.spout,
|
||||
this.error,
|
||||
this.icon,
|
||||
@ -27,7 +28,8 @@ fun SelfossModel.Source.toEntity(): SOURCE =
|
||||
SOURCE(
|
||||
this.id.toString(),
|
||||
this.title.getHtmlDecoded(),
|
||||
this.tags.joinToString(","),
|
||||
this.unread?.toLong(),
|
||||
this.tags?.joinToString(","),
|
||||
this.spout,
|
||||
this.error,
|
||||
this.icon.orEmpty(),
|
||||
|
@ -0,0 +1 @@
|
||||
ALTER TABLE SOURCE ADD COLUMN `unread` INTEGER;
|
||||
AmineB marked this conversation as resolved
AmineB
commented
As As `unread` is only in the public mode, let's not change this.
|
@ -1,10 +1,11 @@
|
||||
CREATE TABLE SOURCE (
|
||||
`id` TEXT NOT NULL,
|
||||
`title` TEXT NOT NULL,
|
||||
`tags` TEXT NOT NULL,
|
||||
`spout` TEXT NOT NULL,
|
||||
`error` TEXT NOT NULL,
|
||||
`icon` TEXT NOT NULL,
|
||||
`unread` INTEGER,
|
||||
AmineB marked this conversation as resolved
AmineB
commented
As As `unread` is only in the public mode, let's not change this.
|
||||
`tags` TEXT,
|
||||
`spout` TEXT,
|
||||
`error` TEXT,
|
||||
AmineB marked this conversation as resolved
AmineB
commented
Why was everything changed to nullable ? Why was everything changed to nullable ?
|
||||
`icon` TEXT,
|
||||
`url` TEXT,
|
||||
PRIMARY KEY(`id`)
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user
Source
data class should be changed to an interfaceSourceDetail
andSourceStats
should implement it.