2017-12-29 18:17:07 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-12-29 18:17:07 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-12-29 18:17:07 +00:00
|
|
|
*/
|
|
|
|
#include "core/changelogs.h"
|
|
|
|
|
|
|
|
#include "storage/localstorage.h"
|
|
|
|
#include "lang/lang_keys.h"
|
2018-01-04 10:22:53 +00:00
|
|
|
#include "data/data_session.h"
|
2017-12-29 18:17:07 +00:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "apiwrap.h"
|
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
namespace {
|
|
|
|
|
2018-09-26 14:58:09 +00:00
|
|
|
std::map<int, const char*> BetaLogs() {
|
2017-12-29 18:17:07 +00:00
|
|
|
return {
|
2018-08-01 17:22:41 +00:00
|
|
|
{
|
|
|
|
1003011,
|
2018-10-16 20:10:26 +00:00
|
|
|
"- Added a new night theme.\n"
|
2018-08-01 17:22:41 +00:00
|
|
|
|
2018-10-16 20:10:26 +00:00
|
|
|
"- You can now assign custom themes "
|
2018-08-01 17:22:41 +00:00
|
|
|
"as night and day themes to quickly switch between them."
|
2018-09-01 10:56:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
1003015,
|
2018-10-16 20:10:26 +00:00
|
|
|
"- Improved local caching "
|
2018-09-01 10:56:17 +00:00
|
|
|
"for images and GIF animations.\n"
|
|
|
|
|
2018-10-16 20:10:26 +00:00
|
|
|
"- Control how much disk space is used by the cache "
|
2018-09-01 10:56:17 +00:00
|
|
|
"and for how long the cached files are stored."
|
2018-09-26 15:33:48 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
1003017,
|
2018-10-16 20:10:26 +00:00
|
|
|
"- Fully redisigned Settings section.\n"
|
2018-09-26 15:33:48 +00:00
|
|
|
|
2018-10-16 20:10:26 +00:00
|
|
|
"- New theme selector in Chat Settings.\n"
|
|
|
|
"- New settings: Peer-to-Peer settings for calls, "
|
2018-09-26 15:33:48 +00:00
|
|
|
"disable animations for low performance computers.\n"
|
|
|
|
|
2018-10-16 20:10:26 +00:00
|
|
|
"- Various other improvements."
|
|
|
|
},
|
|
|
|
{
|
|
|
|
1004004,
|
|
|
|
"- Interface scaling for large screens, up to 300% "
|
|
|
|
"(up to 150% for macOS retina screens).\n"
|
|
|
|
|
|
|
|
"- Updated emoji."
|
2018-09-26 15:33:48 +00:00
|
|
|
},
|
2018-11-08 13:29:29 +00:00
|
|
|
{
|
|
|
|
1004005,
|
|
|
|
"- Listen to voice and video messages in 2X mode "
|
|
|
|
"if you're in a hurry.\n"
|
|
|
|
|
|
|
|
"- Find video messages in the shared voice messages section.\n"
|
|
|
|
|
|
|
|
"- Add a comment when you share posts from channels.\n"
|
|
|
|
|
|
|
|
"- View all photos and videos "
|
|
|
|
"in Twitter and Instagram link previews.\n"
|
|
|
|
|
|
|
|
"- Bug fixes and other minor improvements."
|
2018-12-04 15:58:33 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
1004008,
|
|
|
|
"- Add emoji to media captions.\n"
|
|
|
|
|
|
|
|
"- Switch off the 'Count unread messages' option "
|
|
|
|
"in Settings > Notifications if you want to see "
|
|
|
|
"the unread chats count in the badge instead."
|
2018-11-08 13:29:29 +00:00
|
|
|
}
|
2017-12-29 18:17:07 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
QString FormatVersionDisplay(int version) {
|
|
|
|
return QString::number(version / 1000000)
|
|
|
|
+ '.' + QString::number((version % 1000000) / 1000)
|
|
|
|
+ ((version % 1000)
|
|
|
|
? ('.' + QString::number(version % 1000))
|
|
|
|
: QString());
|
|
|
|
}
|
|
|
|
|
|
|
|
QString FormatVersionPrecise(int version) {
|
|
|
|
return QString::number(version / 1000000)
|
|
|
|
+ '.' + QString::number((version % 1000000) / 1000)
|
|
|
|
+ '.' + QString::number(version % 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
Changelogs::Changelogs(not_null<AuthSession*> session, int oldVersion)
|
|
|
|
: _session(session)
|
|
|
|
, _oldVersion(oldVersion) {
|
|
|
|
_chatsSubscription = subscribe(
|
|
|
|
_session->data().moreChatsLoaded(),
|
|
|
|
[this] { requestCloudLogs(); });
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<Changelogs> Changelogs::Create(
|
|
|
|
not_null<AuthSession*> session) {
|
|
|
|
const auto oldVersion = Local::oldMapVersion();
|
|
|
|
return (oldVersion > 0 && oldVersion < AppVersion)
|
|
|
|
? std::make_unique<Changelogs>(session, oldVersion)
|
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Changelogs::requestCloudLogs() {
|
|
|
|
unsubscribe(base::take(_chatsSubscription));
|
|
|
|
|
|
|
|
const auto callback = [this](const MTPUpdates &result) {
|
|
|
|
_session->api().applyUpdates(result);
|
|
|
|
|
|
|
|
auto resultEmpty = true;
|
|
|
|
switch (result.type()) {
|
|
|
|
case mtpc_updateShortMessage:
|
|
|
|
case mtpc_updateShortChatMessage:
|
|
|
|
case mtpc_updateShort:
|
|
|
|
resultEmpty = false;
|
|
|
|
break;
|
|
|
|
case mtpc_updatesCombined:
|
|
|
|
resultEmpty = result.c_updatesCombined().vupdates.v.isEmpty();
|
|
|
|
break;
|
|
|
|
case mtpc_updates:
|
|
|
|
resultEmpty = result.c_updates().vupdates.v.isEmpty();
|
|
|
|
break;
|
|
|
|
case mtpc_updatesTooLong:
|
|
|
|
case mtpc_updateShortSentMessage:
|
|
|
|
LOG(("API Error: Bad updates type in app changelog."));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (resultEmpty) {
|
|
|
|
addLocalLogs();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
_session->api().requestChangelog(
|
|
|
|
FormatVersionPrecise(_oldVersion),
|
2018-06-04 15:35:11 +00:00
|
|
|
crl::guard(this, callback));
|
2017-12-29 18:17:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Changelogs::addLocalLogs() {
|
2018-09-26 15:11:16 +00:00
|
|
|
if (AppBetaVersion || cAlphaVersion()) {
|
2018-09-26 14:58:09 +00:00
|
|
|
addBetaLogs();
|
2017-12-29 18:17:07 +00:00
|
|
|
}
|
|
|
|
if (!_addedSomeLocal) {
|
|
|
|
const auto text = lng_new_version_wrap(
|
|
|
|
lt_version,
|
2018-11-08 05:50:18 +00:00
|
|
|
QString::fromLatin1(AppVersionStr),
|
2017-12-29 18:17:07 +00:00
|
|
|
lt_changes,
|
|
|
|
lang(lng_new_version_minor),
|
|
|
|
lt_link,
|
|
|
|
qsl("https://desktop.telegram.org/changelog"));
|
|
|
|
addLocalLog(text.trimmed());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Changelogs::addLocalLog(const QString &text) {
|
|
|
|
auto textWithEntities = TextWithEntities{ text };
|
|
|
|
TextUtilities::ParseEntities(textWithEntities, TextParseLinks);
|
2018-09-27 20:31:48 +00:00
|
|
|
_session->data().serviceNotification(
|
2017-12-29 18:17:07 +00:00
|
|
|
textWithEntities,
|
2018-09-27 20:31:48 +00:00
|
|
|
MTP_messageMediaEmpty());
|
2017-12-29 18:17:07 +00:00
|
|
|
_addedSomeLocal = true;
|
|
|
|
};
|
|
|
|
|
2018-09-26 14:58:09 +00:00
|
|
|
void Changelogs::addBetaLogs() {
|
|
|
|
for (const auto[version, changes] : BetaLogs()) {
|
|
|
|
addBetaLog(version, changes);
|
2017-12-29 18:17:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-26 14:58:09 +00:00
|
|
|
void Changelogs::addBetaLog(int changeVersion, const char *changes) {
|
2017-12-29 18:17:07 +00:00
|
|
|
if (_oldVersion >= changeVersion) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto version = FormatVersionDisplay(changeVersion);
|
|
|
|
const auto text = qsl("New in version %1:\n\n").arg(version)
|
|
|
|
+ QString::fromUtf8(changes).trimmed();
|
|
|
|
addLocalLog(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Core
|