mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
[DeckShare] Extract the share-creation response handling into DeckShareUtils
This commit is contained in:
parent
4b870fdf06
commit
a5b2114296
5 changed files with 45 additions and 35 deletions
|
|
@ -4,6 +4,8 @@
|
|||
#include <QGuiApplication>
|
||||
#include <QTimeZone>
|
||||
#include <libcockatrice/network/client/abstract/abstract_client.h>
|
||||
#include <libcockatrice/protocol/pb/response.pb.h>
|
||||
#include <libcockatrice/protocol/pb/response_deck_share_create.pb.h>
|
||||
|
||||
namespace DeckShareUtils
|
||||
{
|
||||
|
|
@ -25,4 +27,21 @@ QString formatShareExpiry(const QDateTime &expiry)
|
|||
return expiry.toLocalTime().toString();
|
||||
}
|
||||
|
||||
ShareResponse handleShareResponse(const AbstractClient *client, const Response &response)
|
||||
{
|
||||
const Response_DeckShareCreate &resp = response.GetExtension(Response_DeckShareCreate::ext);
|
||||
const QString token = QString::fromStdString(resp.token());
|
||||
|
||||
const QString link = buildShareLink(client, token);
|
||||
copyShareLinkToClipboard(link);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
||||
const QDateTime expiry = QDateTime::fromSecsSinceEpoch(resp.expires_at(), QTimeZone::UTC);
|
||||
#else
|
||||
const QDateTime expiry = QDateTime::fromSecsSinceEpoch(resp.expires_at(), Qt::UTC);
|
||||
#endif
|
||||
|
||||
return {link, expiry};
|
||||
}
|
||||
|
||||
} // namespace DeckShareUtils
|
||||
Loading…
Add table
Add a link
Reference in a new issue