mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 17:12:45 +02:00
Rework MXKSlashCommands to a more Swift-friendly form and use it in suggestion module
This commit is contained in:
@@ -39,7 +39,6 @@
|
||||
#import "MXKEncryptionKeysImportView.h"
|
||||
|
||||
#import "NSBundle+MatrixKit.h"
|
||||
#import "MXKSlashCommands.h"
|
||||
#import "MXKSwiftHeader.h"
|
||||
|
||||
#import "MXKPreviewViewController.h"
|
||||
@@ -1284,8 +1283,14 @@ static const CGFloat kCellVisibilityMinimumHeight = 8.0;
|
||||
|
||||
// TODO: display an alert with the cmd usage in case of error or unrecognized cmd.
|
||||
NSString *cmdUsage;
|
||||
|
||||
NSString* kMXKSlashCmdChangeDisplayName = [MXKSlashCommandsHelper commandNameFor:MXKSlashCommandChangeDisplayName];
|
||||
NSString* kMXKSlashCmdJoinRoom = [MXKSlashCommandsHelper commandNameFor:MXKSlashCommandJoinRoom];
|
||||
NSString* kMXKSlashCmdPartRoom = [MXKSlashCommandsHelper commandNameFor:MXKSlashCommandPartRoom];
|
||||
NSString* kMXKSlashCmdChangeRoomTopic = [MXKSlashCommandsHelper commandNameFor:MXKSlashCommandChangeRoomTopic];
|
||||
|
||||
|
||||
if ([cmd isEqualToString:kMXKSlashCmdEmote])
|
||||
if ([cmd isEqualToString:[MXKSlashCommandsHelper commandNameFor:MXKSlashCommandEmote]])
|
||||
{
|
||||
// send message as an emote
|
||||
[self sendTextMessage:string];
|
||||
@@ -1320,7 +1325,7 @@ static const CGFloat kCellVisibilityMinimumHeight = 8.0;
|
||||
else
|
||||
{
|
||||
// Display cmd usage in text input as placeholder
|
||||
cmdUsage = @"Usage: /nick <display_name>";
|
||||
cmdUsage = [MXKSlashCommandsHelper commandUsageFor:MXKSlashCommandChangeDisplayName];
|
||||
}
|
||||
}
|
||||
else if ([string hasPrefix:kMXKSlashCmdJoinRoom])
|
||||
@@ -1355,7 +1360,7 @@ static const CGFloat kCellVisibilityMinimumHeight = 8.0;
|
||||
else
|
||||
{
|
||||
// Display cmd usage in text input as placeholder
|
||||
cmdUsage = @"Usage: /join <room_alias>";
|
||||
cmdUsage = [MXKSlashCommandsHelper commandUsageFor:MXKSlashCommandJoinRoom];
|
||||
}
|
||||
}
|
||||
else if ([string hasPrefix:kMXKSlashCmdPartRoom])
|
||||
@@ -1413,7 +1418,7 @@ static const CGFloat kCellVisibilityMinimumHeight = 8.0;
|
||||
else
|
||||
{
|
||||
// Display cmd usage in text input as placeholder
|
||||
cmdUsage = @"Usage: /part [<room_alias>]";
|
||||
cmdUsage = [MXKSlashCommandsHelper commandUsageFor:MXKSlashCommandPartRoom];
|
||||
}
|
||||
}
|
||||
else if ([string hasPrefix:kMXKSlashCmdChangeRoomTopic])
|
||||
@@ -1445,10 +1450,10 @@ static const CGFloat kCellVisibilityMinimumHeight = 8.0;
|
||||
else
|
||||
{
|
||||
// Display cmd usage in text input as placeholder
|
||||
cmdUsage = @"Usage: /topic <topic>";
|
||||
cmdUsage = [MXKSlashCommandsHelper commandUsageFor:MXKSlashCommandChangeRoomTopic];
|
||||
}
|
||||
}
|
||||
else if ([string hasPrefix:kMXKSlashCmdDiscardSession])
|
||||
else if ([string hasPrefix:[MXKSlashCommandsHelper commandNameFor:MXKSlashCommandDiscardSession]])
|
||||
{
|
||||
[roomDataSource.mxSession.crypto discardOutboundGroupSessionForRoomWithRoomId:roomDataSource.roomId onComplete:^{
|
||||
MXLogDebug(@"[MXKRoomVC] Manually discarded outbound group session");
|
||||
@@ -1470,7 +1475,7 @@ static const CGFloat kCellVisibilityMinimumHeight = 8.0;
|
||||
userId = nil;
|
||||
}
|
||||
|
||||
if ([cmd isEqualToString:kMXKSlashCmdInviteUser])
|
||||
if ([cmd isEqualToString:[MXKSlashCommandsHelper commandNameFor:MXKSlashCommandInviteUser]])
|
||||
{
|
||||
if (userId)
|
||||
{
|
||||
@@ -1489,10 +1494,10 @@ static const CGFloat kCellVisibilityMinimumHeight = 8.0;
|
||||
else
|
||||
{
|
||||
// Display cmd usage in text input as placeholder
|
||||
cmdUsage = @"Usage: /invite <userId>";
|
||||
cmdUsage = [MXKSlashCommandsHelper commandUsageFor:MXKSlashCommandInviteUser];
|
||||
}
|
||||
}
|
||||
else if ([cmd isEqualToString:kMXKSlashCmdKickUser])
|
||||
else if ([cmd isEqualToString:[MXKSlashCommandsHelper commandNameFor:MXKSlashCommandKickUser]])
|
||||
{
|
||||
if (userId)
|
||||
{
|
||||
@@ -1524,10 +1529,10 @@ static const CGFloat kCellVisibilityMinimumHeight = 8.0;
|
||||
else
|
||||
{
|
||||
// Display cmd usage in text input as placeholder
|
||||
cmdUsage = @"Usage: /kick <userId> [<reason>]";
|
||||
cmdUsage = [MXKSlashCommandsHelper commandUsageFor:MXKSlashCommandKickUser];
|
||||
}
|
||||
}
|
||||
else if ([cmd isEqualToString:kMXKSlashCmdBanUser])
|
||||
else if ([cmd isEqualToString:[MXKSlashCommandsHelper commandNameFor:MXKSlashCommandBanUser]])
|
||||
{
|
||||
if (userId)
|
||||
{
|
||||
@@ -1559,10 +1564,10 @@ static const CGFloat kCellVisibilityMinimumHeight = 8.0;
|
||||
else
|
||||
{
|
||||
// Display cmd usage in text input as placeholder
|
||||
cmdUsage = @"Usage: /ban <userId> [<reason>]";
|
||||
cmdUsage = [MXKSlashCommandsHelper commandUsageFor:MXKSlashCommandBanUser];
|
||||
}
|
||||
}
|
||||
else if ([cmd isEqualToString:kMXKSlashCmdUnbanUser])
|
||||
else if ([cmd isEqualToString:[MXKSlashCommandsHelper commandNameFor:MXKSlashCommandUnbanUser]])
|
||||
{
|
||||
if (userId)
|
||||
{
|
||||
@@ -1581,10 +1586,10 @@ static const CGFloat kCellVisibilityMinimumHeight = 8.0;
|
||||
else
|
||||
{
|
||||
// Display cmd usage in text input as placeholder
|
||||
cmdUsage = @"Usage: /unban <userId>";
|
||||
cmdUsage = [MXKSlashCommandsHelper commandUsageFor:MXKSlashCommandUnbanUser];
|
||||
}
|
||||
}
|
||||
else if ([cmd isEqualToString:kMXKSlashCmdSetUserPowerLevel])
|
||||
else if ([cmd isEqualToString:[MXKSlashCommandsHelper commandNameFor:MXKSlashCommandSetUserPowerLevel]])
|
||||
{
|
||||
// Retrieve power level
|
||||
NSString *powerLevel = nil;
|
||||
@@ -1617,10 +1622,10 @@ static const CGFloat kCellVisibilityMinimumHeight = 8.0;
|
||||
else
|
||||
{
|
||||
// Display cmd usage in text input as placeholder
|
||||
cmdUsage = @"Usage: /op <userId> <power level>";
|
||||
cmdUsage = [MXKSlashCommandsHelper commandUsageFor:MXKSlashCommandSetUserPowerLevel];
|
||||
}
|
||||
}
|
||||
else if ([cmd isEqualToString:kMXKSlashCmdResetUserPowerLevel])
|
||||
else if ([cmd isEqualToString:[MXKSlashCommandsHelper commandNameFor:MXKSlashCommandResetUserPowerLevel]])
|
||||
{
|
||||
if (userId)
|
||||
{
|
||||
@@ -1639,7 +1644,7 @@ static const CGFloat kCellVisibilityMinimumHeight = 8.0;
|
||||
else
|
||||
{
|
||||
// Display cmd usage in text input as placeholder
|
||||
cmdUsage = @"Usage: /deop <userId>";
|
||||
cmdUsage = [MXKSlashCommandsHelper commandUsageFor:MXKSlashCommandResetUserPowerLevel];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user