feat: option to not send typing notifications

pull/473/head
Bnyro 2 years ago
parent 4bb3434519
commit 57b026b913

@ -189,6 +189,8 @@
"supportedVersions": {} "supportedVersions": {}
} }
}, },
"sendTypingNotifications": "Send typing notifications",
"@sendTypingNotifications": {},
"sendOnEnter": "Send on enter", "sendOnEnter": "Send on enter",
"@sendOnEnter": {}, "@sendOnEnter": {},
"badServerVersionsException": "The homeserver supports the Spec versions:\n{serverVersions}\nBut this app supports only {supportedVersions}", "badServerVersionsException": "The homeserver supports the Spec versions:\n{serverVersions}\nBut this app supports only {supportedVersions}",

@ -49,6 +49,7 @@ abstract class AppConfig {
static bool showDirectChatsInSpaces = true; static bool showDirectChatsInSpaces = true;
static bool separateChatTypes = false; static bool separateChatTypes = false;
static bool autoplayImages = true; static bool autoplayImages = true;
static bool sendTypingNotifications = true;
static bool sendOnEnter = false; static bool sendOnEnter = false;
static bool experimentalVoip = false; static bool experimentalVoip = false;
static const bool hideTypingUsernames = false; static const bool hideTypingUsernames = false;

@ -26,6 +26,8 @@ abstract class SettingKeys {
static const String dontAskForBootstrapKey = static const String dontAskForBootstrapKey =
'chat.fluffychat.dont_ask_bootstrap'; 'chat.fluffychat.dont_ask_bootstrap';
static const String autoplayImages = 'chat.fluffy.autoplay_images'; static const String autoplayImages = 'chat.fluffy.autoplay_images';
static const String sendTypingNotifications =
'chat.fluffy.send_typing_notifications';
static const String sendOnEnter = 'chat.fluffy.send_on_enter'; static const String sendOnEnter = 'chat.fluffy.send_on_enter';
static const String experimentalVoip = 'chat.fluffy.experimental_voip'; static const String experimentalVoip = 'chat.fluffy.experimental_voip';
} }

@ -19,6 +19,7 @@ import 'package:scroll_to_index/scroll_to_index.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:vrouter/vrouter.dart'; import 'package:vrouter/vrouter.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/pages/chat/chat_view.dart'; import 'package:fluffychat/pages/chat/chat_view.dart';
import 'package:fluffychat/pages/chat/event_info_dialog.dart'; import 'package:fluffychat/pages/chat/event_info_dialog.dart';
import 'package:fluffychat/pages/chat/recording_dialog.dart'; import 'package:fluffychat/pages/chat/recording_dialog.dart';
@ -1139,19 +1140,24 @@ class ChatController extends State<ChatPageWithRoom> {
} }
} }
} }
typingCoolDown?.cancel(); if (AppConfig.sendTypingNotifications) {
typingCoolDown = Timer(const Duration(seconds: 2), () { typingCoolDown?.cancel();
typingCoolDown = null; typingCoolDown = Timer(const Duration(seconds: 2), () {
currentlyTyping = false; typingCoolDown = null;
room.setTyping(false); currentlyTyping = false;
}); room.setTyping(false);
typingTimeout ??= Timer(const Duration(seconds: 30), () { });
typingTimeout = null; typingTimeout ??= Timer(const Duration(seconds: 30), () {
currentlyTyping = false; typingTimeout = null;
}); currentlyTyping = false;
if (!currentlyTyping) { });
currentlyTyping = true; if (!currentlyTyping) {
room.setTyping(true, timeout: const Duration(seconds: 30).inMilliseconds); currentlyTyping = true;
room.setTyping(
true,
timeout: const Duration(seconds: 30).inMilliseconds,
);
}
} }
setState(() => inputText = text); setState(() => inputText = text);
} }

@ -66,6 +66,12 @@ class SettingsChatView extends StatelessWidget {
defaultValue: AppConfig.autoplayImages, defaultValue: AppConfig.autoplayImages,
), ),
const Divider(), const Divider(),
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.sendTypingNotifications,
onChanged: (b) => AppConfig.sendTypingNotifications = b,
storeKey: SettingKeys.sendTypingNotifications,
defaultValue: AppConfig.sendTypingNotifications,
),
SettingsSwitchListTile.adaptive( SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.sendOnEnter, title: L10n.of(context)!.sendOnEnter,
onChanged: (b) => AppConfig.sendOnEnter = b, onChanged: (b) => AppConfig.sendOnEnter = b,

@ -489,6 +489,12 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
store store
.getItemBool(SettingKeys.autoplayImages, AppConfig.autoplayImages) .getItemBool(SettingKeys.autoplayImages, AppConfig.autoplayImages)
.then((value) => AppConfig.autoplayImages = value); .then((value) => AppConfig.autoplayImages = value);
store
.getItemBool(
SettingKeys.sendTypingNotifications,
AppConfig.sendTypingNotifications,
)
.then((value) => AppConfig.sendTypingNotifications = value);
store store
.getItemBool(SettingKeys.sendOnEnter, AppConfig.sendOnEnter) .getItemBool(SettingKeys.sendOnEnter, AppConfig.sendOnEnter)
.then((value) => AppConfig.sendOnEnter = value); .then((value) => AppConfig.sendOnEnter = value);

Loading…
Cancel
Save