mirror of https://github.com/procxx/kepka.git
Online updated in the new profile covers. Covert to supergroup handled.
This commit is contained in:
parent
855d44b9d8
commit
3915576673
|
@ -609,9 +609,11 @@ namespace {
|
|||
}
|
||||
}
|
||||
Notify::migrateUpdated(channel);
|
||||
update.flags |= UpdateFlag::MigrationChanged;
|
||||
}
|
||||
if (updatedTo) {
|
||||
Notify::migrateUpdated(cdata);
|
||||
update.flags |= UpdateFlag::MigrationChanged;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -697,7 +699,10 @@ namespace {
|
|||
if (canViewAdmins != cdata->canViewAdmins()) update.flags |= UpdateFlag::ChannelCanViewAdmins;
|
||||
if (canViewMembers != cdata->canViewMembers()) update.flags |= UpdateFlag::ChannelCanViewMembers;
|
||||
if (canAddMembers != cdata->canAddMembers()) update.flags |= UpdateFlag::ChannelCanAddMembers;
|
||||
if (wasEditor != cdata->amEditor()) update.flags |= UpdateFlag::ChannelAmEditor;
|
||||
if (wasEditor != cdata->amEditor()) {
|
||||
cdata->selfAdminUpdated();
|
||||
update.flags |= (UpdateFlag::ChannelAmEditor | UpdateFlag::AdminsChanged);
|
||||
}
|
||||
} break;
|
||||
case mtpc_channelForbidden: {
|
||||
auto &d(chat.c_channelForbidden());
|
||||
|
@ -729,7 +734,10 @@ namespace {
|
|||
if (canViewAdmins != cdata->canViewAdmins()) update.flags |= UpdateFlag::ChannelCanViewAdmins;
|
||||
if (canViewMembers != cdata->canViewMembers()) update.flags |= UpdateFlag::ChannelCanViewMembers;
|
||||
if (canAddMembers != cdata->canAddMembers()) update.flags |= UpdateFlag::ChannelCanAddMembers;
|
||||
if (wasEditor != cdata->amEditor()) update.flags |= UpdateFlag::ChannelAmEditor;
|
||||
if (wasEditor != cdata->amEditor()) {
|
||||
cdata->selfAdminUpdated();
|
||||
update.flags |= (UpdateFlag::ChannelAmEditor | UpdateFlag::AdminsChanged);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
if (!data) continue;
|
||||
|
|
|
@ -40,6 +40,7 @@ struct PeerUpdate {
|
|||
AboutChanged = 0x00000008U,
|
||||
NotificationsEnabled = 0x00000010U,
|
||||
SharedMediaChanged = 0x00000020U,
|
||||
MigrationChanged = 0x00000040U,
|
||||
|
||||
// For chats and channels
|
||||
InviteLinkChanged = 0x00000020U,
|
||||
|
|
|
@ -54,6 +54,7 @@ profileStatusLeft: 27px;
|
|||
profileStatusTop: 35px;
|
||||
profileStatusFont: normalFont;
|
||||
profileStatusFg: windowSubTextFg;
|
||||
profileStatusFgActive: windowActiveTextFg;
|
||||
profileMarginBottom: 30px;
|
||||
|
||||
profileActiveBg: #3fb0e4;
|
||||
|
|
|
@ -61,7 +61,9 @@ CoverWidget::CoverWidget(QWidget *parent, PeerData *peer) : TWidget(parent)
|
|||
_name.setSelectable(true);
|
||||
_name.setContextCopyText(lang(lng_profile_copy_fullname));
|
||||
|
||||
auto observeEvents = ButtonsUpdateFlags | UpdateFlag::NameChanged;
|
||||
auto observeEvents = ButtonsUpdateFlags
|
||||
| UpdateFlag::NameChanged
|
||||
| UpdateFlag::UserOnlineChanged;
|
||||
Notify::registerPeerObserver(observeEvents, this, &CoverWidget::notifyPeerUpdated);
|
||||
FileDialog::registerObserver(this, &CoverWidget::notifyFileQueryUpdated);
|
||||
|
||||
|
@ -178,7 +180,7 @@ void CoverWidget::paintEvent(QPaintEvent *e) {
|
|||
p.fillRect(e->rect(), st::profileBg);
|
||||
|
||||
p.setFont(st::profileStatusFont);
|
||||
p.setPen(st::profileStatusFg);
|
||||
p.setPen(_statusTextIsOnline ? st::profileStatusFgActive : st::profileStatusFg);
|
||||
p.drawTextLeft(_statusPosition.x(), _statusPosition.y(), width(), _statusText);
|
||||
|
||||
paintDivider(p);
|
||||
|
@ -306,6 +308,9 @@ void CoverWidget::notifyPeerUpdated(const Notify::PeerUpdate &update) {
|
|||
if (update.flags & UpdateFlag::NameChanged) {
|
||||
refreshNameText();
|
||||
}
|
||||
if (update.flags & UpdateFlag::UserOnlineChanged) {
|
||||
refreshStatusText();
|
||||
}
|
||||
}
|
||||
|
||||
void CoverWidget::refreshNameText() {
|
||||
|
@ -317,6 +322,7 @@ void CoverWidget::refreshStatusText() {
|
|||
int currentTime = unixtime();
|
||||
if (_peerUser) {
|
||||
_statusText = App::onlineText(_peerUser, currentTime, true);
|
||||
_statusTextIsOnline = App::onlineColorUse(_peerUser, currentTime);
|
||||
} else if (_peerChat && _peerChat->amIn()) {
|
||||
int fullCount = qMax(_peerChat->count, _peerChat->participants.size());
|
||||
if (_onlineCount > 0 && _onlineCount <= fullCount) {
|
||||
|
|
|
@ -117,6 +117,7 @@ private:
|
|||
|
||||
QPoint _statusPosition;
|
||||
QString _statusText;
|
||||
bool _statusTextIsOnline = false;
|
||||
|
||||
struct Button {
|
||||
Ui::RoundButton *widget;
|
||||
|
|
|
@ -81,7 +81,9 @@ FixedBar::FixedBar(QWidget *parent, PeerData *peer) : TWidget(parent)
|
|||
_backButton->moveToLeft(0, 0);
|
||||
connect(_backButton, SIGNAL(clicked()), this, SLOT(onBack()));
|
||||
|
||||
Notify::registerPeerObserver(ButtonsUpdateFlags, this, &FixedBar::notifyPeerUpdate);
|
||||
auto observeEvents = ButtonsUpdateFlags
|
||||
| UpdateFlag::MigrationChanged;
|
||||
Notify::registerPeerObserver(observeEvents, this, &FixedBar::notifyPeerUpdate);
|
||||
|
||||
refreshRightActions();
|
||||
}
|
||||
|
@ -93,6 +95,13 @@ void FixedBar::notifyPeerUpdate(const Notify::PeerUpdate &update) {
|
|||
if ((update.flags & ButtonsUpdateFlags) != 0) {
|
||||
refreshRightActions();
|
||||
}
|
||||
if (update.flags & UpdateFlag::MigrationChanged) {
|
||||
if (_peerChat && _peerChat->migrateTo()) {
|
||||
auto channel = _peerChat->migrateTo();
|
||||
onBack();
|
||||
Ui::showPeerProfile(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FixedBar::refreshRightActions() {
|
||||
|
|
|
@ -45,7 +45,9 @@ MembersWidget::MembersWidget(QWidget *parent, PeerData *peer) : BlockWidget(pare
|
|||
_updateOnlineTimer.setSingleShot(true);
|
||||
connect(&_updateOnlineTimer, SIGNAL(timeout()), this, SLOT(onUpdateOnlineDisplay()));
|
||||
|
||||
auto observeEvents = UpdateFlag::AdminsChanged | UpdateFlag::MembersChanged | UpdateFlag::UserOnlineChanged;
|
||||
auto observeEvents = UpdateFlag::AdminsChanged
|
||||
| UpdateFlag::MembersChanged
|
||||
| UpdateFlag::UserOnlineChanged;
|
||||
Notify::registerPeerObserver(observeEvents, this, &MembersWidget::notifyPeerUpdated);
|
||||
FileDownload::registerImageLoadedObserver(this, &MembersWidget::repaintCallback);
|
||||
|
||||
|
|
|
@ -552,6 +552,16 @@ void ChannelData::flagsUpdated() {
|
|||
}
|
||||
}
|
||||
|
||||
void ChannelData::selfAdminUpdated() {
|
||||
if (isMegagroup()) {
|
||||
if (amEditor()) {
|
||||
mgInfo->lastAdmins.insert(App::self());
|
||||
} else {
|
||||
mgInfo->lastAdmins.remove(App::self());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ChannelData::~ChannelData() {
|
||||
delete mgInfo;
|
||||
}
|
||||
|
|
|
@ -708,6 +708,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
void flagsUpdated();
|
||||
void selfAdminUpdated();
|
||||
bool isMegagroup() const {
|
||||
return flags & MTPDchannel::Flag::f_megagroup;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue