mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show correct reply placeholder in stealth mode.
This commit is contained in:
parent
c12297d8cb
commit
3adb0c1856
4 changed files with 56 additions and 22 deletions
|
@ -11,6 +11,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "api/api_sending.h"
|
#include "api/api_sending.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "base/call_delayed.h"
|
#include "base/call_delayed.h"
|
||||||
|
#include "base/timer_rpl.h"
|
||||||
|
#include "base/unixtime.h"
|
||||||
#include "boxes/premium_limits_box.h"
|
#include "boxes/premium_limits_box.h"
|
||||||
#include "boxes/send_files_box.h"
|
#include "boxes/send_files_box.h"
|
||||||
#include "chat_helpers/compose/compose_show.h"
|
#include "chat_helpers/compose/compose_show.h"
|
||||||
|
@ -30,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "media/stories/media_stories_controller.h"
|
#include "media/stories/media_stories_controller.h"
|
||||||
|
#include "media/stories/media_stories_stealth.h"
|
||||||
#include "menu/menu_send.h"
|
#include "menu/menu_send.h"
|
||||||
#include "storage/localimageloader.h"
|
#include "storage/localimageloader.h"
|
||||||
#include "storage/storage_account.h"
|
#include "storage/storage_account.h"
|
||||||
|
@ -42,6 +45,35 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_media_view.h"
|
#include "styles/style_media_view.h"
|
||||||
|
|
||||||
namespace Media::Stories {
|
namespace Media::Stories {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
[[nodiscard]] rpl::producer<QString> PlaceholderText(
|
||||||
|
const std::shared_ptr<ChatHelpers::Show> &show) {
|
||||||
|
return show->session().data().stories().stealthModeValue(
|
||||||
|
) | rpl::map([](Data::StealthMode value) {
|
||||||
|
return value.enabledTill;
|
||||||
|
}) | rpl::distinct_until_changed() | rpl::map([](TimeId till) {
|
||||||
|
return rpl::single(
|
||||||
|
rpl::empty
|
||||||
|
) | rpl::then(
|
||||||
|
base::timer_each(250)
|
||||||
|
) | rpl::map([=] {
|
||||||
|
return till - base::unixtime::now();
|
||||||
|
}) | rpl::take_while([](TimeId left) {
|
||||||
|
return left > 0;
|
||||||
|
}) | rpl::then(
|
||||||
|
rpl::single(0)
|
||||||
|
) | rpl::map([](TimeId left) {
|
||||||
|
return left
|
||||||
|
? tr::lng_stealth_mode_countdown(
|
||||||
|
lt_left,
|
||||||
|
rpl::single(TimeLeftText(left)))
|
||||||
|
: tr::lng_story_reply_ph();
|
||||||
|
}) | rpl::flatten_latest();
|
||||||
|
}) | rpl::flatten_latest();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
class ReplyArea::Cant final : public Ui::RpWidget {
|
class ReplyArea::Cant final : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
|
@ -85,7 +117,7 @@ ReplyArea::ReplyArea(not_null<Controller*> controller)
|
||||||
.mode = HistoryView::ComposeControlsMode::Normal,
|
.mode = HistoryView::ComposeControlsMode::Normal,
|
||||||
.sendMenuType = SendMenu::Type::SilentOnly,
|
.sendMenuType = SendMenu::Type::SilentOnly,
|
||||||
.stickerOrEmojiChosen = _controller->stickerOrEmojiChosen(),
|
.stickerOrEmojiChosen = _controller->stickerOrEmojiChosen(),
|
||||||
.customPlaceholder = tr::lng_story_reply_ph(),
|
.customPlaceholder = PlaceholderText(_controller->uiShow()),
|
||||||
.voiceCustomCancelText = tr::lng_record_cancel_stories(tr::now),
|
.voiceCustomCancelText = tr::lng_record_cancel_stories(tr::now),
|
||||||
.voiceLockFromBottom = true,
|
.voiceLockFromBottom = true,
|
||||||
.features = {
|
.features = {
|
||||||
|
|
|
@ -45,31 +45,13 @@ struct Feature {
|
||||||
TextWithEntities about;
|
TextWithEntities about;
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] QString LeftText(int left) {
|
|
||||||
Expects(left >= 0);
|
|
||||||
|
|
||||||
const auto hours = left / 3600;
|
|
||||||
const auto minutes = (left % 3600) / 60;
|
|
||||||
const auto seconds = left % 60;
|
|
||||||
const auto zero = QChar('0');
|
|
||||||
if (hours) {
|
|
||||||
return u"%1:%2:%3"_q
|
|
||||||
.arg(hours)
|
|
||||||
.arg(minutes, 2, 10, zero)
|
|
||||||
.arg(seconds, 2, 10, zero);
|
|
||||||
} else if (minutes) {
|
|
||||||
return u"%1:%2"_q.arg(minutes).arg(seconds, 2, 10, zero);
|
|
||||||
}
|
|
||||||
return u"0:%1"_q.arg(left, 2, 10, zero);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] Ui::Toast::Config ToastAlready(TimeId left) {
|
[[nodiscard]] Ui::Toast::Config ToastAlready(TimeId left) {
|
||||||
return {
|
return {
|
||||||
.title = tr::lng_stealth_mode_already_title(tr::now),
|
.title = tr::lng_stealth_mode_already_title(tr::now),
|
||||||
.text = tr::lng_stealth_mode_already_about(
|
.text = tr::lng_stealth_mode_already_about(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_left,
|
lt_left,
|
||||||
TextWithEntities{ LeftText(left) },
|
TextWithEntities{ TimeLeftText(left) },
|
||||||
Ui::Text::RichLangValue),
|
Ui::Text::RichLangValue),
|
||||||
.st = &st::storiesStealthToast,
|
.st = &st::storiesStealthToast,
|
||||||
.duration = kAlreadyToastDuration,
|
.duration = kAlreadyToastDuration,
|
||||||
|
@ -277,7 +259,7 @@ struct Feature {
|
||||||
return tr::lng_stealth_mode_cooldown_in(
|
return tr::lng_stealth_mode_cooldown_in(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_left,
|
lt_left,
|
||||||
LeftText(left));
|
TimeLeftText(left));
|
||||||
}) | rpl::type_erased();
|
}) | rpl::type_erased();
|
||||||
}) | rpl::flatten_latest();
|
}) | rpl::flatten_latest();
|
||||||
|
|
||||||
|
@ -404,4 +386,22 @@ void SetupStealthMode(std::shared_ptr<ChatHelpers::Show> show) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString TimeLeftText(int left) {
|
||||||
|
Expects(left >= 0);
|
||||||
|
|
||||||
|
const auto hours = left / 3600;
|
||||||
|
const auto minutes = (left % 3600) / 60;
|
||||||
|
const auto seconds = left % 60;
|
||||||
|
const auto zero = QChar('0');
|
||||||
|
if (hours) {
|
||||||
|
return u"%1:%2:%3"_q
|
||||||
|
.arg(hours)
|
||||||
|
.arg(minutes, 2, 10, zero)
|
||||||
|
.arg(seconds, 2, 10, zero);
|
||||||
|
} else if (minutes) {
|
||||||
|
return u"%1:%2"_q.arg(minutes).arg(seconds, 2, 10, zero);
|
||||||
|
}
|
||||||
|
return u"0:%1"_q.arg(left, 2, 10, zero);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Media::Stories
|
} // namespace Media::Stories
|
||||||
|
|
|
@ -15,4 +15,6 @@ namespace Media::Stories {
|
||||||
|
|
||||||
void SetupStealthMode(std::shared_ptr<ChatHelpers::Show> show);
|
void SetupStealthMode(std::shared_ptr<ChatHelpers::Show> show);
|
||||||
|
|
||||||
|
[[nodiscard]] QString TimeLeftText(int left);
|
||||||
|
|
||||||
} // namespace Media::Stories
|
} // namespace Media::Stories
|
||||||
|
|
|
@ -1313,7 +1313,7 @@ void OverlayWidget::updateControls() {
|
||||||
}
|
}
|
||||||
_shareNav = navRect(index);
|
_shareNav = navRect(index);
|
||||||
_shareNavOver = style::centerrect(_shareNav, overRect);
|
_shareNavOver = style::centerrect(_shareNav, overRect);
|
||||||
_shareNavIcon = style::centerrect(_shareNav, st::mediaviewSave);
|
_shareNavIcon = style::centerrect(_shareNav, st::mediaviewShare);
|
||||||
if (_shareVisible) {
|
if (_shareVisible) {
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue