Editing: default to MessageContent.body when no formattedBody is present (#7592)
				
					
				
			* Editing: default to `MessageContent.body` when no `formattedBody` is present * Update docs
This commit is contained in:
		
							parent
							
								
									54fcdcdb6d
								
							
						
					
					
						commit
						10775ab2f3
					
				
							
								
								
									
										1
									
								
								changelog.d/7574.sdk
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								changelog.d/7574.sdk
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
If message content has no `formattedBody`, default to `body` when editing.
 | 
			
		||||
@ -180,11 +180,13 @@ fun TimelineEvent.isRootThread(): Boolean {
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get the latest message body, after a possible edition, stripping the reply prefix if necessary.
 | 
			
		||||
 * @param formatted Indicates whether the formatted HTML body of the message should be retrieved of the plain text one.
 | 
			
		||||
 * @return If [formatted] is `true`, the HTML body of the message will be retrieved if available. Otherwise, the plain text/markdown version will be returned.
 | 
			
		||||
 */
 | 
			
		||||
fun TimelineEvent.getTextEditableContent(formatted: Boolean): String {
 | 
			
		||||
    val lastMessageContent = getLastMessageContent()
 | 
			
		||||
    val lastContentBody = if (formatted && lastMessageContent is MessageContentWithFormattedBody) {
 | 
			
		||||
        lastMessageContent.formattedBody
 | 
			
		||||
        lastMessageContent.formattedBody ?: lastMessageContent.body
 | 
			
		||||
    } else {
 | 
			
		||||
        lastMessageContent?.body
 | 
			
		||||
    } ?: return ""
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user