[DeckShare] Use the stable server client for the visual deck storage tab

This commit is contained in:
Lukas Brübach 2026-09-18 23:55:13 +02:00 committed by GitHub
parent bb06de724f
commit 4b870fdf06
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 8 deletions

View file

@ -672,7 +672,7 @@ void TabSupervisor::actTabVisualDeckStorage(bool checked)
void TabSupervisor::openTabVisualDeckStorage() void TabSupervisor::openTabVisualDeckStorage()
{ {
tabVisualDeckStorage = new TabDeckStorageVisual(this); tabVisualDeckStorage = new TabDeckStorageVisual(this, client);
myAddTab(tabVisualDeckStorage, aTabVisualDeckStorage); myAddTab(tabVisualDeckStorage, aTabVisualDeckStorage);
connect(tabVisualDeckStorage, &QObject::destroyed, this, [this] { connect(tabVisualDeckStorage, &QObject::destroyed, this, [this] {
tabVisualDeckStorage = nullptr; tabVisualDeckStorage = nullptr;

View file

@ -17,8 +17,8 @@
#include <libcockatrice/protocol/pb/response_deck_share_create.pb.h> #include <libcockatrice/protocol/pb/response_deck_share_create.pb.h>
#include <libcockatrice/protocol/pending_command.h> #include <libcockatrice/protocol/pending_command.h>
TabDeckStorageVisual::TabDeckStorageVisual(TabSupervisor *_tabSupervisor) TabDeckStorageVisual::TabDeckStorageVisual(TabSupervisor *_tabSupervisor, AbstractClient *_client)
: Tab(_tabSupervisor), visualDeckStorageWidget(new VisualDeckStorageWidget(this)) : Tab(_tabSupervisor), client(_client), visualDeckStorageWidget(new VisualDeckStorageWidget(this))
{ {
connect(this, &TabDeckStorageVisual::openDeckEditor, tabSupervisor, &TabSupervisor::openDeckInNewTab); connect(this, &TabDeckStorageVisual::openDeckEditor, tabSupervisor, &TabSupervisor::openDeckInNewTab);
connect(visualDeckStorageWidget, &VisualDeckStorageWidget::deckLoadRequested, this, connect(visualDeckStorageWidget, &VisualDeckStorageWidget::deckLoadRequested, this,
@ -35,7 +35,6 @@ TabDeckStorageVisual::TabDeckStorageVisual(TabSupervisor *_tabSupervisor)
} }
}); });
AbstractClient *client = tabSupervisor->getClient();
connect(client, &AbstractClient::statusChanged, this, &TabDeckStorageVisual::handleConnectionChanged); connect(client, &AbstractClient::statusChanged, this, &TabDeckStorageVisual::handleConnectionChanged);
shareDeckAvailable = (client->getStatus() == StatusLoggedIn); shareDeckAvailable = (client->getStatus() == StatusLoggedIn);
visualDeckStorageWidget->setShareAvailable(shareDeckAvailable); visualDeckStorageWidget->setShareAvailable(shareDeckAvailable);
@ -152,9 +151,9 @@ void TabDeckStorageVisual::actShareSelected()
} }
shareBar->setCreateEnabled(false); shareBar->setCreateEnabled(false);
PendingCommand *pend = tabSupervisor->getClient()->prepareSessionCommand(cmd); PendingCommand *pend = client->prepareSessionCommand(cmd);
connect(pend, &PendingCommand::finished, this, &TabDeckStorageVisual::shareFinished); connect(pend, &PendingCommand::finished, this, &TabDeckStorageVisual::shareFinished);
tabSupervisor->getClient()->sendCommand(pend); client->sendCommand(pend);
} }
void TabDeckStorageVisual::shareFinished(const Response &response, const CommandContainer & /*commandContainer*/) void TabDeckStorageVisual::shareFinished(const Response &response, const CommandContainer & /*commandContainer*/)
@ -175,7 +174,7 @@ void TabDeckStorageVisual::shareFinished(const Response &response, const Command
const QDateTime expiry = QDateTime::fromSecsSinceEpoch(resp.expires_at(), Qt::UTC); const QDateTime expiry = QDateTime::fromSecsSinceEpoch(resp.expires_at(), Qt::UTC);
#endif #endif
const QString link = DeckShareUtils::buildShareLink(tabSupervisor->getClient(), token); const QString link = DeckShareUtils::buildShareLink(client, token);
DeckShareUtils::copyShareLinkToClipboard(link); DeckShareUtils::copyShareLinkToClipboard(link);
showShareNotice( showShareNotice(

View file

@ -30,7 +30,7 @@ class TabDeckStorageVisual final : public Tab
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit TabDeckStorageVisual(TabSupervisor *_tabSupervisor); explicit TabDeckStorageVisual(TabSupervisor *_tabSupervisor, AbstractClient *_client);
void retranslateUi() override; void retranslateUi() override;
[[nodiscard]] QString getTabText() const override [[nodiscard]] QString getTabText() const override
@ -73,6 +73,7 @@ private:
VisualDeckStorageWidget *visualDeckStorageWidget; VisualDeckStorageWidget *visualDeckStorageWidget;
ShareBarWidget *shareBar; ShareBarWidget *shareBar;
AbstractClient *client;
bool shareDeckAvailable = false; bool shareDeckAvailable = false;
}; };