mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
parent
9733e08a78
commit
3f40b1c804
2 changed files with 41 additions and 32 deletions
|
@ -6,6 +6,7 @@ Improvements:
|
||||||
* i18n: Add Spanish (sp).
|
* i18n: Add Spanish (sp).
|
||||||
* Settings: Make advanced info copyable (#2023).
|
* Settings: Make advanced info copyable (#2023).
|
||||||
* Settings: Made cryptography info copyable, thanks to @daverPL (PR #1999).
|
* Settings: Made cryptography info copyable, thanks to @daverPL (PR #1999).
|
||||||
|
* Room settings: Anyone can now set a room alias (#2033).
|
||||||
|
|
||||||
Bug fix:
|
Bug fix:
|
||||||
* Fix missing read receipts when lazy-loading room members.
|
* Fix missing read receipts when lazy-loading room members.
|
||||||
|
|
|
@ -707,7 +707,7 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
|
||||||
currentAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
|
currentAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
|
||||||
|
|
||||||
// Check whether the user is allowed to modify the main address.
|
// Check whether the user is allowed to modify the main address.
|
||||||
if (roomAddressNewAliasIndex != -1)
|
if ([self canSetCanonicalAlias])
|
||||||
{
|
{
|
||||||
// Compare the selected alias with the current main address
|
// Compare the selected alias with the current main address
|
||||||
NSString *currentCanonicalAlias = mxRoomState.canonicalAlias;
|
NSString *currentCanonicalAlias = mxRoomState.canonicalAlias;
|
||||||
|
@ -791,23 +791,21 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
|
||||||
|
|
||||||
}]];
|
}]];
|
||||||
|
|
||||||
// Check whether the user is allowed to remove a room alias.
|
// The user can only delete alias they has created, even if the Admin has set it as canonical.
|
||||||
if (roomAddressNewAliasIndex != -1)
|
// So, let the server answer if it's possible to delete an alias.
|
||||||
{
|
[currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"delete"]
|
||||||
[currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"delete"]
|
style:UIAlertActionStyleDefault
|
||||||
style:UIAlertActionStyleDefault
|
handler:^(UIAlertAction * action) {
|
||||||
handler:^(UIAlertAction * action) {
|
|
||||||
|
if (weakSelf)
|
||||||
if (weakSelf)
|
{
|
||||||
{
|
typeof(self) self = weakSelf;
|
||||||
typeof(self) self = weakSelf;
|
self->currentAlert = nil;
|
||||||
self->currentAlert = nil;
|
|
||||||
|
[self removeRoomAlias:roomAliasLabel.text];
|
||||||
[self removeRoomAlias:roomAliasLabel.text];
|
}
|
||||||
}
|
|
||||||
|
}]];
|
||||||
}]];
|
|
||||||
}
|
|
||||||
|
|
||||||
[currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"]
|
[currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"]
|
||||||
style:UIAlertActionStyleCancel
|
style:UIAlertActionStyleCancel
|
||||||
|
@ -1964,18 +1962,9 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
|
||||||
roomAddressNewAliasIndex = -1;
|
roomAddressNewAliasIndex = -1;
|
||||||
|
|
||||||
count = (localAddressesCount ? roomAddresses.count : roomAddresses.count + 1);
|
count = (localAddressesCount ? roomAddresses.count : roomAddresses.count + 1);
|
||||||
|
|
||||||
if (self.mainSession)
|
// Everyone can add an alias: display the "add address" entry
|
||||||
{
|
roomAddressNewAliasIndex = count++;
|
||||||
// Check user's power level to know whether the user is allowed to add room alias
|
|
||||||
MXRoomPowerLevels *powerLevels = [mxRoomState powerLevels];
|
|
||||||
NSInteger oneSelfPowerLevel = [powerLevels powerLevelOfUserWithUserID:self.mainSession.myUser.userId];
|
|
||||||
|
|
||||||
if (oneSelfPowerLevel >= [powerLevels minimumPowerLevelForSendingEventAsStateEvent:kMXEventTypeStringRoomAliases])
|
|
||||||
{
|
|
||||||
roomAddressNewAliasIndex = count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (section == ROOM_SETTINGS_RELATED_GROUPS_SECTION_INDEX)
|
else if (section == ROOM_SETTINGS_RELATED_GROUPS_SECTION_INDEX)
|
||||||
{
|
{
|
||||||
|
@ -2786,8 +2775,9 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
|
||||||
{
|
{
|
||||||
if (localAddressesCount != 0 || indexPath.row != 0)
|
if (localAddressesCount != 0 || indexPath.row != 0)
|
||||||
{
|
{
|
||||||
// The user is allowed to remove a room alias only if he is allowed to create alias too.
|
// The user can only delete alias they has created, even if the Admin has set it as canonical.
|
||||||
return (roomAddressNewAliasIndex != -1);
|
// So, let the server answer if it's possible to delete an alias.
|
||||||
|
return YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (indexPath.section == ROOM_SETTINGS_RELATED_GROUPS_SECTION_INDEX && indexPath.row != relatedGroupsNewGroupIndex)
|
else if (indexPath.section == ROOM_SETTINGS_RELATED_GROUPS_SECTION_INDEX && indexPath.row != relatedGroupsNewGroupIndex)
|
||||||
|
@ -3218,6 +3208,24 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)canSetCanonicalAlias
|
||||||
|
{
|
||||||
|
BOOL canSetCanonicalAlias = NO;
|
||||||
|
if (self.mainSession)
|
||||||
|
{
|
||||||
|
// Check user's power level to know whether the user is allowed to set the main address
|
||||||
|
MXRoomPowerLevels *powerLevels = [mxRoomState powerLevels];
|
||||||
|
NSInteger oneSelfPowerLevel = [powerLevels powerLevelOfUserWithUserID:self.mainSession.myUser.userId];
|
||||||
|
|
||||||
|
if (oneSelfPowerLevel >= [powerLevels minimumPowerLevelForSendingEventAsStateEvent:kMXEventTypeStringRoomAliases])
|
||||||
|
{
|
||||||
|
canSetCanonicalAlias = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return canSetCanonicalAlias;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)shouldRemoveCanonicalAlias:(void (^)())didRemoveCanonicalAlias
|
- (void)shouldRemoveCanonicalAlias:(void (^)())didRemoveCanonicalAlias
|
||||||
{
|
{
|
||||||
// Prompt the user before removing the current main address
|
// Prompt the user before removing the current main address
|
||||||
|
|
Loading…
Reference in a new issue