Fixed position of Saved Messages in touchbar when user unpins it.

This commit is contained in:
23rd 2019-05-11 14:40:17 +03:00 committed by John Preston
parent b4df7b4efd
commit de3cc76468
1 changed files with 6 additions and 1 deletions

View File

@ -438,6 +438,7 @@ NSString* FormatTime(int time) {
- (void) updatePinnedButtons {
const auto &order = Auth().data().pinnedChatsOrder(nullptr);
auto isSelfPeerPinned = false;
auto isArchivePinned = false;
PinnedDialogButton *selfChatButton;
NSCustomTouchBarItem *item = [self.touchBarMain itemForIdentifier:kPinnedPanelItemIdentifier];
NSStackView *stack = item.view;
@ -447,6 +448,8 @@ NSString* FormatTime(int time) {
if (num <= kSavedMessagesId) {
if (num == kSavedMessagesId) {
selfChatButton = button;
} else if (num == kArchiveId) {
isArchivePinned = !button.isDeletedFromView;
}
continue;
}
@ -472,7 +475,9 @@ NSString* FormatTime(int time) {
[stack removeView:selfChatButton.view];
} else if (!isSelfPeerPinned && selfChatButton.isDeletedFromView) {
selfChatButton.isDeletedFromView = false;
[stack insertView:selfChatButton.view atIndex:0 inGravity:NSStackViewGravityLeading];
[stack insertView:selfChatButton.view
atIndex:(isArchivePinned ? 1 : 0)
inGravity:NSStackViewGravityLeading];
}
}