mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
cleanup
This commit is contained in:
parent
10599aa728
commit
707397cb9d
@ -176,6 +176,7 @@ internal class DefaultRelationService @AssistedInject constructor(
|
|||||||
formattedText: String?,
|
formattedText: String?,
|
||||||
eventReplied: TimelineEvent?): Cancelable? {
|
eventReplied: TimelineEvent?): Cancelable? {
|
||||||
val event = if (eventReplied != null) {
|
val event = if (eventReplied != null) {
|
||||||
|
// Reply within a thread
|
||||||
eventFactory.createReplyTextEvent(
|
eventFactory.createReplyTextEvent(
|
||||||
roomId = roomId,
|
roomId = roomId,
|
||||||
eventReplied = eventReplied,
|
eventReplied = eventReplied,
|
||||||
@ -187,6 +188,7 @@ internal class DefaultRelationService @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
?: return null
|
?: return null
|
||||||
} else {
|
} else {
|
||||||
|
// Normal thread reply
|
||||||
eventFactory.createThreadTextEvent(
|
eventFactory.createThreadTextEvent(
|
||||||
rootThreadEventId = rootThreadEventId,
|
rootThreadEventId = rootThreadEventId,
|
||||||
roomId = roomId,
|
roomId = roomId,
|
||||||
|
@ -457,6 +457,14 @@ internal class LocalEchoEventFactory @Inject constructor(
|
|||||||
/**
|
/**
|
||||||
* Generates the appropriate relatesTo object for a reply event.
|
* Generates the appropriate relatesTo object for a reply event.
|
||||||
* It can either be a regular reply or a reply within a thread
|
* It can either be a regular reply or a reply within a thread
|
||||||
|
* "m.relates_to": {
|
||||||
|
* "rel_type": "m.thread",
|
||||||
|
* "event_id": "$thread_root",
|
||||||
|
* "m.in_reply_to": {
|
||||||
|
* "event_id": "$event_target",
|
||||||
|
* "render_in": ["m.thread"]
|
||||||
|
* }
|
||||||
|
* }
|
||||||
*/
|
*/
|
||||||
private fun generateReplyRelationContent(eventId: String, rootThreadEventId: String? = null): RelationDefaultContent =
|
private fun generateReplyRelationContent(eventId: String, rootThreadEventId: String? = null): RelationDefaultContent =
|
||||||
rootThreadEventId?.let {
|
rootThreadEventId?.let {
|
||||||
|
@ -171,7 +171,6 @@ internal class LoadTimelineStrategy(
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun loadMore(count: Int, direction: Timeline.Direction, fetchOnServerIfNeeded: Boolean = true): LoadMoreResult {
|
suspend fun loadMore(count: Int, direction: Timeline.Direction, fetchOnServerIfNeeded: Boolean = true): LoadMoreResult {
|
||||||
// /
|
|
||||||
if (mode is Mode.Permalink && timelineChunk == null) {
|
if (mode is Mode.Permalink && timelineChunk == null) {
|
||||||
val params = GetContextOfEventTask.Params(roomId, mode.originEventId)
|
val params = GetContextOfEventTask.Params(roomId, mode.originEventId)
|
||||||
try {
|
try {
|
||||||
|
@ -289,22 +289,10 @@ internal class TimelineChunk(private val chunkEntity: ChunkEntity,
|
|||||||
val displayIndex = getNextDisplayIndex(direction) ?: return LoadedFromStorage()
|
val displayIndex = getNextDisplayIndex(direction) ?: return LoadedFromStorage()
|
||||||
val baseQuery = timelineEventEntities.where()
|
val baseQuery = timelineEventEntities.where()
|
||||||
|
|
||||||
// val timelineEvents = if (timelineSettings.rootThreadEventId != null) {
|
|
||||||
// baseQuery
|
|
||||||
// .beginGroup()
|
|
||||||
// .equalTo(TimelineEventEntityFields.ROOT.ROOT_THREAD_EVENT_ID, timelineSettings.rootThreadEventId)
|
|
||||||
// .or()
|
|
||||||
// .equalTo(TimelineEventEntityFields.ROOT.EVENT_ID, timelineSettings.rootThreadEventId)
|
|
||||||
// .endGroup()
|
|
||||||
// .offsets(direction, count, displayIndex)
|
|
||||||
// .findAll()
|
|
||||||
// .orEmpty()
|
|
||||||
// } else {
|
|
||||||
val timelineEvents = baseQuery
|
val timelineEvents = baseQuery
|
||||||
.offsets(direction, count, displayIndex)
|
.offsets(direction, count, displayIndex)
|
||||||
.findAll()
|
.findAll()
|
||||||
.orEmpty()
|
.orEmpty()
|
||||||
// }
|
|
||||||
|
|
||||||
if (timelineEvents.isEmpty()) return LoadedFromStorage()
|
if (timelineEvents.isEmpty()) return LoadedFromStorage()
|
||||||
fetchRootThreadEventsIfNeeded(timelineEvents)
|
fetchRootThreadEventsIfNeeded(timelineEvents)
|
||||||
@ -331,7 +319,7 @@ internal class TimelineChunk(private val chunkEntity: ChunkEntity,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether or not the the thread has reached end. It returned false if the current timeline
|
* Returns whether or not the the thread has reached end. It returns false if the current timeline
|
||||||
* is not a thread timeline
|
* is not a thread timeline
|
||||||
*/
|
*/
|
||||||
private fun threadReachedEnd(timelineEvents: List<TimelineEventEntity>): Boolean =
|
private fun threadReachedEnd(timelineEvents: List<TimelineEventEntity>): Boolean =
|
||||||
|
@ -171,7 +171,7 @@ internal class ThreadsAwarenessHandler @Inject constructor(
|
|||||||
/**
|
/**
|
||||||
* If the event is a thread event then transform/enhance it to a visual Reply Event,
|
* If the event is a thread event then transform/enhance it to a visual Reply Event,
|
||||||
* If the event is not a thread event, null value will be returned
|
* If the event is not a thread event, null value will be returned
|
||||||
* If there is an error (ex. the root/origin thread event is not found), null willl be returend
|
* If there is an error (ex. the root/origin thread event is not found), null will be returned
|
||||||
*/
|
*/
|
||||||
private fun transformThreadToReplyIfNeeded(realm: Realm, roomId: String?, event: Event, decryptedResult: JsonDict?): JsonDict? {
|
private fun transformThreadToReplyIfNeeded(realm: Realm, roomId: String?, event: Event, decryptedResult: JsonDict?): JsonDict? {
|
||||||
roomId ?: return null
|
roomId ?: return null
|
||||||
|
@ -45,8 +45,8 @@ enum class Command(val command: String,
|
|||||||
REMOVE_USER("/remove", arrayOf("/kick"), "<user-id> [reason]", R.string.command_description_kick_user, false, false),
|
REMOVE_USER("/remove", arrayOf("/kick"), "<user-id> [reason]", R.string.command_description_kick_user, false, false),
|
||||||
CHANGE_DISPLAY_NAME("/nick", null, "<display-name>", R.string.command_description_nick, false, false),
|
CHANGE_DISPLAY_NAME("/nick", null, "<display-name>", R.string.command_description_nick, false, false),
|
||||||
CHANGE_DISPLAY_NAME_FOR_ROOM("/myroomnick", arrayOf("/roomnick"), "<display-name>", R.string.command_description_nick_for_room, false, false),
|
CHANGE_DISPLAY_NAME_FOR_ROOM("/myroomnick", arrayOf("/roomnick"), "<display-name>", R.string.command_description_nick_for_room, false, false),
|
||||||
ROOM_AVATAR("/roomavatar", null, "<mxc_url>", R.string.command_description_room_avatar, true /* Since user has to know the mxc url */, false),
|
ROOM_AVATAR("/roomavatar", null, "<mxc_url>", R.string.command_description_room_avatar, true /* User has to know the mxc url */, false),
|
||||||
CHANGE_AVATAR_FOR_ROOM("/myroomavatar", null, "<mxc_url>", R.string.command_description_avatar_for_room, true /* Since user has to know the mxc url */, false),
|
CHANGE_AVATAR_FOR_ROOM("/myroomavatar", null, "<mxc_url>", R.string.command_description_avatar_for_room, true /* User has to know the mxc url */, false),
|
||||||
MARKDOWN("/markdown", null, "<on|off>", R.string.command_description_markdown, false, false),
|
MARKDOWN("/markdown", null, "<on|off>", R.string.command_description_markdown, false, false),
|
||||||
RAINBOW("/rainbow", null, "<message>", R.string.command_description_rainbow, false, true),
|
RAINBOW("/rainbow", null, "<message>", R.string.command_description_rainbow, false, true),
|
||||||
RAINBOW_EMOTE("/rainbowme", null, "<message>", R.string.command_description_rainbow_emote, false, true),
|
RAINBOW_EMOTE("/rainbowme", null, "<message>", R.string.command_description_rainbow_emote, false, true),
|
||||||
|
Loading…
Reference in New Issue
Block a user