Use stories ShareBox from the saved stories list.

This commit is contained in:
John Preston 2023-06-30 17:04:11 +04:00
parent 5f72a5238c
commit a733b83642
4 changed files with 24 additions and 10 deletions

View file

@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/history_view_cursor_state.h" #include "history/view/history_view_cursor_state.h"
#include "history/view/history_view_service_message.h" #include "history/view/history_view_service_message.h"
#include "media/stories/media_stories_controller.h" // ...TogglePinnedToast. #include "media/stories/media_stories_controller.h" // ...TogglePinnedToast.
#include "media/stories/media_stories_share.h" // PrepareShareBox.
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "window/window_peer_menu.h" #include "window/window_peer_menu.h"
#include "ui/widgets/popup_menu.h" #include "ui/widgets/popup_menu.h"
@ -1104,7 +1105,16 @@ void ListWidget::contextMenuEvent(QContextMenuEvent *e) {
} }
void ListWidget::forwardSelected() { void ListWidget::forwardSelected() {
if (auto items = collectSelectedIds(); !items.empty()) { if (_controller->storiesPeer()) {
const auto ids = collectSelectedIds();
if (ids.size() == 1 && IsStoryMsgId(ids.front().msg)) {
const auto id = ids.front();
_controller->parentController()->show(
::Media::Stories::PrepareShareBox(
_controller->parentController()->uiShow(),
{ id.peer, StoryIdFromMsgId(id.msg) }));
}
} else if (auto items = collectSelectedIds(); !items.empty()) {
forwardItems(std::move(items)); forwardItems(std::move(items));
} }
} }

View file

@ -1245,7 +1245,7 @@ void Controller::unfocusReply() {
void Controller::shareRequested() { void Controller::shareRequested() {
const auto show = _delegate->storiesShow(); const auto show = _delegate->storiesShow();
if (auto box = PrepareShareBox(show, _shown)) { if (auto box = PrepareShareBox(show, _shown, true)) {
show->show(std::move(box)); show->show(std::move(box));
} }
} }

View file

@ -32,7 +32,8 @@ namespace Media::Stories {
[[nodiscard]] object_ptr<Ui::BoxContent> PrepareShareBox( [[nodiscard]] object_ptr<Ui::BoxContent> PrepareShareBox(
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
FullStoryId id) { FullStoryId id,
bool viewerStyle) {
const auto session = &show->session(); const auto session = &show->session();
const auto resolve = [=] { const auto resolve = [=] {
const auto maybeStory = session->data().stories().lookup(id); const auto maybeStory = session->data().stories().lookup(id);
@ -170,7 +171,7 @@ namespace Media::Stories {
} }
}; };
const auto scheduleStyle = [&] { const auto viewerScheduleStyle = [&] {
auto date = Ui::ChooseDateTimeStyleArgs(); auto date = Ui::ChooseDateTimeStyleArgs();
date.labelStyle = &st::groupCallBoxLabel; date.labelStyle = &st::groupCallBoxLabel;
date.dateFieldStyle = &st::groupCallScheduleDateField; date.dateFieldStyle = &st::groupCallScheduleDateField;
@ -191,11 +192,13 @@ namespace Media::Stories {
.copyCallback = std::move(copyLinkCallback), .copyCallback = std::move(copyLinkCallback),
.submitCallback = std::move(submitCallback), .submitCallback = std::move(submitCallback),
.filterCallback = std::move(filterCallback), .filterCallback = std::move(filterCallback),
.stMultiSelect = &st::groupCallMultiSelect, .stMultiSelect = viewerStyle ? &st::groupCallMultiSelect : nullptr,
.stComment = &st::groupCallShareBoxComment, .stComment = viewerStyle ? &st::groupCallShareBoxComment : nullptr,
.st = &st::groupCallShareBoxList, .st = viewerStyle ? &st::groupCallShareBoxList : nullptr,
.stLabel = &st::groupCallField, .stLabel = viewerStyle ? &st::groupCallField : nullptr,
.scheduleBoxStyle = scheduleStyle(), .scheduleBoxStyle = (viewerStyle
? viewerScheduleStyle()
: HistoryView::ScheduleBoxStyleArgs()),
}); });
} }

View file

@ -21,6 +21,7 @@ namespace Media::Stories {
[[nodiscard]] object_ptr<Ui::BoxContent> PrepareShareBox( [[nodiscard]] object_ptr<Ui::BoxContent> PrepareShareBox(
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
FullStoryId id); FullStoryId id,
bool viewerStyle = false);
} // namespace Media::Stories } // namespace Media::Stories