Skip to content

Commit

Permalink
fix: don't play button click sound on click message button (#1334)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggurdin authored Dec 31, 2024
1 parent 09942aa commit 0fdd8a6
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 16 deletions.
3 changes: 0 additions & 3 deletions lib/pages/chat/events/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,6 @@ class Message extends StatelessWidget {
showToolbar(pangeaMessageEvent);
},
color: color,
clickPlayer:
controller.choreographer.clickPlayer,
child:
// Pangea#
Container(
Expand Down Expand Up @@ -521,7 +519,6 @@ class Message extends StatelessWidget {
controller: controller,
nextEvent: nextEvent,
prevEvent: previousEvent,
isButton: isButton,
// Pangea#
),
if (event.hasAggregatedEvents(
Expand Down
6 changes: 0 additions & 6 deletions lib/pages/chat/events/message_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class MessageContent extends StatelessWidget {
final ChatController controller;
final Event? nextEvent;
final Event? prevEvent;
final bool isButton;
// Pangea#

const MessageContent(
Expand All @@ -56,7 +55,6 @@ class MessageContent extends StatelessWidget {
required this.controller,
this.nextEvent,
this.prevEvent,
this.isButton = false,
// Pangea#
required this.borderRadius,
});
Expand Down Expand Up @@ -333,10 +331,6 @@ class MessageContent extends StatelessWidget {
return;
}

if (isButton) {
controller.choreographer.clickPlayer.play();
}

controller.showToolbar(
event,
pangeaMessageEvent: pangeaMessageEvent,
Expand Down
3 changes: 0 additions & 3 deletions lib/pangea/choreographer/controllers/choreographer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import 'package:fluffychat/pangea/models/tokens_event_content_model.dart';
import 'package:fluffychat/pangea/utils/any_state_holder.dart';
import 'package:fluffychat/pangea/utils/error_handler.dart';
import 'package:fluffychat/pangea/utils/overlay.dart';
import 'package:fluffychat/pangea/utils/play_click_sound.dart';
import 'package:fluffychat/pangea/widgets/chat/tts_controller.dart';
import 'package:fluffychat/pangea/widgets/igc/paywall_card.dart';
import 'package:flutter/foundation.dart';
Expand All @@ -43,7 +42,6 @@ class Choreographer {
late AlternativeTranslator altTranslator;
late ErrorService errorService;
final tts = TtsController();
final clickPlayer = ClickPlayer();

bool isFetching = false;
int _timesClicked = 0;
Expand Down Expand Up @@ -520,7 +518,6 @@ class Choreographer {
_textController.dispose();
trialStream?.cancel();
tts.dispose();
clickPlayer.dispose();
}

LanguageModel? get l2Lang {
Expand Down
2 changes: 1 addition & 1 deletion lib/pangea/controllers/app_version_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class AppVersionController {
isOlderCurrentVersion = true;
}

if (!isOlderCurrentVersion && !mandatoryUpdate) {
if (!isOlderCurrentVersion) {
return;
}

Expand Down
1 change: 1 addition & 0 deletions lib/pangea/widgets/chat/message_toolbar_buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ class ToolbarButton extends StatelessWidget {
onPressed: enabled
? () => overlayController.updateToolbarMode(mode)
: null,
playSound: true,
child: AnimatedContainer(
duration: FluffyThemes.animationDuration,
height: buttonSize,
Expand Down
8 changes: 5 additions & 3 deletions lib/pangea/widgets/pressable_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PressableButton extends StatefulWidget {

final void Function()? onPressed;
final Stream? triggerAnimation;
final ClickPlayer? clickPlayer;
final bool playSound;

final bool? isShadow;

Expand All @@ -26,8 +26,8 @@ class PressableButton extends StatefulWidget {
this.buttonHeight = 5,
this.depressed = false,
this.triggerAnimation,
this.clickPlayer,
this.isShadow,
this.playSound = false,
super.key,
});

Expand All @@ -41,6 +41,7 @@ class PressableButtonState extends State<PressableButton>
late Animation<double> _tweenAnimation;
Completer<void>? _animationCompleter;
StreamSubscription? _triggerAnimationSubscription;
final ClickPlayer clickPlayer = ClickPlayer();

// seperate the widget's depressed state from the internal
// state to enable animations when this changes
Expand Down Expand Up @@ -112,7 +113,7 @@ class PressableButtonState extends State<PressableButton>
if (_animationCompleter != null) {
await _animationCompleter!.future;
}
widget.clickPlayer?.play();
if (widget.playSound) clickPlayer.play();
if (!kIsWeb) {
HapticFeedback.mediumImpact();
}
Expand All @@ -128,6 +129,7 @@ class PressableButtonState extends State<PressableButton>
void dispose() {
_controller.dispose();
_triggerAnimationSubscription?.cancel();
clickPlayer.dispose();
super.dispose();
}

Expand Down

0 comments on commit 0fdd8a6

Please sign in to comment.