Repository navigation
feat: ask before sending gif - #206
Conversation
Reviewer's GuideImplements an opt-in GIF-send confirmation flow: when enabled in chat settings, selecting a GIF opens a localized confirmation dialog before the existing send operation runs; cancellation prevents sending while the default behavior remains unchanged. Sequence diagram for optional GIF send confirmationsequenceDiagram
participant User
participant ChatActivityEnterView
participant NaConfig
participant AlertDialog
participant SendOperation
User->>ChatActivityEnterView: onGifSelected()
ChatActivityEnterView->>NaConfig: getAskBeforeSendingGIF()
alt confirmation enabled
ChatActivityEnterView->>AlertDialog: show ConfirmSendGIF
alt user confirms
User->>AlertDialog: OK
AlertDialog->>SendOperation: run()
else user cancels
User->>AlertDialog: Cancel
end
else confirmation disabled
ChatActivityEnterView->>SendOperation: run()
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java" line_range="13452" />
<code_context>
};
if (!showConfirmAlert(runnable)) {
- runnable.run();
+ if (NaConfig.INSTANCE.getAskBeforeSendingGIF().Bool()) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity != null ? parentActivity : getContext(), resourcesProvider);
+ builder.setTitle(LocaleController.getString(R.string.ConfirmSendGIF));
</code_context>
<issue_to_address>
**Story replies bypass GIF confirmation**
When a GIF is sent from the story-reply input with Ask Before Sending GIF enabled, in `PeerStoriesView`, `showConfirmAlert` delegates to `applyMessageToChat`, which runs the callback and returns `true` on the normal path, so the GIF confirmation check is skipped and the GIF reaches the story recipient without confirmation.
Ensure the GIF confirmation preference is checked for story-reply sends even when `showConfirmAlert` returns `true`.
</issue_to_address>
### Comment 2
<location path="TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java" line_range="13459" />
<code_context>
+ builder.setPositiveButton(LocaleController.getString(R.string.OK), (dialogInterface, i) -> runnable.run());
+ builder.setNegativeButton(LocaleController.getString(R.string.Cancel), null);
+ if (parentFragment != null) {
+ parentFragment.showDialog(builder.create());
+ }
+ if (parentFragment == null) {
</code_context>
<issue_to_address>
**GIF selection is silently dropped**
When the GIF confirmation is enabled and the parent fragment cannot show dialogs, `showDialog` returns without displaying the alert, but the fallback runs only when `parentFragment` is null, so the selection is dropped and no GIF is sent.
Fall back to showing the alert when `parentFragment.showDialog(...)` does not display it.
Also at `TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java:13460`.
</issue_to_address>Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java:13452, TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java:13459
| }; | ||
| if (!showConfirmAlert(runnable)) { | ||
| runnable.run(); | ||
| if (NaConfig.INSTANCE.getAskBeforeSendingGIF().Bool()) { |
There was a problem hiding this comment.
🟡 Medium · Story replies bypass GIF confirmation
When a GIF is sent from the story-reply input with Ask Before Sending GIF enabled, in PeerStoriesView, showConfirmAlert delegates to applyMessageToChat, which runs the callback and returns true on the normal path, so the GIF confirmation check is skipped and the GIF reaches the story recipient without confirmation.
Ensure the GIF confirmation preference is checked for story-reply sends even when showConfirmAlert returns true.
Prompt for AI agents
In `TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java` at line 13452:
**Story replies bypass GIF confirmation**
When a GIF is sent from the story-reply input with Ask Before Sending GIF enabled, in `PeerStoriesView`, `showConfirmAlert` delegates to `applyMessageToChat`, which runs the callback and returns `true` on the normal path, so the GIF confirmation check is skipped and the GIF reaches the story recipient without confirmation.
Ensure the GIF confirmation preference is checked for story-reply sends even when `showConfirmAlert` returns `true`.| builder.setPositiveButton(LocaleController.getString(R.string.OK), (dialogInterface, i) -> runnable.run()); | ||
| builder.setNegativeButton(LocaleController.getString(R.string.Cancel), null); | ||
| if (parentFragment != null) { | ||
| parentFragment.showDialog(builder.create()); |
There was a problem hiding this comment.
🟡 Medium · GIF selection is silently dropped
When the GIF confirmation is enabled and the parent fragment cannot show dialogs, showDialog returns without displaying the alert, but the fallback runs only when parentFragment is null, so the selection is dropped and no GIF is sent.
Fall back to showing the alert when parentFragment.showDialog(...) does not display it.
Also at TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java:13460.
Prompt for AI agents
In `TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java` at line 13459:
**GIF selection is silently dropped**
When the GIF confirmation is enabled and the parent fragment cannot show dialogs, `showDialog` returns without displaying the alert, but the fallback runs only when `parentFragment` is null, so the selection is dropped and no GIF is sent.
Fall back to showing the alert when `parentFragment.showDialog(...)` does not display it.
Also at `TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java:13460`.
added option to confirm sending gif, just like nagram desktop. in mobile screen things are easy to misclick. this could avoid the user sending a nsfw gif in a chat by accident.
Screen_Recording_20261010_163229_Nagram.mp4
Summary by Sourcery
Allow users to confirm GIF sends to reduce accidental sharing from mobile chats.
New Features: