From 5227751dcad431848fe29276a0344fcd1309b227 Mon Sep 17 00:00:00 2001 From: davidoskky Date: Wed, 28 Dec 2022 11:02:43 +0100 Subject: [PATCH] Make the author field nullable --- .../apps/readerforselfossv2/android/model/ParecelableItem.kt | 2 +- .../bou/amine/apps/readerforselfossv2/model/SelfossModel.kt | 4 ++-- .../sqldelight/bou/amine/apps/readerforselfossv2/dao/1.sqm | 2 +- .../sqldelight/bou/amine/apps/readerforselfossv2/dao/Items.sq | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/model/ParecelableItem.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/model/ParecelableItem.kt index 9eaf41d..7ae2939 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/model/ParecelableItem.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/model/ParecelableItem.kt @@ -46,7 +46,7 @@ data class ParecelableItem( val link: String, val sourcetitle: String, val tags: String, - val author: String + val author: String? ) : Parcelable { companion object { diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/model/SelfossModel.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/model/SelfossModel.kt index 7566f18..5d4d5c4 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/model/SelfossModel.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/model/SelfossModel.kt @@ -73,7 +73,7 @@ class SelfossModel { val sourcetitle: String, @Serializable(with = TagsListSerializer::class) val tags: List, - val author: String + val author: String? ) { // TODO: maybe find a better way to handle these kind of urls fun getLinkDecoded(): String { @@ -104,7 +104,7 @@ class SelfossModel { fun sourceAuthorAndDate(): String { var txt = this.sourcetitle.getHtmlDecoded() - if (this.author.isNotEmpty()) { + if (!this.author.isNullOrBlank()) { txt += " (by ${this.author}) " } txt += DateUtils.parseRelativeDate(this.datetime) diff --git a/shared/src/commonMain/sqldelight/bou/amine/apps/readerforselfossv2/dao/1.sqm b/shared/src/commonMain/sqldelight/bou/amine/apps/readerforselfossv2/dao/1.sqm index 6f9532c..1a71de6 100644 --- a/shared/src/commonMain/sqldelight/bou/amine/apps/readerforselfossv2/dao/1.sqm +++ b/shared/src/commonMain/sqldelight/bou/amine/apps/readerforselfossv2/dao/1.sqm @@ -1 +1 @@ -ALTER TABLE ITEM ADD COLUMN `author` TEXT NOT NULL; \ No newline at end of file +ALTER TABLE ITEM ADD COLUMN `author` TEXT; \ No newline at end of file diff --git a/shared/src/commonMain/sqldelight/bou/amine/apps/readerforselfossv2/dao/Items.sq b/shared/src/commonMain/sqldelight/bou/amine/apps/readerforselfossv2/dao/Items.sq index ed9fa8e..04a9c00 100644 --- a/shared/src/commonMain/sqldelight/bou/amine/apps/readerforselfossv2/dao/Items.sq +++ b/shared/src/commonMain/sqldelight/bou/amine/apps/readerforselfossv2/dao/Items.sq @@ -10,7 +10,7 @@ CREATE TABLE ITEM ( `link` TEXT NOT NULL, `sourcetitle` TEXT NOT NULL, `tags` TEXT NOT NULL, - `author` TEXT NOT NULL, + `author` TEXT, PRIMARY KEY(`id`) );