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 "lang/lang_keys.h"
|
2020-06-15 16:25:02 +00:00
|
|
|
#include "core/application.h"
|
2020-06-18 18:04:16 +00:00
|
|
|
#include "main/main_domain.h"
|
2020-06-09 16:57:05 +00:00
|
|
|
#include "main/main_session.h"
|
2020-06-18 18:04:16 +00:00
|
|
|
#include "storage/storage_domain.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 {
|
2020-03-14 09:45:49 +00:00
|
|
|
{
|
|
|
|
1009020,
|
2020-07-02 18:11:53 +00:00
|
|
|
"- Fix crash in shared links search.\n"
|
2020-03-14 09:45:49 +00:00
|
|
|
|
2020-07-02 18:11:53 +00:00
|
|
|
"- Fix blurred thumbnails in albums with video files.\n"
|
2020-03-14 09:45:49 +00:00
|
|
|
|
2020-07-02 18:11:53 +00:00
|
|
|
"- Fix a possible crash in animated stickers rendering."
|
2020-03-27 16:15:16 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
1009022,
|
2020-07-02 18:11:53 +00:00
|
|
|
"- Organize chats into Chat Folders if you have too many chats.\n"
|
2020-03-31 09:06:33 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
2000001,
|
2020-07-02 18:11:53 +00:00
|
|
|
"- Switch between folders using Ctrl+1, ..., Ctrl+8.\n"
|
2020-03-31 09:06:33 +00:00
|
|
|
|
2020-07-02 18:11:53 +00:00
|
|
|
"- Fix crash when a pinned in folder chat was added to archive.\n"
|
2020-03-31 09:06:33 +00:00
|
|
|
|
2020-07-02 18:11:53 +00:00
|
|
|
"- Fix font issues in Linux version."
|
2020-06-03 11:51:27 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
2001008,
|
2020-07-02 18:11:53 +00:00
|
|
|
"- Add support for full group message history export.\n"
|
2020-06-03 11:51:27 +00:00
|
|
|
|
2020-07-02 18:11:53 +00:00
|
|
|
"- Allow export of a single chat message history in JSON format."
|
2020-06-29 17:51:06 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
2001014,
|
2020-07-02 18:11:53 +00:00
|
|
|
"- Support for multiple accounts."
|
|
|
|
},
|
|
|
|
{
|
|
|
|
2001017,
|
|
|
|
"- Fix messages editing in a non-active account.\n"
|
|
|
|
|
|
|
|
"- Fix large animated emoji messages editing.\n"
|
|
|
|
|
|
|
|
"- Fix high definition GIF animations opening in media viewer.\n"
|
|
|
|
|
|
|
|
"- Multiple crash fixes."
|
2020-07-08 05:41:20 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
2001018,
|
|
|
|
"- Fix a possible crash in Picture-in-Picture video player.\n"
|
|
|
|
|
|
|
|
"- Fix copying links from message texts.\n"
|
|
|
|
|
2020-07-08 06:08:45 +00:00
|
|
|
"- Raise file size limit to 2000 MB.\n"
|
|
|
|
|
2020-07-08 05:41:20 +00:00
|
|
|
"- Allow using system window frame in Windows and Linux."
|
|
|
|
},
|
2020-07-16 07:47:52 +00:00
|
|
|
{
|
|
|
|
2001019,
|
|
|
|
"- File uploading in an inactive account correctly finishes.\n"
|
|
|
|
|
|
|
|
"- Stickers panel works correctly after switching between accounts.\n"
|
|
|
|
|
|
|
|
"- Large .webp files are not shown as stickers.\n"
|
|
|
|
|
|
|
|
"- MacBook TouchBar support was fully rewritten with fixes for multiple accounts.\n"
|
|
|
|
|
|
|
|
"- Custom window title bar works in all Linux versions.\n"
|
|
|
|
|
|
|
|
"- Passcode doesn't auto-lock while you're active in other apps on Linux X11."
|
|
|
|
},
|
2020-07-24 13:03:51 +00:00
|
|
|
{
|
|
|
|
2001021,
|
|
|
|
"- Edit your scheduled messages.\n"
|
|
|
|
|
2020-07-24 15:54:47 +00:00
|
|
|
"- See the unread messages indicator for your additional accounts on the main menu button.\n"
|
2020-07-24 13:03:51 +00:00
|
|
|
|
|
|
|
"- Use Auto-Night Mode to make Telegram night mode match the system Dark Mode settings.\n"
|
|
|
|
|
|
|
|
"- Enjoy dark native window frame for Telegram night mode on Windows.\n"
|
|
|
|
},
|
2017-12-29 18:17:07 +00:00
|
|
|
};
|
2019-07-04 14:59:42 +00:00
|
|
|
};
|
2017-12-29 18:17:07 +00:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
Changelogs::Changelogs(not_null<Main::Session*> session, int oldVersion)
|
2017-12-29 18:17:07 +00:00
|
|
|
: _session(session)
|
|
|
|
, _oldVersion(oldVersion) {
|
2019-04-18 08:28:43 +00:00
|
|
|
_session->data().chatsListChanges(
|
|
|
|
) | rpl::filter([](Data::Folder *folder) {
|
|
|
|
return !folder;
|
|
|
|
}) | rpl::start_with_next([=] {
|
|
|
|
requestCloudLogs();
|
|
|
|
}, _chatsSubscription);
|
2017-12-29 18:17:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<Changelogs> Changelogs::Create(
|
2019-07-24 11:45:24 +00:00
|
|
|
not_null<Main::Session*> session) {
|
2020-06-18 18:04:16 +00:00
|
|
|
auto &local = Core::App().domain().local();
|
2020-06-15 16:25:02 +00:00
|
|
|
const auto oldVersion = local.oldVersion();
|
|
|
|
local.clearOldVersion();
|
2017-12-29 18:17:07 +00:00
|
|
|
return (oldVersion > 0 && oldVersion < AppVersion)
|
|
|
|
? std::make_unique<Changelogs>(session, oldVersion)
|
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Changelogs::requestCloudLogs() {
|
2019-04-18 08:28:43 +00:00
|
|
|
_chatsSubscription.destroy();
|
2017-12-29 18:17:07 +00:00
|
|
|
|
|
|
|
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:
|
2019-07-05 13:38:38 +00:00
|
|
|
resultEmpty = result.c_updatesCombined().vupdates().v.isEmpty();
|
2017-12-29 18:17:07 +00:00
|
|
|
break;
|
|
|
|
case mtpc_updates:
|
2019-07-05 13:38:38 +00:00
|
|
|
resultEmpty = result.c_updates().vupdates().v.isEmpty();
|
2017-12-29 18:17:07 +00:00
|
|
|
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) {
|
2019-06-19 16:39:25 +00:00
|
|
|
const auto text = tr::lng_new_version_wrap(
|
|
|
|
tr::now,
|
2017-12-29 18:17:07 +00:00
|
|
|
lt_version,
|
2018-11-08 05:50:18 +00:00
|
|
|
QString::fromLatin1(AppVersionStr),
|
2017-12-29 18:17:07 +00:00
|
|
|
lt_changes,
|
2019-06-19 15:09:03 +00:00
|
|
|
tr::lng_new_version_minor(tr::now),
|
2017-12-29 18:17:07 +00:00
|
|
|
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);
|
2019-02-11 12:50:35 +00:00
|
|
|
_session->data().serviceNotification(textWithEntities);
|
2017-12-29 18:17:07 +00:00
|
|
|
_addedSomeLocal = true;
|
|
|
|
};
|
|
|
|
|
2018-09-26 14:58:09 +00:00
|
|
|
void Changelogs::addBetaLogs() {
|
2019-01-13 08:03:34 +00:00
|
|
|
for (const auto [version, changes] : BetaLogs()) {
|
2018-09-26 14:58:09 +00:00
|
|
|
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;
|
|
|
|
}
|
2020-07-02 18:11:53 +00:00
|
|
|
const auto text = [&] {
|
|
|
|
static const auto simple = u"\n- "_q;
|
|
|
|
static const auto separator = QString::fromUtf8("\n\xE2\x80\xA2 ");
|
|
|
|
auto result = QString::fromUtf8(changes).trimmed();
|
|
|
|
if (result.startsWith(simple.midRef(1))) {
|
2020-07-02 19:02:59 +00:00
|
|
|
result = separator.mid(1) + result.mid(simple.size() - 1);
|
2020-07-02 18:11:53 +00:00
|
|
|
}
|
|
|
|
return result.replace(simple, separator);
|
|
|
|
}();
|
2017-12-29 18:17:07 +00:00
|
|
|
const auto version = FormatVersionDisplay(changeVersion);
|
2020-07-02 18:11:53 +00:00
|
|
|
const auto log = qsl("New in version %1:\n\n").arg(version) + text;
|
|
|
|
addLocalLog(log);
|
2017-12-29 18:17:07 +00:00
|
|
|
}
|
|
|
|
|
2020-09-08 15:01:12 +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);
|
|
|
|
}
|
|
|
|
|
2017-12-29 18:17:07 +00:00
|
|
|
} // namespace Core
|