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