Reformat and add trailing commas

This commit is contained in:
Florian Renaud 2022-10-14 11:35:53 +02:00
parent 06bceef7c0
commit fb9c747a20
2 changed files with 35 additions and 20 deletions

View File

@ -72,7 +72,7 @@ interface SendService {
text: String, text: String,
formattedText: String? = null, formattedText: String? = null,
autoMarkdown: Boolean, autoMarkdown: Boolean,
rootThreadEventId: String? = null rootThreadEventId: String? = null,
): Cancelable ): Cancelable
/** /**
@ -90,7 +90,7 @@ interface SendService {
compressBeforeSending: Boolean, compressBeforeSending: Boolean,
roomIds: Set<String>, roomIds: Set<String>,
rootThreadEventId: String? = null, rootThreadEventId: String? = null,
relatesTo: RelationDefaultContent? = null relatesTo: RelationDefaultContent? = null,
): Cancelable ): Cancelable
/** /**
@ -106,7 +106,7 @@ interface SendService {
attachments: List<ContentAttachmentData>, attachments: List<ContentAttachmentData>,
compressBeforeSending: Boolean, compressBeforeSending: Boolean,
roomIds: Set<String>, roomIds: Set<String>,
rootThreadEventId: String? = null rootThreadEventId: String? = null,
): Cancelable ): Cancelable
/** /**

View File

@ -127,7 +127,7 @@ internal class LocalEchoEventFactory @Inject constructor(
newBodyFormattedText: CharSequence?, newBodyFormattedText: CharSequence?,
newBodyAutoMarkdown: Boolean, newBodyAutoMarkdown: Boolean,
msgType: String, msgType: String,
compatibilityText: String compatibilityText: String,
): Event { ): Event {
val content = if (newBodyFormattedText != null) { val content = if (newBodyFormattedText != null) {
TextContent(newBodyText.toString(), newBodyFormattedText.toString()).toMessageTextContent(msgType) TextContent(newBodyText.toString(), newBodyFormattedText.toString()).toMessageTextContent(msgType)
@ -148,7 +148,7 @@ internal class LocalEchoEventFactory @Inject constructor(
private fun createPollContent( private fun createPollContent(
question: String, question: String,
options: List<String>, options: List<String>,
pollType: PollType pollType: PollType,
): MessagePollContent { ): MessagePollContent {
return MessagePollContent( return MessagePollContent(
unstablePollCreationInfo = PollCreationInfo( unstablePollCreationInfo = PollCreationInfo(
@ -166,7 +166,7 @@ internal class LocalEchoEventFactory @Inject constructor(
pollType: PollType, pollType: PollType,
targetEventId: String, targetEventId: String,
question: String, question: String,
options: List<String> options: List<String>,
): Event { ): Event {
val newContent = MessagePollContent( val newContent = MessagePollContent(
relatesTo = RelationDefaultContent(RelationType.REPLACE, targetEventId), relatesTo = RelationDefaultContent(RelationType.REPLACE, targetEventId),
@ -186,7 +186,7 @@ internal class LocalEchoEventFactory @Inject constructor(
fun createPollReplyEvent( fun createPollReplyEvent(
roomId: String, roomId: String,
pollEventId: String, pollEventId: String,
answerId: String answerId: String,
): Event { ): Event {
val content = MessagePollResponseContent( val content = MessagePollResponseContent(
body = answerId, body = answerId,
@ -212,7 +212,7 @@ internal class LocalEchoEventFactory @Inject constructor(
roomId: String, roomId: String,
pollType: PollType, pollType: PollType,
question: String, question: String,
options: List<String> options: List<String>,
): Event { ): Event {
val content = createPollContent(question, options, pollType) val content = createPollContent(question, options, pollType)
val localId = LocalEcho.createLocalEchoId() val localId = LocalEcho.createLocalEchoId()
@ -229,7 +229,7 @@ internal class LocalEchoEventFactory @Inject constructor(
fun createEndPollEvent( fun createEndPollEvent(
roomId: String, roomId: String,
eventId: String eventId: String,
): Event { ): Event {
val content = MessageEndPollContent( val content = MessageEndPollContent(
relatesTo = RelationDefaultContent( relatesTo = RelationDefaultContent(
@ -254,7 +254,7 @@ internal class LocalEchoEventFactory @Inject constructor(
latitude: Double, latitude: Double,
longitude: Double, longitude: Double,
uncertainty: Double?, uncertainty: Double?,
isUserLocation: Boolean isUserLocation: Boolean,
): Event { ): Event {
val geoUri = buildGeoUri(latitude, longitude, uncertainty) val geoUri = buildGeoUri(latitude, longitude, uncertainty)
val assetType = if (isUserLocation) LocationAssetType.SELF else LocationAssetType.PIN val assetType = if (isUserLocation) LocationAssetType.SELF else LocationAssetType.PIN
@ -274,7 +274,7 @@ internal class LocalEchoEventFactory @Inject constructor(
roomId: String, roomId: String,
latitude: Double, latitude: Double,
longitude: Double, longitude: Double,
uncertainty: Double? uncertainty: Double?,
): Event { ): Event {
val geoUri = buildGeoUri(latitude, longitude, uncertainty) val geoUri = buildGeoUri(latitude, longitude, uncertainty)
val content = MessageBeaconLocationDataContent( val content = MessageBeaconLocationDataContent(
@ -305,7 +305,7 @@ internal class LocalEchoEventFactory @Inject constructor(
newBodyText: String, newBodyText: String,
autoMarkdown: Boolean, autoMarkdown: Boolean,
msgType: String, msgType: String,
compatibilityText: String compatibilityText: String,
): Event { ): Event {
val permalink = permalinkFactory.createPermalink(roomId, originalEvent.root.eventId ?: "", false) val permalink = permalinkFactory.createPermalink(roomId, originalEvent.root.eventId ?: "", false)
val userLink = originalEvent.root.senderId?.let { permalinkFactory.createPermalink(it, false) } ?: "" val userLink = originalEvent.root.senderId?.let { permalinkFactory.createPermalink(it, false) } ?: ""
@ -359,7 +359,7 @@ internal class LocalEchoEventFactory @Inject constructor(
attachment, attachment,
isVoiceMessage = true, isVoiceMessage = true,
rootThreadEventId = rootThreadEventId, rootThreadEventId = rootThreadEventId,
relatesTo relatesTo,
) )
ContentAttachmentData.Type.FILE -> createFileEvent(roomId, attachment, rootThreadEventId, relatesTo) ContentAttachmentData.Type.FILE -> createFileEvent(roomId, attachment, rootThreadEventId, relatesTo)
} }
@ -385,7 +385,12 @@ internal class LocalEchoEventFactory @Inject constructor(
) )
} }
private fun createImageEvent(roomId: String, attachment: ContentAttachmentData, rootThreadEventId: String?, relatesTo: RelationDefaultContent?): Event { private fun createImageEvent(
roomId: String,
attachment: ContentAttachmentData,
rootThreadEventId: String?,
relatesTo: RelationDefaultContent?,
): Event {
var width = attachment.width var width = attachment.width
var height = attachment.height var height = attachment.height
@ -415,7 +420,12 @@ internal class LocalEchoEventFactory @Inject constructor(
return createMessageEvent(roomId, content) return createMessageEvent(roomId, content)
} }
private fun createVideoEvent(roomId: String, attachment: ContentAttachmentData, rootThreadEventId: String?, relatesTo: RelationDefaultContent?): Event { private fun createVideoEvent(
roomId: String,
attachment: ContentAttachmentData,
rootThreadEventId: String?,
relatesTo: RelationDefaultContent?,
): Event {
val mediaDataRetriever = MediaMetadataRetriever() val mediaDataRetriever = MediaMetadataRetriever()
mediaDataRetriever.setDataSource(context, attachment.queryUri) mediaDataRetriever.setDataSource(context, attachment.queryUri)
@ -478,7 +488,12 @@ internal class LocalEchoEventFactory @Inject constructor(
return createMessageEvent(roomId, content) return createMessageEvent(roomId, content)
} }
private fun createFileEvent(roomId: String, attachment: ContentAttachmentData, rootThreadEventId: String?, relatesTo: RelationDefaultContent?): Event { private fun createFileEvent(
roomId: String,
attachment: ContentAttachmentData,
rootThreadEventId: String?,
relatesTo: RelationDefaultContent?,
): Event {
val content = MessageFileContent( val content = MessageFileContent(
msgType = MessageType.MSGTYPE_FILE, msgType = MessageType.MSGTYPE_FILE,
body = attachment.name ?: "file", body = attachment.name ?: "file",
@ -539,7 +554,7 @@ internal class LocalEchoEventFactory @Inject constructor(
text: CharSequence, text: CharSequence,
msgType: String, msgType: String,
autoMarkdown: Boolean, autoMarkdown: Boolean,
formattedText: String? formattedText: String?,
): Event { ): Event {
val content = formattedText?.let { TextContent(text.toString(), it) } ?: createTextContent(text, autoMarkdown) val content = formattedText?.let { TextContent(text.toString(), it) } ?: createTextContent(text, autoMarkdown)
return createEvent( return createEvent(
@ -568,7 +583,7 @@ internal class LocalEchoEventFactory @Inject constructor(
replyTextFormatted: CharSequence?, replyTextFormatted: CharSequence?,
autoMarkdown: Boolean, autoMarkdown: Boolean,
rootThreadEventId: String? = null, rootThreadEventId: String? = null,
showInThread: Boolean showInThread: Boolean,
): Event? { ): Event? {
// Fallbacks and event representation // Fallbacks and event representation
// TODO Add error/warning logs when any of this is null // TODO Add error/warning logs when any of this is null
@ -614,7 +629,7 @@ internal class LocalEchoEventFactory @Inject constructor(
type = RelationType.THREAD, type = RelationType.THREAD,
eventId = rootThreadEventId, eventId = rootThreadEventId,
isFallingBack = true, isFallingBack = true,
inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(rootThreadEventId)) inReplyTo = ReplyToContent(eventId = localEchoRepository.getLatestThreadEvent(rootThreadEventId)),
) )
/** /**
@ -760,7 +775,7 @@ internal class LocalEchoEventFactory @Inject constructor(
text: String, text: String,
formattedText: String?, formattedText: String?,
autoMarkdown: Boolean, autoMarkdown: Boolean,
rootThreadEventId: String? rootThreadEventId: String?,
): Event { ): Event {
val messageContent = quotedEvent.getLastMessageContent() val messageContent = quotedEvent.getLastMessageContent()
val textMsg = if (messageContent is MessageContentWithFormattedBody) { messageContent.formattedBody } else { messageContent?.body } val textMsg = if (messageContent is MessageContentWithFormattedBody) { messageContent.formattedBody } else { messageContent?.body }