Update archive row on chat list name change.

This commit is contained in:
John Preston 2019-04-23 17:28:44 +04:00
parent 9ff02707bf
commit 3dd2a6bb5b
4 changed files with 43 additions and 12 deletions

View File

@ -17,9 +17,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/application.h"
//#include "storage/storage_feed_messages.h" // #feed
#include "auth_session.h"
#include "observer_peer.h"
#include "apiwrap.h"
#include "mainwidget.h"
#include "styles/style_dialogs.h" // st::dialogsArchiveUserpic
#include "styles/style_dialogs.h"
namespace Data {
namespace {
@ -55,6 +56,18 @@ Folder::Folder(not_null<Data::Session*> owner, FolderId id)
, _chatsList(PinnedDialogsInFolderMaxValue())
, _name(lang(lng_archived_name)) {
indexNameParts();
Notify::PeerUpdateViewer(
Notify::PeerUpdate::Flag::NameChanged
) | rpl::start_with_next([=](const Notify::PeerUpdate &update) {
for (const auto history : _unreadHistoriesLast) {
if (history->peer == update.peer) {
++_chatListViewVersion;
updateChatListEntry();
return;
}
}
}, _lifetime);
}
FolderId Folder::id() const {
@ -227,9 +240,21 @@ void Folder::paintUserpic(
p.setBrush(st::historyPeerArchiveUserpicBg);
{
PainterHighQualityEnabler hq(p);
p.drawRoundedRect(x, y, size, size, size / 3., size / 3.);
p.drawEllipse(x, y, size, size);
}
if (size == st::dialogsPhotoSize) {
st::dialogsArchiveUserpic.paintInCenter(p, { x, y, size, size });
} else {
p.save();
const auto ratio = size / float64(st::dialogsPhotoSize);
p.translate(x + size / 2., y + size / 2.);
p.scale(ratio, ratio);
const auto skip = st::dialogsPhotoSize;
st::dialogsArchiveUserpic.paintInCenter(
p,
{ -skip, -skip, 2 * skip, 2 * skip });
p.restore();
}
st::dialogsArchiveUserpic.paintInCenter(p, { x, y, size, size });
//const auto small = (size - st::lineWidth) / 2; // #feed
//const auto delta = size - small;
//auto index = 0;

View File

@ -108,6 +108,8 @@ private:
uint32 _chatListViewVersion = 0;
//rpl::variable<MessagePosition> _unreadPosition;
rpl::lifetime _lifetime;
};
} // namespace Data

View File

@ -115,7 +115,7 @@ void PeerData::updateNameDelayed(
const QString &newName,
const QString &newNameOrPhone,
const QString &newUsername) {
if (name == newName) {
if (name == newName && nameVersion > 1) {
if (isUser()) {
if (asUser()->nameOrPhone == newNameOrPhone
&& asUser()->username == newUsername) {
@ -129,15 +129,14 @@ void PeerData::updateNameDelayed(
return;
}
}
++nameVersion;
name = newName;
nameText.setText(st::msgNameStyle, name, Ui::NameTextOptions());
refreshEmptyUserpic();
Notify::PeerUpdate update(this);
update.flags |= UpdateFlag::NameChanged;
update.oldNameFirstLetters = nameFirstLetters();
if (nameVersion++ > 1) {
update.flags |= UpdateFlag::NameChanged;
update.oldNameFirstLetters = nameFirstLetters();
}
if (isUser()) {
if (asUser()->username != newUsername) {
asUser()->username = newUsername;
@ -157,7 +156,9 @@ void PeerData::updateNameDelayed(
}
}
fillNames();
Notify::PeerUpdated().notify(update, true);
if (update.flags) {
Notify::PeerUpdated().notify(update, true);
}
}
std::unique_ptr<Ui::EmptyUserpic> PeerData::createEmptyUserpic() const {

View File

@ -2016,7 +2016,7 @@ void DialogsInner::refresh(bool toTop) {
loadPeerPhotos();
}
_controller->dialogsListDisplayForced().set(
_searchInChat || !_filter.isEmpty(),
_openedFolder || _searchInChat || !_filter.isEmpty(),
true);
update();
}
@ -2058,6 +2058,9 @@ void DialogsInner::searchInChat(Dialogs::Key key, UserData *from) {
_searchInChat = key;
_searchFromUser = from;
if (_searchInChat) {
if (_openedFolder) {
changeOpenedFolder(nullptr);
}
onHashtagFilterUpdate(QStringRef());
_cancelSearchInChat->show();
refreshSearchInChatLabel();
@ -2070,7 +2073,7 @@ void DialogsInner::searchInChat(Dialogs::Key key, UserData *from) {
_cancelSearchFromUser->hide();
}
_controller->dialogsListDisplayForced().set(
_searchInChat || !_filter.isEmpty(),
_openedFolder || _searchInChat || !_filter.isEmpty(),
true);
}