Show toasts on reply / archive / unarchive.

This commit is contained in:
John Preston 2023-06-15 20:28:53 +04:00
parent ff835ec76c
commit ad5b96b049
7 changed files with 49 additions and 17 deletions

View File

@ -3811,6 +3811,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_stories_my_title" = "My Stories";
"lng_stories_archive_button" = "Archive";
"lng_stories_archive_title" = "Stories Archive";
"lng_stories_reply_sent" = "Message Sent";
"lng_stories_hidden_to_contacts" = "Those stories are now shown only in your Contacts list.";
"lng_stories_shown_in_chats" = "Those stories are now shown in your Chats list.";
"lng_stories_link_invalid" = "This link is broken or has expired.";

View File

@ -108,7 +108,8 @@ object_ptr<Ui::BoxContent> PrepareContactsBox(
) | rpl::start_with_next([=](Stories::ToggleShownRequest request) {
sessionController->session().data().stories().toggleHidden(
PeerId(int64(request.id)),
!request.shown);
!request.shown,
sessionController->uiShow());
}, raw->lifetime());
raw->loadMoreRequests(

View File

@ -16,16 +16,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_document.h"
#include "data/data_file_origin.h"
#include "data/data_photo.h"
#include "data/data_session.h"
#include "lang/lang_keys.h"
#include "main/main_session.h"
#include "ui/text/text_utilities.h"
// #TODO stories testing
#include "data/data_user.h"
#include "data/data_session.h"
#include "data/data_thread.h"
#include "history/history.h"
#include "history/history_item.h"
#include "storage/storage_shared_media.h"
#include "lang/lang_keys.h"
#include "main/main_session.h"
#include "ui/layers/show.h"
#include "ui/text/text_utilities.h"
namespace Data {
namespace {
@ -1140,7 +1139,10 @@ void Stories::markAsRead(FullStoryId id, bool viewed) {
_markReadTimer.callOnce(kMarkAsReadDelay);
}
void Stories::toggleHidden(PeerId peerId, bool hidden) {
void Stories::toggleHidden(
PeerId peerId,
bool hidden,
std::shared_ptr<Ui::Show> show) {
const auto user = _owner->peer(peerId)->asUser();
Assert(user != nullptr);
if (user->hasStoriesHidden() != hidden) {
@ -1153,6 +1155,14 @@ void Stories::toggleHidden(PeerId peerId, bool hidden) {
)).send();
}
const auto guard = gsl::finally([&] {
if (show) {
show->showToast(hidden
? tr::lng_stories_hidden_to_contacts(tr::now)
: tr::lng_stories_shown_in_chats(tr::now));
}
});
const auto i = _all.find(peerId);
if (i == end(_all)) {
return;

View File

@ -21,6 +21,10 @@ namespace Main {
class Session;
} // namespace Main
namespace Ui {
class Show;
} // namespace Ui
namespace Data {
class Session;
@ -251,7 +255,10 @@ public:
[[nodiscard]] bool isQuitPrevent();
void markAsRead(FullStoryId id, bool viewed);
void toggleHidden(PeerId peerId, bool hidden);
void toggleHidden(
PeerId peerId,
bool hidden,
std::shared_ptr<Ui::Show> show);
static constexpr auto kViewsPerPage = 50;
void loadViewsSlice(

View File

@ -353,7 +353,8 @@ InnerWidget::InnerWidget(
) | rpl::start_with_next([=](Stories::ToggleShownRequest request) {
session().data().stories().toggleHidden(
PeerId(int64(request.id)),
!request.shown);
!request.shown,
_controller->uiShow());
}, lifetime());
_stories->loadMoreRequests(

View File

@ -122,7 +122,7 @@ void ReplyArea::sendReaction(const Data::ReactionId &id) {
}
}
if (!message.textWithTags.empty()) {
send(std::move(message), {});
send(std::move(message), {}, true);
}
}
@ -136,7 +136,10 @@ void ReplyArea::send(Api::SendOptions options) {
send(std::move(message), options);
}
void ReplyArea::send(Api::MessageToSend message, Api::SendOptions options) {
void ReplyArea::send(
Api::MessageToSend message,
Api::SendOptions options,
bool skipToast) {
const auto error = GetErrorTextForSending(
_data.user,
{
@ -151,7 +154,7 @@ void ReplyArea::send(Api::MessageToSend message, Api::SendOptions options) {
session().api().sendMessage(std::move(message));
_controls->clear();
finishSending();
finishSending(skipToast);
}
void ReplyArea::sendVoice(VoiceToSend &&data) {
@ -256,9 +259,13 @@ void ReplyArea::sendInlineResult(
finishSending();
}
void ReplyArea::finishSending() {
void ReplyArea::finishSending(bool skipToast) {
_controls->hidePanelsAnimated();
_controller->wrap()->setFocus();
if (!skipToast) {
_controller->uiShow()->showToast(
tr::lng_stories_reply_sent(tr::now));
}
}
void ReplyArea::uploadFile(

View File

@ -73,7 +73,10 @@ private:
[[nodiscard]] Main::Session &session() const;
[[nodiscard]] not_null<History*> history() const;
void send(Api::MessageToSend message, Api::SendOptions options);
void send(
Api::MessageToSend message,
Api::SendOptions options,
bool skipToast = false);
void uploadFile(const QByteArray &fileContent, SendMediaType type);
bool confirmSendingFiles(
@ -98,7 +101,7 @@ private:
TextWithTags &&caption,
Api::SendOptions options,
bool ctrlShiftEnter);
void finishSending();
void finishSending(bool skipToast = false);
void sendExistingDocument(not_null<DocumentData*> document);
bool sendExistingDocument(