Skip to content

Commit 4eace6f

Browse files
authored
Merge pull request #1650 from DimensionDev/dependency/bsky
update bluesky
2 parents 06e2f93 + 2d0ba24 commit 4eace6f

File tree

6 files changed

+45
-49
lines changed

6 files changed

+45
-49
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ okio = "3.16.4"
4040
skie = "0.10.8"
4141
ksoup = "0.2.0"
4242
versionUpdate = "0.53.0"
43-
bluesky = "0.3.3-SNAPSHOT"
43+
bluesky = "0.3.4-SNAPSHOT"
4444
kotlinx-coroutines = "1.10.2"
4545
koin = "4.1.1"
4646
composeIcons = "1.3.0"

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

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import dev.dimension.flare.model.ReferenceType
3838
import dev.dimension.flare.ui.model.mapper.parseBlueskyJson
3939
import kotlinx.collections.immutable.ImmutableMap
4040
import kotlinx.coroutines.flow.firstOrNull
41-
import kotlinx.datetime.toStdlibInstant
4241
import sh.christian.ozone.api.AtUri
4342

4443
internal object Bluesky {
@@ -85,7 +84,7 @@ internal object Bluesky {
8584
database: CacheDatabase,
8685
data: List<PostView>,
8786
sortIdProvider: (PostView) -> Long = {
88-
it.indexedAt.toStdlibInstant().toEpochMilliseconds()
87+
it.indexedAt.toEpochMilliseconds()
8988
},
9089
) {
9190
save(database, data.toDb(accountKey, pagingKey, sortIdProvider))
@@ -156,7 +155,7 @@ internal suspend fun List<BookmarkView>.toDb(
156155
accountKey: MicroBlogKey,
157156
pagingKey: String,
158157
sortIdProvider: suspend (BookmarkView) -> Long = {
159-
it.createdAt?.toStdlibInstant()?.toEpochMilliseconds() ?: SnowflakeIdGenerator.nextId()
158+
it.createdAt?.toEpochMilliseconds() ?: SnowflakeIdGenerator.nextId()
160159
},
161160
): List<DbPagingTimelineWithStatus> =
162161
this.mapNotNull {
@@ -174,7 +173,7 @@ internal suspend fun List<BookmarkView>.toDb(
174173
internal fun List<PostView>.toDb(
175174
accountKey: MicroBlogKey,
176175
pagingKey: String,
177-
sortIdProvider: (PostView) -> Long = { it.indexedAt.toStdlibInstant().toEpochMilliseconds() },
176+
sortIdProvider: (PostView) -> Long = { it.indexedAt.toEpochMilliseconds() },
178177
): List<DbPagingTimelineWithStatus> =
179178
this.map {
180179
createDbPagingTimelineWithStatus(
@@ -204,7 +203,7 @@ internal fun List<ListNotificationsNotification>.toDb(
204203
createDbPagingTimelineWithStatus(
205204
accountKey = accountKey,
206205
pagingKey = pagingKey,
207-
sortId = it.indexedAt.toStdlibInstant().toEpochMilliseconds(),
206+
sortId = it.indexedAt.toEpochMilliseconds(),
208207
status = it.toDbStatusWithUser(accountKey),
209208
references = mapOf(),
210209
)
@@ -250,7 +249,7 @@ internal fun List<ListNotificationsNotification>.toDb(
250249
userKey = null,
251250
content = content,
252251
text = null,
253-
createdAt = items.first().indexedAt.toStdlibInstant(),
252+
createdAt = items.first().indexedAt,
254253
),
255254
)
256255
listOf(
@@ -261,7 +260,6 @@ internal fun List<ListNotificationsNotification>.toDb(
261260
items
262261
.first()
263262
.indexedAt
264-
.toStdlibInstant()
265263
.toEpochMilliseconds(),
266264
status = data,
267265
references =
@@ -295,7 +293,7 @@ internal fun List<ListNotificationsNotification>.toDb(
295293
userKey = null,
296294
content = content,
297295
text = null,
298-
createdAt = items.first().indexedAt.toStdlibInstant(),
296+
createdAt = items.first().indexedAt,
299297
),
300298
)
301299
listOfNotNull(
@@ -306,7 +304,6 @@ internal fun List<ListNotificationsNotification>.toDb(
306304
items
307305
.first()
308306
.indexedAt
309-
.toStdlibInstant()
310307
.toEpochMilliseconds(),
311308
status = data,
312309
references = mapOf(),
@@ -336,13 +333,13 @@ internal fun List<ListNotificationsNotification>.toDb(
336333
userKey = user.userKey,
337334
content = content,
338335
text = null,
339-
createdAt = it.indexedAt.toStdlibInstant(),
336+
createdAt = it.indexedAt,
340337
),
341338
)
342339
createDbPagingTimelineWithStatus(
343340
accountKey = accountKey,
344341
pagingKey = pagingKey,
345-
sortId = it.indexedAt.toStdlibInstant().toEpochMilliseconds(),
342+
sortId = it.indexedAt.toEpochMilliseconds(),
346343
status = data,
347344
references =
348345
mapOf(
@@ -376,13 +373,13 @@ internal fun List<ListNotificationsNotification>.toDb(
376373
userKey = user.userKey,
377374
content = content,
378375
text = null,
379-
createdAt = it.indexedAt.toStdlibInstant(),
376+
createdAt = it.indexedAt,
380377
),
381378
)
382379
createDbPagingTimelineWithStatus(
383380
accountKey = accountKey,
384381
pagingKey = pagingKey,
385-
sortId = it.indexedAt.toStdlibInstant().toEpochMilliseconds(),
382+
sortId = it.indexedAt.toEpochMilliseconds(),
386383
status = data,
387384
references =
388385
mapOf(
@@ -415,13 +412,13 @@ internal fun List<ListNotificationsNotification>.toDb(
415412
userKey = user.userKey,
416413
content = content,
417414
text = null,
418-
createdAt = it.indexedAt.toStdlibInstant(),
415+
createdAt = it.indexedAt,
419416
),
420417
)
421418
createDbPagingTimelineWithStatus(
422419
accountKey = accountKey,
423420
pagingKey = pagingKey,
424-
sortId = it.indexedAt.toStdlibInstant().toEpochMilliseconds(),
421+
sortId = it.indexedAt.toEpochMilliseconds(),
425422
status = data,
426423
references =
427424
mapOf(
@@ -454,13 +451,13 @@ internal fun List<ListNotificationsNotification>.toDb(
454451
userKey = user.userKey,
455452
content = content,
456453
text = null,
457-
createdAt = it.indexedAt.toStdlibInstant(),
454+
createdAt = it.indexedAt,
458455
),
459456
)
460457
createDbPagingTimelineWithStatus(
461458
accountKey = accountKey,
462459
pagingKey = pagingKey,
463-
sortId = it.indexedAt.toStdlibInstant().toEpochMilliseconds(),
460+
sortId = it.indexedAt.toEpochMilliseconds(),
464461
status = data,
465462
references =
466463
mapOf(
@@ -507,7 +504,7 @@ private fun ListNotificationsNotification.toDbStatus(accountKey: MicroBlogKey):
507504
content = StatusContent.BlueskyNotification.Normal(this),
508505
accountType = AccountType.Specific(accountKey),
509506
text = null,
510-
createdAt = indexedAt.toStdlibInstant(),
507+
createdAt = indexedAt,
511508
)
512509
}
513510

@@ -518,7 +515,7 @@ internal suspend fun List<FeedViewPost>.toDbPagingTimeline(
518515
when (val reason = it.reason) {
519516
// is FeedViewPostReasonUnion.ReasonRepost -> {
520517
// reason.value.indexedAt
521-
// .toStdlibInstant()
518+
//
522519
// .toEpochMilliseconds()
523520
// }
524521

@@ -529,7 +526,7 @@ internal suspend fun List<FeedViewPost>.toDbPagingTimeline(
529526
else -> {
530527
-SnowflakeIdGenerator.nextId()
531528
// it.post.indexedAt
532-
// .toStdlibInstant()
529+
//
533530
// .toEpochMilliseconds()
534531
}
535532
}
@@ -568,7 +565,7 @@ internal suspend fun List<FeedViewPost>.toDbPagingTimeline(
568565
content = StatusContent.BlueskyReason(data),
569566
accountType = AccountType.Specific(accountKey),
570567
text = null,
571-
createdAt = it.post.indexedAt.toStdlibInstant(),
568+
createdAt = it.post.indexedAt,
572569
),
573570
)
574571
}
@@ -588,7 +585,7 @@ internal suspend fun List<FeedViewPost>.toDbPagingTimeline(
588585
content = StatusContent.BlueskyReason(data),
589586
accountType = AccountType.Specific(accountKey),
590587
text = status.data.text,
591-
createdAt = it.post.indexedAt.toStdlibInstant(),
588+
createdAt = it.post.indexedAt,
592589
),
593590
)
594591
}
@@ -644,7 +641,7 @@ private fun PostView.toDbStatusWithUser(accountKey: MicroBlogKey): DbStatusWithU
644641
userKey = user.userKey,
645642
accountType = AccountType.Specific(accountKey),
646643
text = parseBlueskyJson(record, accountKey).raw,
647-
createdAt = indexedAt.toStdlibInstant(),
644+
createdAt = indexedAt,
648645
)
649646
return DbStatusWithUser(
650647
data = status,
@@ -784,7 +781,7 @@ private fun MessageView.toDbMessageItem(roomKey: MicroBlogKey) =
784781
messageKey = MicroBlogKey(id = id, host = roomKey.host),
785782
roomKey = roomKey,
786783
userKey = MicroBlogKey(id = sender.did.did, host = roomKey.host),
787-
timestamp = sentAt.toStdlibInstant().toEpochMilliseconds(),
784+
timestamp = sentAt.toEpochMilliseconds(),
788785
content = MessageContent.Bluesky.Message(this),
789786
showSender = false,
790787
)
@@ -797,7 +794,7 @@ private fun ConvoViewLastMessageUnion.DeletedMessageView.toDbMessageItem(roomKey
797794
messageKey = MicroBlogKey(id = id, host = roomKey.host),
798795
roomKey = roomKey,
799796
userKey = MicroBlogKey(id = sender.did.did, host = roomKey.host),
800-
timestamp = sentAt.toStdlibInstant().toEpochMilliseconds(),
797+
timestamp = sentAt.toEpochMilliseconds(),
801798
content = MessageContent.Bluesky.Deleted(this),
802799
showSender = false,
803800
)

shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/bluesky/BlueskyDataSource.kt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ import kotlinx.coroutines.flow.flow
130130
import kotlinx.coroutines.flow.map
131131
import kotlinx.coroutines.flow.mapNotNull
132132
import kotlinx.coroutines.launch
133-
import kotlinx.datetime.toDeprecatedInstant
134133
import org.koin.core.component.KoinComponent
135134
import org.koin.core.component.inject
136135
import sh.christian.ozone.api.AtUri
@@ -387,7 +386,7 @@ internal class BlueskyDataSource(
387386
Post(
388387
text = data.content,
389388
facets = facets,
390-
createdAt = Clock.System.now().toDeprecatedInstant(),
389+
createdAt = Clock.System.now(),
391390
embed =
392391
quoteId
393392
?.let {
@@ -559,8 +558,7 @@ internal class BlueskyDataSource(
559558
),
560559
createdAt =
561560
Clock.System
562-
.now()
563-
.toDeprecatedInstant(),
561+
.now(),
564562
).bskyJson(),
565563
),
566564
).requireResponse()
@@ -719,7 +717,7 @@ internal class BlueskyDataSource(
719717
uri = AtUri(uri),
720718
cid = Cid(cid),
721719
),
722-
createdAt = Clock.System.now().toDeprecatedInstant(),
720+
createdAt = Clock.System.now(),
723721
).bskyJson(),
724722
),
725723
).requireResponse()
@@ -813,7 +811,7 @@ internal class BlueskyDataSource(
813811
app.bsky.graph
814812
.Follow(
815813
subject = Did(userKey.id),
816-
createdAt = Clock.System.now().toDeprecatedInstant(),
814+
createdAt = Clock.System.now(),
817815
).bskyJson(),
818816
),
819817
)
@@ -846,7 +844,7 @@ internal class BlueskyDataSource(
846844
app.bsky.graph
847845
.Block(
848846
subject = Did(userKey.id),
849-
createdAt = Clock.System.now().toDeprecatedInstant(),
847+
createdAt = Clock.System.now(),
850848
).bskyJson(),
851849
),
852850
)
@@ -1403,7 +1401,7 @@ internal class BlueskyDataSource(
14031401
name = title,
14041402
description = description,
14051403
avatar = iconInfo?.blob,
1406-
createdAt = Clock.System.now().toDeprecatedInstant(),
1404+
createdAt = Clock.System.now(),
14071405
)
14081406
service.createRecord(
14091407
request =
@@ -1631,7 +1629,7 @@ internal class BlueskyDataSource(
16311629
.Listitem(
16321630
list = AtUri(listId),
16331631
subject = Did(userKey.id),
1634-
createdAt = Clock.System.now().toDeprecatedInstant(),
1632+
createdAt = Clock.System.now(),
16351633
).bskyJson(),
16361634
),
16371635
)

shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/bluesky/NotificationRemoteMediator.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import dev.dimension.flare.data.network.bluesky.BlueskyService
1414
import dev.dimension.flare.model.MicroBlogKey
1515
import kotlinx.collections.immutable.toImmutableList
1616
import kotlinx.collections.immutable.toImmutableMap
17-
import kotlinx.datetime.toDeprecatedInstant
1817
import kotlin.time.Clock
1918

2019
@OptIn(ExperimentalPagingApi::class)
@@ -49,7 +48,7 @@ internal class NotificationRemoteMediator(
4948
service.updateSeen(
5049
request =
5150
UpdateSeenRequest(
52-
seenAt = Clock.System.now().toDeprecatedInstant(),
51+
seenAt = Clock.System.now(),
5352
),
5453
)
5554
onClearMarker.invoke()

shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/bluesky/StatusDetailRemoteMediator.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,15 @@ internal class StatusDetailRemoteMediator(
7575
}
7676
}
7777
val replies =
78-
thread.value.replies.mapNotNull {
78+
thread.value.replies.orEmpty().mapNotNull {
7979
when (it) {
8080
is ThreadViewPostReplieUnion.ThreadViewPost -> {
81-
if (it.value.replies.any()) {
81+
if (it.value.replies
82+
.orEmpty()
83+
.any()
84+
) {
8285
val last =
83-
it.value.replies.last().let {
86+
it.value.replies.orEmpty().last().let {
8487
when (it) {
8588
is ThreadViewPostReplieUnion.ThreadViewPost -> it.value.post
8689
else -> null
@@ -89,7 +92,7 @@ internal class StatusDetailRemoteMediator(
8992
if (last != null) {
9093
val parents =
9194
listOfNotNull(it.value.post) +
92-
it.value.replies.toList().dropLast(1).mapNotNull {
95+
it.value.replies.orEmpty().toList().dropLast(1).mapNotNull {
9396
when (it) {
9497
is ThreadViewPostReplieUnion.ThreadViewPost -> it.value.post
9598
else -> null

0 commit comments

Comments
 (0)