Save away / greeting settings.

This commit is contained in:
John Preston 2024-03-01 13:17:41 +04:00
parent ca4cbddba6
commit cf8aaf5f9d
12 changed files with 41 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -2238,6 +2238,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_away_schedule_custom" = "Custom Schedule";
"lng_away_custom_start" = "Start Time";
"lng_away_custom_end" = "End Time";
"lng_away_offline_only" = "Only if Offline";
"lng_away_offline_only_about" = "Don't send the away message if you've recently been online.";
"lng_away_recipients" = "Recipients";
"lng_away_select" = "Select chats or entire chat categories for sending an away message.";
"lng_away_empty_title" = "New Away Message";

View file

@ -48,6 +48,7 @@ private:
rpl::event_stream<> _deactivateOnAttempt;
rpl::variable<Data::BusinessRecipients> _recipients;
rpl::variable<Data::AwaySchedule> _schedule;
rpl::variable<bool> _offlineOnly;
rpl::variable<bool> _enabled;
};
@ -311,6 +312,18 @@ void AwayMessage::setupContent(
});
Ui::AddSkip(inner);
Ui::AddDivider(inner);
Ui::AddSkip(inner);
const auto offlineOnly = inner->add(
object_ptr<Ui::SettingsButton>(
inner,
tr::lng_away_offline_only(),
st::settingsButtonNoIcon)
)->toggleOn(rpl::single(current.offlineOnly));
_offlineOnly = offlineOnly->toggledValue();
Ui::AddSkip(inner);
Ui::AddDividerText(inner, tr::lng_away_offline_only_about());
AddBusinessRecipientsSelector(inner, {
.controller = controller,
@ -327,10 +340,13 @@ void AwayMessage::setupContent(
}
void AwayMessage::save() {
controller()->session().data().businessInfo().saveAwaySettings(
const auto session = &controller()->session();
session->data().businessInfo().saveAwaySettings(
_enabled.current() ? Data::AwaySettings{
.recipients = _recipients.current(),
.schedule = _schedule.current(),
.shortcutId = LookupShortcutId(session, u"away"_q),
.offlineOnly = _offlineOnly.current(),
} : Data::AwaySettings());
}

View file

@ -326,10 +326,12 @@ void Greeting::setupContent(
}
void Greeting::save() {
controller()->session().data().businessInfo().saveGreetingSettings(
const auto session = &controller()->session();
session->data().businessInfo().saveGreetingSettings(
_enabled.current() ? Data::GreetingSettings{
.recipients = _recipients.current(),
.noActivityDays = _noActivityDays.current(),
.shortcutId = LookupShortcutId(session, u"hello"_q),
} : Data::GreetingSettings());
}

View file

@ -280,7 +280,7 @@ void AddBusinessRecipientsSelector(
});
}, lifetime);
SetupBusinessChatsPreview(includeInner, excluded);
SetupBusinessChatsPreview(includeInner, included);
includeWrap->toggleOn(data->value(
) | rpl::map([](const Data::BusinessRecipients &value) {
@ -374,4 +374,16 @@ rpl::producer<int> ShortcutMessagesLimitValue(
});
}
BusinessShortcutId LookupShortcutId(
not_null<Main::Session*> session,
const QString &name) {
const auto messages = &session->data().shortcutMessages();
for (const auto &[id, shortcut] : messages->shortcuts().list) {
if (shortcut.name == name) {
return id;
}
}
return {};
}
} // namespace Settings

View file

@ -93,4 +93,8 @@ void AddBusinessRecipientsSelector(
[[nodiscard]] rpl::producer<int> ShortcutMessagesLimitValue(
not_null<Main::Session*> session);
[[nodiscard]] BusinessShortcutId LookupShortcutId(
not_null<Main::Session*> session,
const QString &name);
} // namespace Settings

View file

@ -303,8 +303,8 @@ windowFilterTypeBots: icon {{ "folders/folders_type_bots", historyPeerUserpicFg
windowFilterTypeNoMuted: icon {{ "folders/folders_type_muted", historyPeerUserpicFg }};
windowFilterTypeNoArchived: icon {{ "folders/folders_type_archived", historyPeerUserpicFg }};
windowFilterTypeNoRead: icon {{ "folders/folders_type_read", historyPeerUserpicFg }};
windowFilterTypeNewChats: icon {{ "folders/folders_unread", historyPeerUserpicFg }};
windowFilterTypeExistingChats: windowFilterTypeNoRead;
windowFilterTypeNewChats: icon {{ "folders/folder_new_chats", historyPeerUserpicFg }};
windowFilterTypeExistingChats: icon {{ "folders/folder_existing_chats", historyPeerUserpicFg }};
windowFilterChatsSectionSubtitleHeight: 28px;
windowFilterChatsSectionSubtitle: FlatLabel(defaultFlatLabel) {
style: TextStyle(defaultTextStyle) {