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

Reply to ended polls events (PSG-1131) #1685

Merged
merged 4 commits into from
Jan 19, 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
21 changes: 7 additions & 14 deletions MatrixSDK/Data/MXRoom.m
Original file line number Diff line number Diff line change
Expand Up @@ -2194,15 +2194,9 @@ - (void)getReplyContentBodiesWithEventToReply:(MXEvent*)eventToReply
}
if (eventToReply.eventType == MXEventTypePollEnd)
{
MXEvent* pollStartEvent = [mxSession.store eventWithEventId:eventToReply.relatesTo.eventId inRoom:self.roomId];

if (pollStartEvent) {
NSString *question = [MXEventContentPollStart modelFromJSON:pollStartEvent.content].question;
senderMessageBody = question;
} else {
// we need a fallback to avoid crashes since the m.poll.start event may be missing.
senderMessageBody = eventToReply.relatesTo.eventId;
}
// The "Ended poll" text is not meant to be localized from the sender side.
// This is why here we use a "default localizer" providing the english version of it.
senderMessageBody = MXSendReplyEventDefaultStringLocalizer.new.replyToEndedPoll;
}
else if (eventToReply.eventType == MXEventTypeBeaconInfo)
{
Expand Down Expand Up @@ -2278,8 +2272,7 @@ - (void)getReplyContentBodiesWithEventToReply:(MXEvent*)eventToReply
*replyContentFormattedBody = [self replyMessageFormattedBodyFromEventToReply:eventToReply
senderMessageFormattedBody:senderMessageFormattedBody
isSenderMessageAnEmote:isSenderMessageAnEmote
replyFormattedMessage:finalFormattedTextMessage
stringLocalizer:stringLocalizer];
replyFormattedMessage:finalFormattedTextMessage];
}
}

Expand Down Expand Up @@ -2369,15 +2362,13 @@ - (NSString*)replyMessageBodyFromSender:(NSString*)sender
@param senderMessageFormattedBody The message body of the sender.
@param isSenderMessageAnEmote Indicate if the sender message is an emote (/me).
@param replyFormattedMessage The response for the sender message. HTML formatted string if any otherwise non formatted string as reply formatted body is mandatory.
@param stringLocalizer string localizations used when building formatted body.

@return reply message body.
*/
- (NSString*)replyMessageFormattedBodyFromEventToReply:(MXEvent*)eventToReply
senderMessageFormattedBody:(NSString*)senderMessageFormattedBody
isSenderMessageAnEmote:(BOOL)isSenderMessageAnEmote
replyFormattedMessage:(NSString*)replyFormattedMessage
stringLocalizer:(id<MXSendReplyEventStringLocalizerProtocol>)stringLocalizer
{
NSString *eventId = eventToReply.eventId;
NSString *roomId = eventToReply.roomId;
Expand Down Expand Up @@ -2423,7 +2414,9 @@ - (NSString*)replyMessageFormattedBodyFromEventToReply:(MXEvent*)eventToReply
[replyMessageFormattedBody appendString:@"<mx-reply><blockquote>"];

// Add event link
[replyMessageFormattedBody appendFormat:@"<a href=\"%@\">%@</a> ", eventPermalink, stringLocalizer.messageToReplyToPrefix];
// The "In reply to" string is not meant to be localized from the sender side.
// This is how here we use the default string localizer to send the english version of it.
[replyMessageFormattedBody appendFormat:@"<a href=\"%@\">%@</a> ", eventPermalink, MXSendReplyEventDefaultStringLocalizer.new.messageToReplyToPrefix];

if (isSenderMessageAnEmote)
{
Expand Down
2 changes: 2 additions & 0 deletions MatrixSDK/Data/MXSendReplyEventDefaultStringLocalizer.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ @interface MXSendReplyEventDefaultStringLocalizer ()
@property (nonatomic, strong) NSString *senderSentTheirLocation;
@property (nonatomic, strong) NSString *senderSentTheirLiveLocation;
@property (nonatomic, strong) NSString *messageToReplyToPrefix;
@property (nonatomic, strong) NSString *replyToEndedPoll;

@end

Expand All @@ -43,6 +44,7 @@ - (instancetype)init
_senderSentTheirLocation = @"has shared their location.";
_senderSentTheirLiveLocation = @"Live location.";
_messageToReplyToPrefix = @"In reply to";
_replyToEndedPoll = @"Ended poll";
}
return self;
}
Expand Down
1 change: 1 addition & 0 deletions MatrixSDK/Data/MXSendReplyEventStringLocalizerProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSString *)senderSentTheirLocation;
- (NSString *)senderSentTheirLiveLocation;
- (NSString *)messageToReplyToPrefix;
- (NSString *)replyToEndedPoll;

@end

Expand Down
1 change: 1 addition & 0 deletions changelog.d/pr-1685.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Messages' replies: fix localizations issues.