Skip to content

Commit

Permalink
Rebased to new swift ChatViewController.
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Sein <[email protected]>
  • Loading branch information
Ivansss committed Oct 24, 2023
1 parent 1ac50ed commit 6d22d82
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion NextcloudTalk/BaseChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,8 @@ import QuickLook
}

func didPressTranslate(for message: NCChatMessage) {
let translateMessageVC = MessageTranslationViewController(message: message.parsedMessage().string, availableTranslations: NCSettingsController.sharedInstance().availableTranslations())
let activeAccount = NCDatabaseManager.sharedInstance().activeAccount()
let translateMessageVC = MessageTranslationViewController(message: message.parsedMessage().string, availableTranslations: NCDatabaseManager.sharedInstance().availableTranslations(forAccountId: activeAccount.accountId))
self.presentWithNavigation(translateMessageVC, animated: true)
}

Expand Down
4 changes: 2 additions & 2 deletions NextcloudTalk/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,7 @@ import UIKit
}

var actions: [UIMenuElement] = []
let activeAccount = NCDatabaseManager.sharedInstance().activeAccount()
let hasChatPermissions = !NCDatabaseManager.sharedInstance().serverHasTalkCapability(kCapabilityChatPermission) || (self.room.permissions & NCPermission.chat.rawValue) != 0

// Reply option
Expand All @@ -1477,7 +1478,6 @@ import UIKit
}

// Reply-privately option (only to other users and not in one-to-one)
let activeAccount = NCDatabaseManager.sharedInstance().activeAccount()
if self.isMessageReplyable(message: message), self.room.type != kNCRoomTypeOneToOne, message.actorType == "users", message.actorId != activeAccount.userId {
actions.append(UIAction(title: NSLocalizedString("Reply privately", comment: ""), image: .init(systemName: "person")) { _ in
self.didPressReplyPrivately(for: message)
Expand Down Expand Up @@ -1553,7 +1553,7 @@ import UIKit
})

// Translate
if !self.offlineMode, !NCSettingsController.sharedInstance().availableTranslations().isEmpty {
if !self.offlineMode, NCDatabaseManager.sharedInstance().hasAvailableTranslations(forAccountId: activeAccount.accountId) {
actions.append(UIAction(title: NSLocalizedString("Translate", comment: ""), image: .init(systemName: "character.book.closed")) { _ in
self.didPressTranslate(for: message)
})
Expand Down
2 changes: 1 addition & 1 deletion NextcloudTalk/NCDatabaseManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ extern NSString * const kMinimumRequiredTalkCapability;

- (BOOL)hasAvailableTranslationsForAccountId:(NSString *)accountId;
- (BOOL)hasTranslationProvidersForAccountId:(NSString *)accountId;
- (NSArray *)availableTranslationsForAccountId:(NSString *)accountId;
- (NSArray<NCTranslation *> *)availableTranslationsForAccountId:(NSString *)accountId;
- (NSArray *)translationsFromTranslationsArray:(NSArray *)translations;

@end
Expand Down

0 comments on commit 6d22d82

Please sign in to comment.