Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add markdown property to NCChatMessage #1328

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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