mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-03 11:47:31 +01:00
feat: add option to share comments (#950)
This commit is contained in:
parent
8dfb1bf453
commit
fe41e693db
@ -27,11 +27,13 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.test.advanceTimeBy
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Ignore
|
||||
import org.junit.Rule
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertIs
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
@Ignore("Ignore this tests \"for now\" due to flakiness")
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class DefaultDetailOpenerTest {
|
||||
@get:Rule
|
||||
|
@ -4,6 +4,7 @@ import kotlin.jvm.Transient
|
||||
|
||||
data class CommentModel(
|
||||
val id: Long = 0,
|
||||
val originalUrl: String? = null,
|
||||
val postId: Long = 0,
|
||||
val postTitle: String? = null,
|
||||
val text: String? = null,
|
||||
|
@ -242,6 +242,7 @@ internal fun Comment.toModel() =
|
||||
removed = removed,
|
||||
deleted = deleted,
|
||||
languageId = languageId,
|
||||
originalUrl = apId,
|
||||
)
|
||||
|
||||
internal fun Community.toModel() =
|
||||
|
@ -383,7 +383,9 @@ object ProfileLoggedScreen : Tab {
|
||||
if (uiState.posts.isEmpty() && !uiState.loading && !uiState.initial) {
|
||||
item {
|
||||
Text(
|
||||
modifier = Modifier.fillMaxWidth().padding(top = Spacing.xs),
|
||||
modifier =
|
||||
Modifier.fillMaxWidth()
|
||||
.padding(top = Spacing.xs),
|
||||
textAlign = TextAlign.Center,
|
||||
text = LocalStrings.current.messageEmptyList,
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
@ -473,24 +475,26 @@ object ProfileLoggedScreen : Tab {
|
||||
},
|
||||
options =
|
||||
buildList {
|
||||
add(
|
||||
this +=
|
||||
Option(
|
||||
OptionId.SeeRaw,
|
||||
LocalStrings.current.postActionSeeRaw,
|
||||
),
|
||||
)
|
||||
add(
|
||||
)
|
||||
this +=
|
||||
Option(
|
||||
OptionId.SeeRaw,
|
||||
LocalStrings.current.postActionSeeRaw,
|
||||
)
|
||||
this +=
|
||||
Option(
|
||||
OptionId.Edit,
|
||||
LocalStrings.current.postActionEdit,
|
||||
),
|
||||
)
|
||||
add(
|
||||
)
|
||||
this +=
|
||||
Option(
|
||||
OptionId.Delete,
|
||||
LocalStrings.current.commentActionDelete,
|
||||
),
|
||||
)
|
||||
)
|
||||
},
|
||||
onOptionSelected =
|
||||
rememberCallbackArgs(model) { optionId ->
|
||||
@ -510,6 +514,27 @@ object ProfileLoggedScreen : Tab {
|
||||
rawContent = comment
|
||||
}
|
||||
|
||||
OptionId.Share -> {
|
||||
val urls =
|
||||
listOfNotNull(
|
||||
comment.originalUrl,
|
||||
"https://${uiState.instance}/comment/${comment.id}",
|
||||
).distinct()
|
||||
if (urls.size == 1) {
|
||||
model.reduce(
|
||||
ProfileLoggedMviModel.Intent.Share(
|
||||
urls.first(),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
val screen =
|
||||
ShareBottomSheet(urls = urls)
|
||||
navigationCoordinator.showBottomSheet(
|
||||
screen,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
},
|
||||
@ -523,7 +548,9 @@ object ProfileLoggedScreen : Tab {
|
||||
if (uiState.comments.isEmpty() && !uiState.loading && !uiState.initial) {
|
||||
item {
|
||||
Text(
|
||||
modifier = Modifier.fillMaxWidth().padding(top = Spacing.xs),
|
||||
modifier =
|
||||
Modifier.fillMaxWidth()
|
||||
.padding(top = Spacing.xs),
|
||||
textAlign = TextAlign.Center,
|
||||
text = LocalStrings.current.messageEmptyList,
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
|
@ -1245,6 +1245,11 @@ class PostDetailScreen(
|
||||
},
|
||||
options =
|
||||
buildList {
|
||||
this +=
|
||||
Option(
|
||||
OptionId.Share,
|
||||
LocalStrings.current.postActionShare,
|
||||
)
|
||||
this +=
|
||||
Option(
|
||||
OptionId.SeeRaw,
|
||||
@ -1437,6 +1442,29 @@ class PostDetailScreen(
|
||||
}
|
||||
}
|
||||
|
||||
OptionId.Share -> {
|
||||
val urls =
|
||||
listOfNotNull(
|
||||
comment.originalUrl,
|
||||
"https://${uiState.instance}/comment/${comment.id}",
|
||||
).distinct()
|
||||
if (urls.size == 1) {
|
||||
model.reduce(
|
||||
PostDetailMviModel.Intent.Share(
|
||||
urls.first(),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
val screen =
|
||||
ShareBottomSheet(
|
||||
urls = urls,
|
||||
)
|
||||
navigationCoordinator.showBottomSheet(
|
||||
screen,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
},
|
||||
|
@ -1113,6 +1113,10 @@ class UserDetailScreen(
|
||||
},
|
||||
options =
|
||||
buildList {
|
||||
Option(
|
||||
OptionId.Share,
|
||||
LocalStrings.current.postActionShare,
|
||||
)
|
||||
this +=
|
||||
Option(
|
||||
OptionId.SeeRaw,
|
||||
@ -1142,6 +1146,27 @@ class UserDetailScreen(
|
||||
rawContent = comment
|
||||
}
|
||||
|
||||
OptionId.Share -> {
|
||||
val urls =
|
||||
listOfNotNull(
|
||||
comment.originalUrl,
|
||||
"https://${uiState.instance}/comment/${comment.id}",
|
||||
).distinct()
|
||||
if (urls.size == 1) {
|
||||
model.reduce(
|
||||
UserDetailMviModel.Intent.Share(
|
||||
urls.first(),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
val screen =
|
||||
ShareBottomSheet(urls = urls)
|
||||
navigationCoordinator.showBottomSheet(
|
||||
screen,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user