Skip to content

Commit 7522a16

Browse files
zubidenAjaxy
authored andcommitted
Composer: Add silent post button and hide them on text (#5749)
1 parent 440001b commit 7522a16

File tree

10 files changed

+233
-91
lines changed

10 files changed

+233
-91
lines changed

src/api/gramjs/methods/chats.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -735,27 +735,26 @@ async function getFullChannelInfo(
735735
};
736736
}
737737

738-
export function updateChatMutedState({
739-
chat, isMuted, mutedUntil = 0,
738+
export function updateChatNotifySettings({
739+
chat, settings,
740740
}: {
741-
chat: ApiChat; isMuted?: boolean; mutedUntil?: number;
741+
chat: ApiChat; settings: Partial<ApiPeerNotifySettings>;
742742
}) {
743-
if (isMuted && !mutedUntil) {
744-
mutedUntil = MAX_INT_32;
745-
}
746743
invokeRequest(new GramJs.account.UpdateNotifySettings({
747744
peer: new GramJs.InputNotifyPeer({
748745
peer: buildInputPeer(chat.id, chat.accessHash),
749746
}),
750-
settings: new GramJs.InputPeerNotifySettings({ muteUntil: mutedUntil }),
747+
settings: new GramJs.InputPeerNotifySettings({
748+
muteUntil: settings.mutedUntil,
749+
showPreviews: settings.shouldShowPreviews,
750+
silent: settings.isSilentPosting,
751+
}),
751752
}));
752753

753754
sendApiUpdate({
754755
'@type': 'updateChatNotifySettings',
755756
chatId: chat.id,
756-
settings: {
757-
mutedUntil,
758-
},
757+
settings,
759758
});
760759

761760
void requestChatUpdate({

src/assets/localization/fallback.strings

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,18 @@
12711271
"AriaOpenBotMenu" = "Open bot menu";
12721272
"AriaOpenSymbolMenu" = "Choose emoji, sticker or GIF";
12731273
"AriaComposerOpenScheduled" = "Open scheduled messages";
1274+
"AriaComposerBotKeyboard" = "Show bot keyboard";
1275+
"AriaComposerSilentPostingEnable" = "Enable silent notifications.";
1276+
"AriaComposerSilentPostingDisable" = "Disable silent notifications.";
1277+
"ComposerSilentPostingEnabledTootlip" = "Subscribers will receive a silent notification.";
1278+
"ComposerSilentPostingDisabledTootlip" = "Subscribers will be notified when you post.";
1279+
"ComposerPlaceholder" = "Message";
1280+
"ComposerPlaceholderBroadcast" = "Broadcast";
1281+
"ComposerPlaceholderBroadcastSilent" = "Silent Broadcast";
1282+
"ComposerPlaceholderTopic" = "Message in {topic}";
1283+
"ComposerPlaceholderTopicGeneral" = "Message in General";
1284+
"ComposerStoryPlaceholderLocked" = "Replies restricted";
1285+
"ComposerPlaceholderNoText" = "Text not allowed";
12741286
"AriaComposerCancelVoice" = "Cancel voice recording";
12751287
"PreviewForwardedMessage_one" = "{count} forwarded message";
12761288
"PreviewForwardedMessage_other" = "{count} forwarded messages";

src/components/common/Composer.scss

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,24 @@
292292
color: #fff;
293293
}
294294
}
295+
296+
.composer-action-buttons-container {
297+
width: auto;
298+
position: relative;
299+
300+
+ .AttachMenu {
301+
margin-left: var(--action-button-compact-fix);
302+
}
303+
}
304+
305+
.composer-action-buttons {
306+
display: flex;
307+
top: 0;
308+
right: 0;
309+
left: auto;
310+
width: auto;
311+
height: auto;
312+
}
295313
}
296314

297315
.mobile-symbol-menu-button {
@@ -384,25 +402,32 @@
384402
}
385403

386404
.message-input-wrapper {
405+
--action-button-size: var(--base-height, 3.5rem);
406+
--action-button-compact-fix: -1rem;
387407
display: flex;
388408

409+
@media (max-width: 600px) {
410+
--action-button-size: 2.875rem;
411+
--action-button-compact-fix: -0.6875rem;
412+
}
413+
389414
.input-scroller {
390-
margin-right: 0.5rem;
391-
padding-right: 0.25rem;
415+
--_scroller-right-gap: calc((var(--action-button-size) + var(--action-button-compact-fix) - 0.125rem));
416+
margin-right: calc(-1 * var(--_scroller-right-gap));
417+
padding-right: var(--_scroller-right-gap);
392418
}
393419

394420
> .Spinner {
395421
align-self: center;
396422
--spinner-size: 1.5rem;
397-
margin-right: -0.5rem;
423+
margin-right: 0.5rem;
398424
}
399425

400-
> .AttachMenu > .Button,
401-
> .Button {
426+
.composer-action-button {
402427
flex-shrink: 0;
403428
background: none !important;
404-
width: var(--base-height, 3.5rem);
405-
height: var(--base-height, 3.5rem);
429+
width: var(--action-button-size);
430+
height: var(--action-button-size);
406431
margin: 0;
407432
padding: 0;
408433
align-self: flex-end;
@@ -411,17 +436,8 @@
411436
color: var(--color-composer-button);
412437
}
413438

414-
+ .Button, + .AttachMenu {
415-
margin-left: -1rem;
416-
}
417-
418-
@media (max-width: 600px) {
419-
width: 2.875rem;
420-
height: 2.875rem;
421-
422-
+ .Button, + .AttachMenu {
423-
margin-left: -0.6875rem;
424-
}
439+
+ .composer-action-button {
440+
margin-left: var(--action-button-compact-fix);
425441
}
426442

427443
&.bot-menu {

0 commit comments

Comments
 (0)