Reduce duplicated code
This commit is contained in:
parent
a88a172f0f
commit
dbc61971df
@ -403,14 +403,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
|||||||
size = attachment.size
|
size = attachment.size
|
||||||
),
|
),
|
||||||
url = attachment.queryUri.toString(),
|
url = attachment.queryUri.toString(),
|
||||||
relatesTo = rootThreadEventId?.let {
|
relatesTo = rootThreadEventId?.let { generateThreadRelationContent(it) }
|
||||||
RelationDefaultContent(
|
|
||||||
type = RelationType.THREAD,
|
|
||||||
eventId = it,
|
|
||||||
isFallingBack = true,
|
|
||||||
inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(it))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
return createMessageEvent(roomId, content)
|
return createMessageEvent(roomId, content)
|
||||||
}
|
}
|
||||||
@ -447,14 +440,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
|||||||
thumbnailInfo = thumbnailInfo
|
thumbnailInfo = thumbnailInfo
|
||||||
),
|
),
|
||||||
url = attachment.queryUri.toString(),
|
url = attachment.queryUri.toString(),
|
||||||
relatesTo = rootThreadEventId?.let {
|
relatesTo = rootThreadEventId?.let { generateThreadRelationContent(it) }
|
||||||
RelationDefaultContent(
|
|
||||||
type = RelationType.THREAD,
|
|
||||||
eventId = it,
|
|
||||||
isFallingBack = true,
|
|
||||||
inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(it))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
return createMessageEvent(roomId, content)
|
return createMessageEvent(roomId, content)
|
||||||
}
|
}
|
||||||
@ -479,14 +465,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
|||||||
waveform = waveformSanitizer.sanitize(attachment.waveform)
|
waveform = waveformSanitizer.sanitize(attachment.waveform)
|
||||||
),
|
),
|
||||||
voiceMessageIndicator = if (!isVoiceMessage) null else emptyMap(),
|
voiceMessageIndicator = if (!isVoiceMessage) null else emptyMap(),
|
||||||
relatesTo = rootThreadEventId?.let {
|
relatesTo = rootThreadEventId?.let { generateThreadRelationContent(it) }
|
||||||
RelationDefaultContent(
|
|
||||||
type = RelationType.THREAD,
|
|
||||||
eventId = it,
|
|
||||||
isFallingBack = true,
|
|
||||||
inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(it))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
return createMessageEvent(roomId, content)
|
return createMessageEvent(roomId, content)
|
||||||
}
|
}
|
||||||
@ -500,14 +479,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
|||||||
size = attachment.size
|
size = attachment.size
|
||||||
),
|
),
|
||||||
url = attachment.queryUri.toString(),
|
url = attachment.queryUri.toString(),
|
||||||
relatesTo = rootThreadEventId?.let {
|
relatesTo = rootThreadEventId?.let { generateThreadRelationContent(it) }
|
||||||
RelationDefaultContent(
|
|
||||||
type = RelationType.THREAD,
|
|
||||||
eventId = it,
|
|
||||||
isFallingBack = true,
|
|
||||||
inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(it))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
return createMessageEvent(roomId, content)
|
return createMessageEvent(roomId, content)
|
||||||
}
|
}
|
||||||
@ -629,6 +601,14 @@ internal class LocalEchoEventFactory @Inject constructor(
|
|||||||
return createMessageEvent(roomId, content)
|
return createMessageEvent(roomId, content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun generateThreadRelationContent(rootThreadEventId: String) =
|
||||||
|
RelationDefaultContent(
|
||||||
|
type = RelationType.THREAD,
|
||||||
|
eventId = rootThreadEventId,
|
||||||
|
isFallingBack = true,
|
||||||
|
inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(rootThreadEventId))
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user