Skip to content

Commit

Permalink
Merge pull request #1328 from nextcloud/add-markdown-property
Browse files Browse the repository at this point in the history
Add markdown property to NCChatMessage
  • Loading branch information
SystemKeeper authored Aug 15, 2023
2 parents 03673b9 + 519ea37 commit 369d242
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions NextcloudTalk/NCChatMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ typedef void (^GetReferenceDataCompletionBlock)(NCChatMessage *message, NSDictio
@property (nonatomic, assign) BOOL collapsedIncludesActorSelf;
@property (nonatomic, assign) BOOL collapsedIncludesUserSelf;
@property (nonatomic, assign) BOOL isCollapsed;
@property (nonatomic, assign) BOOL isMarkdownMessage;

+ (instancetype)messageWithDictionary:(NSDictionary *)messageDict;
+ (instancetype)messageWithDictionary:(NSDictionary *)messageDict andAccountId:(NSString *)accountId;
Expand Down
11 changes: 11 additions & 0 deletions NextcloudTalk/NCChatMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ + (instancetype)messageWithDictionary:(NSDictionary *)messageDict
message.referenceId = [messageDict objectForKey:@"referenceId"];
message.messageType = [messageDict objectForKey:@"messageType"];
message.expirationTimestamp = [[messageDict objectForKey:@"expirationTimestamp"] integerValue];
message.isMarkdownMessage = [[messageDict objectForKey:@"markdown"] boolValue];

id actorDisplayName = [messageDict objectForKey:@"actorDisplayName"];
if (!actorDisplayName) {
Expand Down Expand Up @@ -169,6 +170,7 @@ + (void)updateChatMessage:(NCChatMessage *)managedChatMessage withChatMessage:(N
managedChatMessage.messageType = chatMessage.messageType;
managedChatMessage.reactionsJSONString = chatMessage.reactionsJSONString;
managedChatMessage.expirationTimestamp = chatMessage.expirationTimestamp;
managedChatMessage.isMarkdownMessage = chatMessage.isMarkdownMessage;

if (!isRoomLastMessage) {
managedChatMessage.reactionsSelfJSONString = chatMessage.reactionsSelfJSONString;
Expand Down Expand Up @@ -215,6 +217,7 @@ - (id)copyWithZone:(NSZone *)zone
messageCopy.isDeleting = _isDeleting;
messageCopy.isOfflineMessage = _isOfflineMessage;
messageCopy.isSilent = _isSilent;
messageCopy.isMarkdownMessage = _isMarkdownMessage;

return messageCopy;
}
Expand Down Expand Up @@ -508,6 +511,10 @@ - (NSMutableAttributedString *)parsedMarkdown
return nil;
}

if (!_isMarkdownMessage) {
return parsedMessage;
}

return [SwiftMarkdownObjCBridge parseMarkdownWithMarkdownString:parsedMessage];
}

Expand All @@ -524,6 +531,10 @@ - (NSMutableAttributedString *)parsedMarkdownForChat
return nil;
}

if (!_isMarkdownMessage) {
return parsedMessage;
}

return [SwiftMarkdownObjCBridge parseMarkdownWithMarkdownString:parsedMessage];
}

Expand Down
2 changes: 1 addition & 1 deletion NextcloudTalk/NCDatabaseManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

NSString *const kTalkDatabaseFolder = @"Library/Application Support/Talk";
NSString *const kTalkDatabaseFileName = @"talk.realm";
uint64_t const kTalkDatabaseSchemaVersion = 53;
uint64_t const kTalkDatabaseSchemaVersion = 54;

NSString * const kCapabilitySystemMessages = @"system-messages";
NSString * const kCapabilityNotificationLevels = @"notification-levels";
Expand Down

0 comments on commit 369d242

Please sign in to comment.