Skip to content

Commit 38543d3

Browse files
authored
Merge pull request #1208 from DimensionDev/bugfix/vvo_cmt
fix vvo comment
2 parents 1fe99f8 + 68afe62 commit 38543d3

File tree

4 files changed

+69
-21
lines changed

4 files changed

+69
-21
lines changed

compose-ui/src/commonMain/kotlin/dev/dimension/flare/ui/component/status/UiTimelineComponent.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dev.dimension.flare.ui.component.status
22

3+
import androidx.compose.foundation.border
34
import androidx.compose.foundation.clickable
45
import androidx.compose.foundation.layout.Arrangement
56
import androidx.compose.foundation.layout.Column
@@ -15,6 +16,7 @@ import androidx.compose.foundation.lazy.LazyRow
1516
import androidx.compose.runtime.Composable
1617
import androidx.compose.ui.Modifier
1718
import androidx.compose.ui.draw.alpha
19+
import androidx.compose.ui.draw.clip
1820
import androidx.compose.ui.layout.Layout
1921
import androidx.compose.ui.platform.LocalLayoutDirection
2022
import androidx.compose.ui.platform.LocalUriHandler
@@ -231,6 +233,7 @@ import dev.dimension.flare.compose.ui.xqt_item_reblogged_status
231233
import dev.dimension.flare.model.MicroBlogKey
232234
import dev.dimension.flare.ui.component.AvatarComponentDefaults
233235
import dev.dimension.flare.ui.component.FAIcon
236+
import dev.dimension.flare.ui.component.FlareDividerDefaults
234237
import dev.dimension.flare.ui.component.VerticalDivider
235238
import dev.dimension.flare.ui.component.platform.PlatformButton
236239
import dev.dimension.flare.ui.component.platform.PlatformCard
@@ -459,9 +462,17 @@ private fun UserListContent(
459462
}
460463
val status = data.status
461464
if (status != null) {
462-
StatusContent(
465+
QuotedStatus(
463466
data = status,
464-
detailStatusKey = null,
467+
modifier =
468+
Modifier
469+
.border(
470+
FlareDividerDefaults.thickness,
471+
color = FlareDividerDefaults.color,
472+
shape = PlatformTheme.shapes.medium,
473+
).clip(
474+
shape = PlatformTheme.shapes.medium,
475+
),
465476
)
466477
}
467478
}

shared/src/commonMain/kotlin/dev/dimension/flare/data/datasource/vvo/VVODataSource.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,10 @@ internal class VVODataSource(
352352
val mediaId = mediaIds.joinToString(",")
353353
if (data.referenceStatus != null && data.referenceStatus.composeStatus is ComposeStatus.VVOComment) {
354354
service.replyComment(
355-
id = data.referenceStatus.composeStatus.statusKey.id,
356-
cid = data.referenceStatus.composeStatus.rootId,
355+
cid = data.referenceStatus.composeStatus.statusKey.id,
356+
reply = data.referenceStatus.composeStatus.statusKey.id,
357+
id = data.referenceStatus.composeStatus.rootId,
358+
mid = data.referenceStatus.composeStatus.rootId,
357359
content = data.content,
358360
st = st,
359361
picId = mediaId,

shared/src/commonMain/kotlin/dev/dimension/flare/data/network/vvo/model/TimelineData.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ internal data class Comment(
580580
val bid: String? = null,
581581
val comments: JsonElement? = null,
582582
val pic: StatusPic? = null,
583+
val analysis_extra: String? = null,
583584
) {
584585
val commentList: List<Comment>?
585586
get() =

shared/src/commonMain/kotlin/dev/dimension/flare/ui/model/mapper/VVO.kt

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,21 @@ internal fun Comment.renderStatus(
351351
id = id,
352352
host = vvoHost,
353353
)
354+
val statusMid =
355+
status?.mid ?: run {
356+
analysis_extra
357+
?.split('|')
358+
?.mapNotNull {
359+
val pair = it.split(':')
360+
if (pair.size == 2) {
361+
pair[0] to pair[1]
362+
} else {
363+
null
364+
}
365+
}?.toMap()
366+
?.get("mid")
367+
}
368+
354369
return UiTimeline.ItemContent.Status(
355370
statusKey = statusKey,
356371
content = element.toUi(),
@@ -372,8 +387,13 @@ internal fun Comment.renderStatus(
372387
)
373388
},
374389
)
375-
}.orEmpty()
376-
.toImmutableList(),
390+
}?.toImmutableList() ?: listOfNotNull(status)
391+
.map {
392+
it.renderStatus(
393+
accountKey,
394+
event,
395+
)
396+
}.toImmutableList(),
377397
card = null,
378398
contentWarning = null,
379399
images =
@@ -398,20 +418,20 @@ internal fun Comment.renderStatus(
398418
poll = null,
399419
actions =
400420
listOfNotNull(
401-
StatusAction.Item.Reply(
402-
count = replyCount ?: 0,
403-
onClicked = {
404-
if (rootidstr != null) {
421+
statusMid?.let {
422+
StatusAction.Item.Reply(
423+
count = replyCount ?: 0,
424+
onClicked = {
405425
launcher.launch(
406426
AppDeepLink.VVO.ReplyToComment(
407427
accountKey = accountKey,
408428
replyTo = statusKey,
409-
rootId = rootidstr,
429+
rootId = statusMid,
410430
),
411431
)
412-
}
413-
},
414-
),
432+
},
433+
)
434+
},
415435
StatusAction.Item.Like(
416436
count = likeCount ?: 0,
417437
liked = liked ?: false,
@@ -450,12 +470,21 @@ internal fun Comment.renderStatus(
450470
createdAt = createdAt?.toUi() ?: Clock.System.now().toUi(),
451471
sensitive = false,
452472
onClicked = {
453-
launcher.launch(
454-
AppDeepLink.VVO.CommentDetail(
455-
accountKey = accountKey,
456-
statusKey = statusKey,
457-
),
458-
)
473+
if (status != null) {
474+
launcher.launch(
475+
AppDeepLink.VVO.StatusDetail(
476+
accountKey = accountKey,
477+
statusKey = status.renderStatus(accountKey, event).statusKey,
478+
),
479+
)
480+
} else {
481+
launcher.launch(
482+
AppDeepLink.VVO.CommentDetail(
483+
accountKey = accountKey,
484+
statusKey = statusKey,
485+
),
486+
)
487+
}
459488
},
460489
platformType = PlatformType.VVo,
461490
onMediaClicked = { media, index ->
@@ -490,6 +519,11 @@ internal fun Attitude.render(
490519
): UiTimeline {
491520
val content = status?.renderStatus(accountKey, event)
492521
val user = user?.render(accountKey)
522+
val userListContent =
523+
UiTimeline.ItemContent.UserList(
524+
users = listOfNotNull(user).toImmutableList(),
525+
status = content,
526+
)
493527
return UiTimeline(
494528
topMessage =
495529
UiTimeline.TopMessage(
@@ -508,7 +542,7 @@ internal fun Attitude.render(
508542
},
509543
statusKey = MicroBlogKey(id.toString(), vvoHost),
510544
),
511-
content = content,
545+
content = userListContent,
512546
)
513547
}
514548

0 commit comments

Comments
 (0)