Skip to content

Commit 1a13419

Browse files
authored
Merge pull request #1614 from DimensionDev/bugfix/xqt_mapping
fix xqt mapping
2 parents f18bf43 + c8b5f34 commit 1a13419

File tree

1 file changed

+3
-22
lines changed
  • shared/src/commonMain/kotlin/dev/dimension/flare/data/database/cache/mapper

1 file changed

+3
-22
lines changed

shared/src/commonMain/kotlin/dev/dimension/flare/data/database/cache/mapper/XQT.kt

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import dev.dimension.flare.model.ReferenceType
4545
import dev.dimension.flare.ui.model.mapper.name
4646
import dev.dimension.flare.ui.model.mapper.parseXQTCustomDateTime
4747
import dev.dimension.flare.ui.model.mapper.screenName
48-
import kotlin.collections.toMap
4948
import kotlin.time.Clock
5049

5150
internal object XQT {
@@ -267,21 +266,21 @@ private fun TweetUnion.toDbStatusWithUser(accountKey: MicroBlogKey): DbStatusWit
267266
private fun toDbStatusWithUser(
268267
tweet: Tweet,
269268
accountKey: MicroBlogKey,
270-
): DbStatusWithUser {
269+
): DbStatusWithUser? {
271270
val user =
272271
tweet.core
273272
?.userResults
274273
?.result
275274
?.let {
276275
it as? User
277-
}?.toDbUser(accountKey) ?: throw IllegalStateException("Tweet.user should not be null")
276+
}?.toDbUser(accountKey) ?: return null
278277
return DbStatusWithUser(
279278
data =
280279
DbStatus(
281280
statusKey =
282281
MicroBlogKey(
283282
id = tweet.restId,
284-
host = user.userKey.host,
283+
host = accountKey.host,
285284
),
286285
content = StatusContent.XQT(tweet),
287286
userKey = user.userKey,
@@ -295,24 +294,6 @@ private fun toDbStatusWithUser(
295294
)
296295
}
297296

298-
private fun TimelineTweet.toDbUser(accountKey: MicroBlogKey): DbUser {
299-
val tweet =
300-
when (tweetResults.result) {
301-
is Tweet -> tweetResults.result
302-
null, is TweetTombstone -> throw IllegalStateException("Tweet tombstone should not be saved")
303-
is TweetWithVisibilityResults -> tweetResults.result.tweet
304-
}
305-
val user =
306-
tweet.core
307-
?.userResults
308-
?.result
309-
?.let {
310-
it as? User
311-
}
312-
?: throw IllegalStateException("Tweet.user should not be null")
313-
return user.toDbUser(accountKey = accountKey)
314-
}
315-
316297
internal fun User.toDbUser(accountKey: MicroBlogKey) =
317298
DbUser(
318299
userKey =

0 commit comments

Comments
 (0)