mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Voiceover fix: Message author read as thread name (#1437) FREEBIE
There was a bug in voiceover mode. When reading messages, Voiceover would read out "message author: message content" for each chat bubble, but the message author was always the name of the chat. So if it was a contact chat, every message would be read as if from the other party, and if it was a group chat, every message would be from the title of the group. This patch looks up the display name for the given signal id so Voiceover reads the correct name for each message. It will read "Me" if the message is outgoing.
This commit is contained in:
parent
89451013d9
commit
b40f6acd01
|
@ -9,6 +9,7 @@
|
|||
#import "OWSMessageData.h"
|
||||
#import "OWSMessageEditing.h"
|
||||
#import "TSInfoMessage.h"
|
||||
#import "ContactsManagerProtocol.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
@ -19,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@interface TSMessageAdapter : NSObject <OWSMessageData>
|
||||
|
||||
+ (id<OWSMessageData>)messageViewDataWithInteraction:(TSInteraction *)interaction inThread:(TSThread *)thread;
|
||||
+ (id<OWSMessageData>)messageViewDataWithInteraction:(TSInteraction *)interaction inThread:(TSThread *)thread contactsManager:(id<ContactsManagerProtocol>)contactsManager;
|
||||
|
||||
@property (nonatomic) TSInteraction *interaction;
|
||||
@property (readonly) TSInfoMessageType infoMessageType;
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
|
||||
// OR for groups
|
||||
|
||||
@property (nonatomic, retain) NSString *senderId;
|
||||
@property (nonatomic, retain) NSString *senderDisplayName;
|
||||
@property (nonatomic, copy) NSString *senderId;
|
||||
@property (nonatomic, copy) NSString *senderDisplayName;
|
||||
|
||||
// for InfoMessages
|
||||
|
||||
|
@ -91,7 +91,7 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
+ (id<OWSMessageData>)messageViewDataWithInteraction:(TSInteraction *)interaction inThread:(TSThread *)thread
|
||||
+ (id<OWSMessageData>)messageViewDataWithInteraction:(TSInteraction *)interaction inThread:(TSThread *)thread contactsManager:(id<ContactsManagerProtocol>)contactsManager
|
||||
{
|
||||
TSMessageAdapter *adapter = [[TSMessageAdapter alloc] initWithInteraction:interaction];
|
||||
|
||||
|
@ -100,7 +100,7 @@
|
|||
if ([interaction isKindOfClass:[TSIncomingMessage class]]) {
|
||||
NSString *contactId = ((TSContactThread *)thread).contactIdentifier;
|
||||
adapter.senderId = contactId;
|
||||
adapter.senderDisplayName = contactId;
|
||||
adapter.senderDisplayName = [contactsManager nameStringForPhoneIdentifier:contactId];
|
||||
adapter.messageType = TSIncomingMessageAdapter;
|
||||
} else {
|
||||
adapter.senderId = ME_MESSAGE_IDENTIFIER;
|
||||
|
@ -111,7 +111,7 @@
|
|||
if ([interaction isKindOfClass:[TSIncomingMessage class]]) {
|
||||
TSIncomingMessage *message = (TSIncomingMessage *)interaction;
|
||||
adapter.senderId = message.authorId;
|
||||
adapter.senderDisplayName = message.authorId;
|
||||
adapter.senderDisplayName = [contactsManager nameStringForPhoneIdentifier:message.authorId];
|
||||
adapter.messageType = TSIncomingMessageAdapter;
|
||||
} else {
|
||||
adapter.senderId = ME_MESSAGE_IDENTIFIER;
|
||||
|
@ -216,13 +216,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (NSString *)senderDisplayName {
|
||||
if (self.thread) {
|
||||
return _thread.name;
|
||||
}
|
||||
return _senderDisplayName;
|
||||
}
|
||||
|
||||
- (NSDate *)date {
|
||||
return self.messageDate;
|
||||
}
|
||||
|
|
|
@ -1957,7 +1957,7 @@ typedef enum : NSUInteger {
|
|||
id<OWSMessageData> messageAdapter = [self.messageAdapterCache objectForKey:interaction.uniqueId];
|
||||
|
||||
if (!messageAdapter) {
|
||||
messageAdapter = [TSMessageAdapter messageViewDataWithInteraction:interaction inThread:self.thread];
|
||||
messageAdapter = [TSMessageAdapter messageViewDataWithInteraction:interaction inThread:self.thread contactsManager:self.contactsManager];
|
||||
[self.messageAdapterCache setObject:messageAdapter forKey: interaction.uniqueId];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue