mirror of https://github.com/procxx/kepka.git
Added ability to update pinned dialogs.
This commit is contained in:
parent
c424607603
commit
62a6812259
|
@ -1414,6 +1414,7 @@ void Session::setChatPinned(const Dialogs::Key &key, bool pinned) {
|
|||
|
||||
const auto list = chatsList(key.entry()->folder())->pinned();
|
||||
list->setPinned(key, pinned);
|
||||
notifyPinnedDialogsOrderUpdated();
|
||||
}
|
||||
|
||||
void Session::setPinnedFromDialog(const Dialogs::Key &key, bool pinned) {
|
||||
|
@ -1430,7 +1431,6 @@ void Session::setPinnedFromDialog(const Dialogs::Key &key, bool pinned) {
|
|||
void Session::applyPinnedChats(
|
||||
Data::Folder *folder,
|
||||
const QVector<MTPDialogPeer> &list) {
|
||||
notifyPinnedDialogsOrderUpdated();
|
||||
for (const auto &peer : list) {
|
||||
peer.match([&](const MTPDdialogPeer &data) {
|
||||
const auto history = this->history(peerFromMTP(data.vpeer));
|
||||
|
@ -1446,6 +1446,7 @@ void Session::applyPinnedChats(
|
|||
});
|
||||
}
|
||||
chatsList(folder)->pinned()->applyList(this, list);
|
||||
notifyPinnedDialogsOrderUpdated();
|
||||
}
|
||||
|
||||
void Session::applyDialogs(
|
||||
|
@ -1490,7 +1491,6 @@ void Session::applyDialog(
|
|||
void Session::applyDialog(
|
||||
Data::Folder *requestFolder,
|
||||
const MTPDdialogFolder &data) {
|
||||
notifyPinnedDialogsOrderUpdated();
|
||||
if (requestFolder) {
|
||||
LOG(("API Error: requestFolder != nullptr for dialogFolder."));
|
||||
}
|
||||
|
@ -1525,6 +1525,7 @@ void Session::reorderTwoPinnedChats(
|
|||
Expects(key1.entry()->folder() == key2.entry()->folder());
|
||||
|
||||
chatsList(key1.entry()->folder())->pinned()->reorder(key1, key2);
|
||||
notifyPinnedDialogsOrderUpdated();
|
||||
}
|
||||
|
||||
bool Session::checkEntitiesAndViewsUpdate(const MTPDmessage &data) {
|
||||
|
|
|
@ -399,12 +399,15 @@ MainWindow::MainWindow()
|
|||
subscribe(Core::App().authSessionChanged(), [this] {
|
||||
if (AuthSession::Exists()) {
|
||||
|
||||
Auth().data().pinnedDialogsOrderUpdated(
|
||||
) | rpl::start_with_next([this] {
|
||||
if (auto view = reinterpret_cast<NSView*>(winId())) {
|
||||
// Create TouchBar.
|
||||
[NSApplication sharedApplication].automaticCustomizeTouchBarMenuItemEnabled = YES;
|
||||
_private->_touchBar = [[TouchBar alloc] init:view];
|
||||
Auth().data().chatsListChanges(
|
||||
) | rpl::start_with_next([this](Data::Folder* folder) {
|
||||
// We need only common pinned dialogs.
|
||||
if (!folder && !_private->_touchBar) {
|
||||
if (auto view = reinterpret_cast<NSView*>(winId())) {
|
||||
// Create TouchBar.
|
||||
[NSApplication sharedApplication].automaticCustomizeTouchBarMenuItemEnabled = YES;
|
||||
_private->_touchBar = [[TouchBar alloc] init:view];
|
||||
}
|
||||
}
|
||||
}, lifetime());
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ NSImage *qt_mac_create_nsimage(const QPixmap &pm);
|
|||
- (NSImage *) getPinImage;
|
||||
- (void)buttonActionPin:(NSButton *)sender;
|
||||
- (void)updatePeerData;
|
||||
- (void)updatePinnedDialog;
|
||||
|
||||
@end // @interface PinnedDialogButton
|
||||
|
||||
|
@ -100,12 +101,19 @@ auto lifetime = rpl::lifetime();
|
|||
button.image = [self getPinImage];
|
||||
};
|
||||
|
||||
Notify::PeerUpdateViewer(
|
||||
self.peer,
|
||||
Notify::PeerUpdate::Flag::PhotoChanged
|
||||
if (self.peer) {
|
||||
Notify::PeerUpdateViewer(
|
||||
self.peer,
|
||||
Notify::PeerUpdate::Flag::PhotoChanged
|
||||
) | rpl::start_with_next([=] {
|
||||
self.waiting = true;
|
||||
updateImage();
|
||||
}, lifetime);
|
||||
}
|
||||
|
||||
Auth().data().pinnedDialogsOrderUpdated(
|
||||
) | rpl::start_with_next([=] {
|
||||
self.waiting = true;
|
||||
updateImage();
|
||||
[self updatePinnedDialog];
|
||||
}, lifetime);
|
||||
|
||||
base::ObservableViewer(
|
||||
|
@ -119,6 +127,13 @@ auto lifetime = rpl::lifetime();
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) updatePinnedDialog {
|
||||
[self updatePeerData];
|
||||
NSButton *button = self.view;
|
||||
button.image = [self getPinImage];
|
||||
[button setHidden:(self.number > Auth().data().pinnedChatsOrder(nullptr).size())];
|
||||
}
|
||||
|
||||
- (id) initSavedMessages {
|
||||
self = [super initWithIdentifier:savedMessages];
|
||||
if (!self) {
|
||||
|
@ -193,7 +208,8 @@ auto lifetime = rpl::lifetime();
|
|||
return static_cast<NSImage*>(qt_mac_create_nsimage(*pix));
|
||||
}
|
||||
if (!self.peer) {
|
||||
return nil;
|
||||
// Random picture.
|
||||
return [NSImage imageNamed:NSImageNameTouchBarAddTemplate];
|
||||
}
|
||||
self.waiting = !self.peer->userpicLoaded();
|
||||
auto pixmap = self.peer->genUserpic(kIdealIconSize);
|
||||
|
|
|
@ -157,7 +157,9 @@ void TogglePinnedDialog(Dialogs::Key key) {
|
|||
history->session().api().request(MTPmessages_ToggleDialogPin(
|
||||
MTP_flags(flags),
|
||||
MTP_inputDialogPeer(key.history()->peer->input)
|
||||
)).send();
|
||||
)).done([=](const MTPBool &result) {
|
||||
Auth().data().notifyPinnedDialogsOrderUpdated();
|
||||
}).send();
|
||||
} else if (const auto folder = key.folder()) {
|
||||
folder->session().api().request(MTPmessages_ToggleDialogPin(
|
||||
MTP_flags(flags),
|
||||
|
|
Loading…
Reference in New Issue