2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-04 00:25:17 +00:00

Refactored code.

- Refactored passing message id to edit media.
 - Removed get/setEditMedia from mainwidget.
 - Combined onEditMedia and onSendFileConfirm in single method.
 - Added argument in FileLoadTask to pass message id to edit media.
 - Renamed flags in apiwrap.
 - Added check for allowing edit media when use clipboard.
 - Removed unused fileIsValidForAlbum.
 - Removed LOGs.
 - Replaced _isNotAlbum with _isAlbum.
 - Removed _viaRemoteContent.
 - Removed _newMediaPath.
 - Added empty() to MessageGroupId.
This commit is contained in:
23rd
2019-04-02 13:38:53 +03:00
committed by John Preston
parent 4988d21819
commit 5d8888bb8b
14 changed files with 94 additions and 118 deletions

View File

@@ -842,11 +842,9 @@ void MainWidget::cancelUploadLayer(not_null<HistoryItem*> item) {
Ui::hideLayer();
if (const auto item = App::histItemById(itemId)) {
const auto history = item->history();
if (!item->isEditingMedia()) {
if (!IsServerMsgId(itemId.msg)) {
item->destroy();
history->requestChatListMessage();
}
if (!IsServerMsgId(itemId.msg)) {
item->destroy();
history->requestChatListMessage();
} else {
item->returnSavedMedia();
session().uploader().cancel(item->fullId());
@@ -1318,15 +1316,8 @@ void MainWidget::inlineResultLoadFailed(FileLoader *loader, bool started) {
}
void MainWidget::onSendFileConfirm(
const std::shared_ptr<FileLoadResult> &file) {
_history->sendFileConfirmed(file);
}
void MainWidget::onEditMedia(
const std::shared_ptr<FileLoadResult> &file,
const FullMsgId &oldId) {
LOG(("ON EDIT MEDIA"));
App::main()->setEditMedia(FullMsgId());
const std::optional<FullMsgId> &oldId) {
_history->sendFileConfirmed(file, oldId);
}
@@ -3721,7 +3712,6 @@ void MainWidget::updateReceived(const mtpPrime *from, const mtpPrime *end) {
void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
switch (updates.type()) {
case mtpc_updates: {
LOG(("TYPE 1"));
auto &d = updates.c_updates();
if (d.vseq.v) {
if (d.vseq.v <= updSeq) {
@@ -3742,7 +3732,6 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
} break;
case mtpc_updatesCombined: {
LOG(("TYPE 2"));
auto &d = updates.c_updatesCombined();
if (d.vseq_start.v) {
if (d.vseq_start.v <= updSeq) {
@@ -3763,7 +3752,6 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
} break;
case mtpc_updateShort: {
LOG(("TYPE 3"));
auto &d = updates.c_updateShort();
feedUpdate(d.vupdate);
@@ -3771,7 +3759,6 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
} break;
case mtpc_updateShortMessage: {
LOG(("TYPE 4"));
auto &d = updates.c_updateShortMessage();
if (!session().data().userLoaded(d.vuser_id.v)
|| (d.has_via_bot_id() && !session().data().userLoaded(d.vvia_bot_id.v))
@@ -3787,7 +3774,6 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
} break;
case mtpc_updateShortChatMessage: {
LOG(("TYPE 5"));
auto &d = updates.c_updateShortChatMessage();
const auto noFrom = !session().data().userLoaded(d.vfrom_id.v);
const auto chat = session().data().chatLoaded(d.vchat_id.v);
@@ -3809,7 +3795,6 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
} break;
case mtpc_updateShortSentMessage: {
LOG(("TYPE 6"));
auto &d = updates.c_updateShortSentMessage();
if (!IsServerMsgId(d.vid.v)) {
LOG(("API Error: Bad msgId got from server: %1").arg(d.vid.v));
@@ -3849,7 +3834,6 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
} break;
case mtpc_updatesTooLong: {
LOG(("TYPE 7"));
MTP_LOG(0, ("getDifference { good - updatesTooLong received }%1").arg(cTestMode() ? " TESTMODE" : ""));
return getDifference();
} break;