Skip to content

Commit

Permalink
TW-1429: disable copy image in message context menu in firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
sherlockvn authored and hoangdat committed Feb 7, 2024
1 parent 12665f9 commit 3b1e56f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2758,7 +2758,7 @@
"@askToInvite": {},
"select": "Select",
"@select": {},
"copyMessageText": "Copy message text",
"copyMessageText": "Copy",
"@copyMessageText": {},
"pinThisChat": "Pin this chat",
"@pinThisChat": {},
Expand Down
1 change: 1 addition & 0 deletions lib/pages/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,7 @@ class ChatController extends State<Chat>
) {
final listAction = [
ChatContextMenuActions.select,
if (event.isCopyable) ChatContextMenuActions.copyMessage,
ChatContextMenuActions.pinChat,
ChatContextMenuActions.copyMessage,
ChatContextMenuActions.forward,
Expand Down
2 changes: 2 additions & 0 deletions lib/utils/matrix_sdk_extensions/event_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ extension LocalizedBody on Event {
bool get isVideoOrImage =>
[MessageTypes.Image, MessageTypes.Video].contains(messageType);

bool get isCopyable => messageType == MessageTypes.Text;

bool isContains(String? searchTerm) =>
plaintextBody.toLowerCase().contains(searchTerm?.toLowerCase() ?? '');

Expand Down
15 changes: 10 additions & 5 deletions lib/utils/platform_infos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,16 @@ abstract class PlatformInfos {

static bool get platformCanRecord => (isMobile || isMacOS);

static bool get isMacKeyboardPlatform =>
isMacOS ||
(kIsWeb &&
html.window.navigator.platform != null &&
html.window.navigator.platform!.toLowerCase().contains('mac'));
static bool get isMacKeyboardPlatform => isMacOS || isWebInMac;

static bool get isWebInMac =>
kIsWeb &&
html.window.navigator.platform != null &&
html.window.navigator.platform!.toLowerCase().contains('mac');

static bool get isFireFoxBrowser =>
kIsWeb &&
html.window.navigator.userAgent.toLowerCase().contains('firefox');

static String get clientName =>
'${AppConfig.applicationName} ${isWeb ? 'web' : Platform.operatingSystem}${kReleaseMode ? '' : 'Debug'}';
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ dependencies:
media_kit_libs_video: ^1.0.1
video_player: ^2.7.2
js: ^0.6.7
super_clipboard: ^0.8.4
super_clipboard: 0.8.4
google_fonts: ^4.0.4
crypto: ^3.0.3
flutter_contacts: ^1.1.7+1
Expand Down

0 comments on commit 3b1e56f

Please sign in to comment.