Merge pull request #2442 from vector-im/labs_reactions

Reactions: Add a labs setting
This commit is contained in:
manuroe
2019-05-20 17:52:29 +02:00
committed by GitHub
6 changed files with 47 additions and 2 deletions
+1
View File
@@ -406,6 +406,7 @@
"settings_labs_room_members_lazy_loading" = "Lazy load rooms members";
"settings_labs_room_members_lazy_loading_error_message" = "Your homeserver does not support lazy loading of room members yet. Try later.";
"settings_labs_create_conference_with_jitsi" = "Create conference calls with jitsi";
"settings_labs_message_reaction" = "React to messages with emoji";
"settings_version" = "Version %@";
"settings_olm_version" = "Olm Version %@";
+4
View File
@@ -2474,6 +2474,10 @@ internal enum VectorL10n {
internal static var settingsLabsE2eEncryptionPromptMessage: String {
return VectorL10n.tr("Vector", "settings_labs_e2e_encryption_prompt_message")
}
/// React to messages with emoji
internal static var settingsLabsMessageReaction: String {
return VectorL10n.tr("Vector", "settings_labs_message_reaction")
}
/// Lazy load rooms members
internal static var settingsLabsRoomMembersLazyLoading: String {
return VectorL10n.tr("Vector", "settings_labs_room_members_lazy_loading")
@@ -26,6 +26,7 @@ final class RiotSettings: NSObject {
static let enableCrashReport = "enableCrashReport"
static let enableRageShake = "enableRageShake"
static let createConferenceCallsWithJitsi = "createConferenceCallsWithJitsi"
static let messageReaction = "messageReaction"
static let userInterfaceTheme = "userInterfaceTheme"
static let notificationsShowDecryptedContent = "showDecryptedContent"
static let pinRoomsWithMissedNotifications = "pinRoomsWithMissedNotif"
@@ -119,4 +120,12 @@ final class RiotSettings: NSObject {
UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.createConferenceCallsWithJitsi)
}
}
var messageReaction: Bool {
get {
return UserDefaults.standard.bool(forKey: UserDefaultsKeys.messageReaction)
} set {
UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.messageReaction)
}
}
}
@@ -59,6 +59,7 @@
self.markTimelineInitialEvent = NO;
self.showBubbleDateTimeOnSelection = YES;
self.showReactions = RiotSettings.shared.messageReaction;
// Observe user interface theme change.
kThemeServiceDidChangeThemeNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kThemeServiceDidChangeThemeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
+1 -1
View File
@@ -5077,7 +5077,7 @@
[self contextualMenuAnimationCompletionAfterBeingShown:YES];
}];
if ([cell isKindOfClass:MXKRoomBubbleTableViewCell.class])
if (RiotSettings.shared.messageReaction && [cell isKindOfClass:MXKRoomBubbleTableViewCell.class])
{
// Note: For the moment, we use the frame of the cell instead of the component
// From UI perpective, that means the menu will be around a paragraph instead of a message
+31 -1
View File
@@ -119,7 +119,8 @@ enum
enum
{
LABS_USE_ROOM_MEMBERS_LAZY_LOADING_INDEX = 0,
LABS_USE_JITSI_WIDGET_INDEX = 0,
LABS_USE_JITSI_WIDGET_INDEX,
LABS_USE_MESSAGE_REACTION_INDEX,
LABS_CRYPTO_INDEX,
LABS_COUNT
};
@@ -2136,6 +2137,19 @@ SignOutAlertPresenterDelegate>
cell = labelAndSwitchCell;
}
else if (row == LABS_USE_MESSAGE_REACTION_INDEX)
{
MXKTableViewCellWithLabelAndSwitch* labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];
labelAndSwitchCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_labs_message_reaction", @"Vector", nil);
labelAndSwitchCell.mxkSwitch.on = RiotSettings.shared.messageReaction;
labelAndSwitchCell.mxkSwitch.onTintColor = ThemeService.shared.theme.tintColor;
labelAndSwitchCell.mxkSwitch.enabled = YES;
[labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleMessageReaction:) forControlEvents:UIControlEventTouchUpInside];
cell = labelAndSwitchCell;
}
else if (row == LABS_CRYPTO_INDEX)
{
MXSession* session = [AppDelegate theDelegate].mxSessions[0];
@@ -3035,6 +3049,22 @@ SignOutAlertPresenterDelegate>
}
}
- (void)toggleMessageReaction:(id)sender
{
if (sender && [sender isKindOfClass:UISwitch.class])
{
UISwitch *switchButton = (UISwitch*)sender;
RiotSettings.shared.messageReaction = switchButton.isOn;
// Reset cached room data sources
MXKRoomDataSourceManager *roomDataSourceManager = [MXKRoomDataSourceManager sharedManagerForMatrixSession:self.mainSession];
[roomDataSourceManager reset];
[self.tableView reloadData];
}
}
- (void)toggleLabsEndToEndEncryption:(id)sender
{
if (sender && [sender isKindOfClass:UISwitch.class])