added Add Members to channel from profile for creator

This commit is contained in:
John Preston 2015-09-22 12:58:40 +03:00
parent 72d0271e4d
commit 38e3399b1d
10 changed files with 55 additions and 30 deletions

View File

@ -35,7 +35,7 @@ _contacts(&App::main()->contactsList()),
_sel(0),
_filteredSel(-1),
_mouseSel(false),
_selCount(1),
_selCount(0),
_searching(false),
_byUsernameSel(-1),
_addContactLnk(this, lang(lng_add_contact_button)) {
@ -47,7 +47,7 @@ _contacts(&App::main()->contactsList()),
_sel(0),
_filteredSel(-1),
_mouseSel(false),
_selCount(1),
_selCount(0),
_searching(false),
_byUsernameSel(-1),
_addContactLnk(this, lang(lng_add_contact_button)) {
@ -194,7 +194,17 @@ ContactsInner::ContactData *ContactsInner::contactData(DialogRow *row) {
ContactsData::const_iterator i = _contactsData.constFind(peer);
if (i == _contactsData.cend()) {
_contactsData.insert(peer, data = new ContactData());
data->inchat = (_chat && peer->isUser()) ? _chat->participants.contains(peer->asUser()) : ((_creating == CreatingGroupGroup || _channel) ? (peer == App::self()) : false);
if (peer->isUser()) {
if (_chat) {
data->inchat = _chat->participants.contains(peer->asUser());
} else if (_creating == CreatingGroupGroup || _channel) {
data->inchat = (peerToUser(peer->id) == MTP::authedId());
} else {
data->inchat = false;
}
} else {
data->inchat = false;
}
data->check = _checkedContacts.contains(peer);
data->name.setText(st::profileListNameFont, peer->name, _textNameOptions);
if (peer->isUser()) {
@ -505,7 +515,15 @@ void ContactsInner::changeCheckState(ContactData *data, PeerData *peer) {
}
int32 ContactsInner::selectedCount() const {
return _selCount + ((_chat && _chat->count >= 0) ? _chat->count : 0);
int32 result = _selCount;
if (_chat) {
result += (_chat->count > 0) ? _chat->count : 1;
} else if (_channel) {
result += (_channel->count > 0) ? _channel->count : 1;
} else if (_creating == CreatingGroupGroup) {
result += 1;
}
return result;
}
void ContactsInner::updateSel() {

View File

@ -17,9 +17,9 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
*/
#pragma once
static const int32 AppVersion = 8057;
static const wchar_t *AppVersionStr = L"0.8.57";
static const bool DevVersion = false;
static const int32 AppVersion = 8058;
static const wchar_t *AppVersionStr = L"0.8.58";
static const bool DevVersion = true;
static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)";
static const wchar_t *AppName = L"Telegram Desktop";

View File

@ -1948,6 +1948,7 @@ bool DialogsWidget::peopleFailed(const RPCError &error, mtpRequestId req) {
bool DialogsWidget::addNewContact(int32 uid, bool show) {
_filter.setText(QString());
_filter.updatePlaceholder();
onFilterUpdate();
int32 to = list.addNewContact(uid, true);
if (to < -1 || !show) return false;
@ -2201,12 +2202,14 @@ void DialogsWidget::scrollToPeer(const PeerId &peer, MsgId msgId) {
void DialogsWidget::removePeer(PeerData *peer) {
_filter.setText(QString());
_filter.updatePlaceholder();
onFilterUpdate();
list.removePeer(peer);
}
void DialogsWidget::removeContact(UserData *user) {
_filter.setText(QString());
_filter.updatePlaceholder();
onFilterUpdate();
list.removeContact(user);
}

View File

@ -97,8 +97,10 @@ bool FlatTextarea::heightAutoupdated() {
}
if (height() != newh) {
resize(width(), newh);
_inHeightCheck = false;
return true;
}
_inHeightCheck = false;
return false;
}
@ -893,6 +895,7 @@ void FlatTextarea::keyPressEvent(QKeyEvent *e) {
void FlatTextarea::resizeEvent(QResizeEvent *e) {
_phelided = _st.font->m.elidedText(_ph, Qt::ElideRight, width() - _st.textMrg.left() - _st.textMrg.right() - _st.phPos.x() - 1);
QTextEdit::resizeEvent(e);
checkContentHeight();
}
void FlatTextarea::mousePressEvent(QMouseEvent *e) {

View File

@ -1654,11 +1654,6 @@ void MessageField::dropEvent(QDropEvent *e) {
}
}
void MessageField::resizeEvent(QResizeEvent *e) {
FlatTextarea::resizeEvent(e);
checkContentHeight();
}
bool MessageField::canInsertFromMimeData(const QMimeData *source) const {
if (source->hasImage()) return true;
return FlatTextarea::canInsertFromMimeData(source);
@ -3416,8 +3411,8 @@ bool HistoryWidget::messagesFailed(const RPCError &error, mtpRequestId requestId
if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;
if (error.type() == qstr("CHANNEL_PRIVATE")) {
App::wnd()->showLayer(new ConfirmBox(lang(lng_channel_not_accessible), true));
App::main()->showDialogs();
App::wnd()->showLayer(new ConfirmBox(lang(lng_channel_not_accessible), true));
return true;
}
@ -5893,15 +5888,24 @@ void HistoryWidget::onFullPeerUpdated(PeerData *data) {
void HistoryWidget::peerUpdated(PeerData *data) {
if (data && data == _peer) {
updateListSize();
if (!_showAnim.animating()) updateControlsVisibility();
if (_peer->isChannel()) updateReportSpamStatus();
if (data->isChat() && data->asChat()->count > 0 && data->asChat()->participants.isEmpty()) {
App::api()->requestFullPeer(data);
} else if (data->isUser() && data->asUser()->blocked == UserBlockUnknown) {
App::api()->requestFullPeer(data);
} else if (!_scroll.isHidden() && (_unblock.isHidden() == isBlocked() || (!isBlocked() && _joinChannel.isHidden() == isJoinChannel()))) {
}
if (!_showAnim.animating()) {
bool resize = (_unblock.isHidden() == isBlocked() || (!isBlocked() && _joinChannel.isHidden() == isJoinChannel()));
bool newCanSendMessages = canSendMessages(_peer);
if (newCanSendMessages != _canSendMessages) {
_canSendMessages = newCanSendMessages;
if (!_canSendMessages) {
cancelReply();
}
resize = true;
}
updateControlsVisibility();
resizeEvent(0);
if (resize) resizeEvent(0);
}
App::main()->updateOnlineDisplay();
}

View File

@ -187,7 +187,6 @@ class MessageField : public FlatTextarea {
public:
MessageField(HistoryWidget *history, const style::flatTextarea &st, const QString &ph = QString(), const QString &val = QString());
void dropEvent(QDropEvent *e);
void resizeEvent(QResizeEvent *e);
bool canInsertFromMimeData(const QMimeData *source) const;
void insertFromMimeData(const QMimeData *source);

View File

@ -4503,6 +4503,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
const MTPDupdateChannel &d(update.c_updateChannel());
if (ChannelData *channel = App::channelLoaded(d.vchannel_id.v)) {
App::markPeerUpdated(channel);
channel->inviter = 0;
if (channel->isForbidden || channel->wasKicked() || channel->haveLeft()) {
dialogs.removePeer(channel);
if (History *h = App::historyLoaded(channel->id)) {
@ -4510,17 +4511,12 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
h->asChannelHistory()->clearOther();
}
channel->ptsWaitingForShortPoll(-1);
channel->inviter = 0;
if (activePeer() == channel) {
showDialogs();
}
} else if (!channel->amCreator() && App::history(channel->id)) { // create history
_updatedChannels.insert(channel, true);
if (channel->inviter) {
checkPeerHistory(channel);
} else {
App::api()->requestSelfParticipant(channel);
}
App::api()->requestSelfParticipant(channel);
}
}
} break;

View File

@ -1950,8 +1950,6 @@ void MTProtoConnectionPrivate::socketStart(bool afterConfig) {
}
void MTProtoConnectionPrivate::restart(bool maybeBadKey) {
_needSessionReset = true;
QReadLocker lockFinished(&sessionDataMutex);
if (!sessionData) return;

View File

@ -29,7 +29,7 @@ mtpRequestId MTProtoSession::send(const TRequest &request, RPCResponseHandler ca
reqSerialized->msDate = getms(true); // > 0 - can send without container
reqSerialized->needsLayer = needsLayer;
// if (after) reqSerialized->after = _mtp_internal::getRequest(after);
if (after) reqSerialized->after = _mtp_internal::getRequest(after);
requestId = _mtp_internal::storeRequest(reqSerialized, callbacks);
sendPrepared(reqSerialized, msCanWait);

View File

@ -340,9 +340,9 @@ bool ProfileInner::blockFail(const RPCError &error) {
}
void ProfileInner::onAddParticipant() {
if (!_peerChat) return;
if (!_peerChat && !_peerChannel) return;
App::wnd()->showLayer(new ContactsBox(_peerChat));
App::wnd()->showLayer(_peerChat ? (new ContactsBox(_peerChat)) : (new ContactsBox(_peerChannel)));
}
void ProfileInner::onUpdatePhotoCancel() {
@ -710,7 +710,7 @@ void ProfileInner::paintEvent(QPaintEvent *e) {
}
top += _editLink.height();
}
// about
if (!_about.isEmpty()) {
p.setFont(st::profileHeaderFont->f);
@ -1409,7 +1409,11 @@ void ProfileInner::showAll() {
_createInvitationLink.hide();
_invitationLink.hide();
}
_addParticipant.hide();
if (_amCreator) {
_addParticipant.show();
} else {
_addParticipant.hide();
}
}
_blockUser.hide();
if (_amCreator) {