mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-13 10:37:41 +00:00
added any profile photo delete, fixed profile photo upload
This commit is contained in:
parent
39981835ce
commit
1bd986d2cb
@ -951,7 +951,7 @@ void AppClass::killDownloadSessions() {
|
||||
}
|
||||
}
|
||||
|
||||
void AppClass::photoUpdated(const FullMsgId &msgId, const MTPInputFile &file) {
|
||||
void AppClass::photoUpdated(const FullMsgId &msgId, bool silent, const MTPInputFile &file) {
|
||||
if (!App::self()) return;
|
||||
|
||||
QMap<FullMsgId, PeerId>::iterator i = photoUpdates.find(msgId);
|
||||
@ -1040,7 +1040,7 @@ void AppClass::uploadProfilePhoto(const QImage &tosend, const PeerId &peerId) {
|
||||
|
||||
ReadyLocalMedia ready(PreparePhoto, file, filename, filesize, data, id, id, qsl("jpg"), peerId, photo, photoThumbs, MTP_documentEmpty(MTP_long(0)), jpeg, false, false, 0);
|
||||
|
||||
connect(App::uploader(), SIGNAL(photoReady(const FullMsgId&, const MTPInputFile&)), App::app(), SLOT(photoUpdated(const FullMsgId&, const MTPInputFile&)), Qt::UniqueConnection);
|
||||
connect(App::uploader(), SIGNAL(photoReady(const FullMsgId&,bool,const MTPInputFile&)), App::app(), SLOT(photoUpdated(const FullMsgId&,bool,const MTPInputFile&)), Qt::UniqueConnection);
|
||||
|
||||
FullMsgId newId(peerToChannel(peerId), clientMsgId());
|
||||
App::app()->regPhotoUpdate(peerId, newId);
|
||||
|
@ -191,7 +191,7 @@ public slots:
|
||||
|
||||
void doMtpUnpause();
|
||||
|
||||
void photoUpdated(const FullMsgId &msgId, const MTPInputFile &file);
|
||||
void photoUpdated(const FullMsgId &msgId, bool silent, const MTPInputFile &file);
|
||||
|
||||
void onSwitchDebugMode();
|
||||
void onSwitchTestMode();
|
||||
|
@ -398,7 +398,7 @@ void MediaView::updateDropdown() {
|
||||
_btnSaveAs->setVisible(true);
|
||||
_btnCopy->setVisible((_doc && fileShown()) || (_photo && _photo->loaded()));
|
||||
_btnForward->setVisible(_canForward);
|
||||
_btnDelete->setVisible(_canDelete || (_photo && App::self() && App::self()->photoId == _photo->id) || (_photo && _photo->peer && _photo->peer->photoId == _photo->id && (_photo->peer->isChat() || (_photo->peer->isChannel() && _photo->peer->asChannel()->amCreator()))));
|
||||
_btnDelete->setVisible(_canDelete || (_photo && App::self() && _user == App::self()) || (_photo && _photo->peer && _photo->peer->photoId == _photo->id && (_photo->peer->isChat() || (_photo->peer->isChannel() && _photo->peer->asChannel()->amCreator()))));
|
||||
_btnViewAll->setVisible((_overview != OverviewCount) && _history);
|
||||
_btnViewAll->setText(lang(_doc ? lng_mediaview_files_all : lng_mediaview_photos_all));
|
||||
_dropdown.updateButtons();
|
||||
@ -707,6 +707,21 @@ void MediaView::onDelete() {
|
||||
if (!_msgid) {
|
||||
if (App::self() && _photo && App::self()->photoId == _photo->id) {
|
||||
App::app()->peerClearPhoto(App::self()->id);
|
||||
} else if (_user && _user == App::self()) {
|
||||
for (int32 i = 0, l = _user->photos.size(); i != l; ++i) {
|
||||
if (_user->photos.at(i) == _photo) {
|
||||
_user->photos.removeAt(i);
|
||||
MTP::send(MTPphotos_DeletePhotos(MTP_vector<MTPInputPhoto>(1, MTP_inputPhoto(MTP_long(_photo->id), MTP_long(_photo->access)))), rpcDone(&MediaView::deletePhotosDone), rpcFail(&MediaView::deletePhotosFail));
|
||||
if (_user->photos.isEmpty()) {
|
||||
hide();
|
||||
} else if (i + 1 < l) {
|
||||
showPhoto(_user->photos.at(i), _user);
|
||||
} else {
|
||||
showPhoto(_user->photos.at(i - 1), _user);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (_photo->peer && _photo->peer->photoId == _photo->id) {
|
||||
App::app()->peerClearPhoto(_photo->peer->id);
|
||||
}
|
||||
@ -2090,6 +2105,15 @@ void MediaView::userPhotosLoaded(UserData *u, const MTPphotos_Photos &photos, mt
|
||||
if (App::wnd()) App::wnd()->mediaOverviewUpdated(u, OverviewCount);
|
||||
}
|
||||
|
||||
void MediaView::deletePhotosDone(const MTPVector<MTPlong> &result) {
|
||||
}
|
||||
|
||||
bool MediaView::deletePhotosFail(const RPCError &error) {
|
||||
if (mtpIsFlood(error)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MediaView::updateHeader() {
|
||||
int32 index = _index, count = 0, addcount = (_migrated && _overview != OverviewCount) ? _migrated->overviewCount(_overview) : 0;
|
||||
if (_history) {
|
||||
|
@ -107,7 +107,9 @@ private:
|
||||
void loadBack();
|
||||
|
||||
void userPhotosLoaded(UserData *u, const MTPphotos_Photos &photos, mtpRequestId req);
|
||||
void filesLoaded(History *h, const MTPmessages_Messages &msgs, mtpRequestId req);
|
||||
|
||||
void deletePhotosDone(const MTPVector<MTPlong> &result);
|
||||
bool deletePhotosFail(const RPCError &error);
|
||||
|
||||
void updateHeader();
|
||||
void snapXY();
|
||||
|
@ -2054,8 +2054,8 @@ void MTProtoConnectionPrivate::socketStart(bool afterConfig) {
|
||||
_pingId = _pingMsgId = _pingIdToSend = _pingSendAt = 0;
|
||||
_pingSender.stop();
|
||||
|
||||
if (!noIPv4) DEBUG_LOG(("MTP Info: creating IPv4 connection to %1:%2 (tcp) and %1:%2 (http)..").arg(ip[IPv4address][TcpProtocol].c_str()).arg(port[IPv4address][TcpProtocol]).arg(ip[IPv4address][HttpProtocol].c_str()).arg(port[IPv4address][HttpProtocol]));
|
||||
if (!noIPv6) DEBUG_LOG(("MTP Info: creating IPv6 connection to [%1]:%2 (tcp) and [%1]:%2 (http)..").arg(ip[IPv6address][TcpProtocol].c_str()).arg(port[IPv6address][TcpProtocol]).arg(ip[IPv4address][HttpProtocol].c_str()).arg(port[IPv4address][HttpProtocol]));
|
||||
if (!noIPv4) DEBUG_LOG(("MTP Info: creating IPv4 connection to %1:%2 (tcp) and %3:%4 (http)..").arg(ip[IPv4address][TcpProtocol].c_str()).arg(port[IPv4address][TcpProtocol]).arg(ip[IPv4address][HttpProtocol].c_str()).arg(port[IPv4address][HttpProtocol]));
|
||||
if (!noIPv6) DEBUG_LOG(("MTP Info: creating IPv6 connection to [%1]:%2 (tcp) and [%3]:%4 (http)..").arg(ip[IPv6address][TcpProtocol].c_str()).arg(port[IPv6address][TcpProtocol]).arg(ip[IPv4address][HttpProtocol].c_str()).arg(port[IPv4address][HttpProtocol]));
|
||||
|
||||
_waitForConnectedTimer.start(_waitForConnected);
|
||||
if (_conn4) {
|
||||
|
Loading…
Reference in New Issue
Block a user