mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Removed all Auth() calls from touchbar.
This commit is contained in:
parent
03dec15e8e
commit
739a3ebe97
4 changed files with 76 additions and 48 deletions
|
@ -24,7 +24,8 @@ enum class TouchBarType {
|
||||||
|
|
||||||
@property(retain) NSDictionary * _Nullable touchBarItems;
|
@property(retain) NSDictionary * _Nullable touchBarItems;
|
||||||
|
|
||||||
- (id _Nonnull) init:(NSView * _Nonnull)view;
|
- (id _Nonnull) init:(NSView * _Nonnull)view
|
||||||
|
session:(not_null<Main::Session*>)session;
|
||||||
- (void) handleTrackStateChange:(Media::Player::TrackState)state;
|
- (void) handleTrackStateChange:(Media::Player::TrackState)state;
|
||||||
- (void) setTouchBar:(Platform::TouchBarType)type;
|
- (void) setTouchBar:(Platform::TouchBarType)type;
|
||||||
- (void) showInputFieldItem:(bool)show;
|
- (void) showInputFieldItem:(bool)show;
|
||||||
|
|
|
@ -219,8 +219,7 @@ inline std::optional<QString> RestrictionToSendStickers() {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TitleRecentlyUsed() {
|
QString TitleRecentlyUsed(const Data::StickersSets &sets) {
|
||||||
const auto &sets = Auth().data().stickers().sets();
|
|
||||||
const auto it = sets.find(Data::Stickers::CloudRecentSetId);
|
const auto it = sets.find(Data::Stickers::CloudRecentSetId);
|
||||||
if (it != sets.cend()) {
|
if (it != sets.cend()) {
|
||||||
return it->second->title;
|
return it->second->title;
|
||||||
|
@ -328,8 +327,10 @@ void SendKeyEvent(int command) {
|
||||||
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyRelease, key, modifier));
|
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyRelease, key, modifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppendStickerSet(std::vector<PickerScrubberItem> &to, uint64 setId) {
|
void AppendStickerSet(
|
||||||
const auto &sets = Auth().data().stickerSets();
|
const Data::StickersSets &sets,
|
||||||
|
std::vector<PickerScrubberItem> &to,
|
||||||
|
uint64 setId) {
|
||||||
const auto it = sets.find(setId);
|
const auto it = sets.find(setId);
|
||||||
if (it == sets.cend() || it->second->stickers.isEmpty()) {
|
if (it == sets.cend() || it->second->stickers.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -350,8 +351,10 @@ void AppendStickerSet(std::vector<PickerScrubberItem> &to, uint64 setId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppendRecentStickers(std::vector<PickerScrubberItem> &to) {
|
void AppendRecentStickers(
|
||||||
const auto &sets = Auth().data().stickers().sets();
|
const Data::StickersSets &sets,
|
||||||
|
RecentStickerPack &recentPack,
|
||||||
|
std::vector<PickerScrubberItem> &to) {
|
||||||
const auto cloudIt = sets.find(Data::Stickers::CloudRecentSetId);
|
const auto cloudIt = sets.find(Data::Stickers::CloudRecentSetId);
|
||||||
const auto cloudCount = (cloudIt != sets.cend())
|
const auto cloudCount = (cloudIt != sets.cend())
|
||||||
? cloudIt->second->stickers.size()
|
? cloudIt->second->stickers.size()
|
||||||
|
@ -366,13 +369,14 @@ void AppendRecentStickers(std::vector<PickerScrubberItem> &to) {
|
||||||
to.emplace_back(PickerScrubberItem(document));
|
to.emplace_back(PickerScrubberItem(document));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const auto recent : Auth().data().stickers().getRecentPack()) {
|
for (const auto recent : recentPack) {
|
||||||
to.emplace_back(PickerScrubberItem(recent.first));
|
to.emplace_back(PickerScrubberItem(recent.first));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppendFavedStickers(std::vector<PickerScrubberItem> &to) {
|
void AppendFavedStickers(
|
||||||
const auto &sets = Auth().data().stickers().sets();
|
const Data::StickersSets &sets,
|
||||||
|
std::vector<PickerScrubberItem> &to) {
|
||||||
const auto it = sets.find(Data::Stickers::FavedSetId);
|
const auto it = sets.find(Data::Stickers::FavedSetId);
|
||||||
const auto count = (it != sets.cend())
|
const auto count = (it != sets.cend())
|
||||||
? it->second->stickers.size()
|
? it->second->stickers.size()
|
||||||
|
@ -387,14 +391,16 @@ void AppendFavedStickers(std::vector<PickerScrubberItem> &to) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
void AppendEmojiPacks(
|
||||||
|
const Data::StickersSets &sets,
|
||||||
|
std::vector<PickerScrubberItem> &to) {
|
||||||
for (auto i = 0; i != ChatHelpers::kEmojiSectionCount; ++i) {
|
for (auto i = 0; i != ChatHelpers::kEmojiSectionCount; ++i) {
|
||||||
const auto section = static_cast<Ui::Emoji::Section>(i);
|
const auto section = static_cast<Ui::Emoji::Section>(i);
|
||||||
const auto list = (section == Ui::Emoji::Section::Recent)
|
const auto list = (section == Ui::Emoji::Section::Recent)
|
||||||
? GetRecentEmojiSection()
|
? GetRecentEmojiSection()
|
||||||
: Ui::Emoji::GetSection(section);
|
: Ui::Emoji::GetSection(section);
|
||||||
const auto title = (section == Ui::Emoji::Section::Recent)
|
const auto title = (section == Ui::Emoji::Section::Recent)
|
||||||
? TitleRecentlyUsed()
|
? TitleRecentlyUsed(sets)
|
||||||
: ChatHelpers::EmojiCategoryTitle(i)(tr::now);
|
: ChatHelpers::EmojiCategoryTitle(i)(tr::now);
|
||||||
to.emplace_back(title);
|
to.emplace_back(title);
|
||||||
for (const auto &emoji : list) {
|
for (const auto &emoji : list) {
|
||||||
|
@ -412,6 +418,7 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
int _startPosition;
|
int _startPosition;
|
||||||
int _tempIndex;
|
int _tempIndex;
|
||||||
bool _orderChanged;
|
bool _orderChanged;
|
||||||
|
Main::Session *_session;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesBeganWithEvent:(NSEvent *)event {
|
- (void)touchesBeganWithEvent:(NSEvent *)event {
|
||||||
|
@ -425,7 +432,7 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesMovedWithEvent:(NSEvent *)event {
|
- (void)touchesMovedWithEvent:(NSEvent *)event {
|
||||||
if (self.tag <= kSavedMessagesId) {
|
if (!_session || self.tag <= kSavedMessagesId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ([event.allTouches allObjects].count > 1) {
|
if ([event.allTouches allObjects].count > 1) {
|
||||||
|
@ -436,7 +443,7 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
if (std::abs(_startPosition - currentPosition) > step) {
|
if (std::abs(_startPosition - currentPosition) > step) {
|
||||||
const auto delta = (currentPosition > _startPosition) ? 1 : -1;
|
const auto delta = (currentPosition > _startPosition) ? 1 : -1;
|
||||||
const auto newIndex = _tempIndex + delta;
|
const auto newIndex = _tempIndex + delta;
|
||||||
const auto &order = Auth().data().pinnedChatsOrder(nullptr, FilterId());
|
const auto &order = _session->data().pinnedChatsOrder(nullptr, FilterId());
|
||||||
|
|
||||||
// In case the order has been changed from another device
|
// In case the order has been changed from another device
|
||||||
// while the user is dragging the dialog.
|
// while the user is dragging the dialog.
|
||||||
|
@ -445,7 +452,7 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newIndex >= 0 && newIndex < order.size()) {
|
if (newIndex >= 0 && newIndex < order.size()) {
|
||||||
Auth().data().reorderTwoPinnedChats(
|
_session->data().reorderTwoPinnedChats(
|
||||||
FilterId(),
|
FilterId(),
|
||||||
order.at(_tempIndex).history(),
|
order.at(_tempIndex).history(),
|
||||||
order.at(newIndex).history());
|
order.at(newIndex).history());
|
||||||
|
@ -456,9 +463,13 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setSession:(not_null<Main::Session*>)session {
|
||||||
|
_session = session;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)touchesEndedWithEvent:(NSEvent *)event {
|
- (void)touchesEndedWithEvent:(NSEvent *)event {
|
||||||
if (_orderChanged) {
|
if (_orderChanged && _session) {
|
||||||
Auth().api().savePinnedOrder(nullptr);
|
_session->api().savePinnedOrder(nullptr);
|
||||||
}
|
}
|
||||||
[super touchesEndedWithEvent:event];
|
[super touchesEndedWithEvent:event];
|
||||||
}
|
}
|
||||||
|
@ -475,7 +486,7 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
@property(nonatomic, assign) bool isDeletedFromView;
|
@property(nonatomic, assign) bool isDeletedFromView;
|
||||||
@property(nonatomic, assign) QPixmap userpic;
|
@property(nonatomic, assign) QPixmap userpic;
|
||||||
|
|
||||||
- (id) init:(int)num;
|
- (id) init:(int)num session:(not_null<Main::Session*>)session;
|
||||||
- (void)buttonActionPin:(NSButton *)sender;
|
- (void)buttonActionPin:(NSButton *)sender;
|
||||||
- (void)updateUserpic;
|
- (void)updateUserpic;
|
||||||
|
|
||||||
|
@ -486,11 +497,13 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
rpl::lifetime _peerChangedLifetime;
|
rpl::lifetime _peerChangedLifetime;
|
||||||
base::has_weak_ptr _guard;
|
base::has_weak_ptr _guard;
|
||||||
std::shared_ptr<Data::CloudImageView> _userpicView;
|
std::shared_ptr<Data::CloudImageView> _userpicView;
|
||||||
|
Main::Session* _session;
|
||||||
|
|
||||||
bool isWaitingUserpicLoad;
|
bool isWaitingUserpicLoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) init:(int)num {
|
- (id) init:(int)num session:(not_null<Main::Session*>)session {
|
||||||
|
_session = session;
|
||||||
if (num == kSavedMessagesId) {
|
if (num == kSavedMessagesId) {
|
||||||
self = [super initWithIdentifier:kSavedMessagesItemIdentifier];
|
self = [super initWithIdentifier:kSavedMessagesItemIdentifier];
|
||||||
isWaitingUserpicLoad = false;
|
isWaitingUserpicLoad = false;
|
||||||
|
@ -511,6 +524,7 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
self.number = num;
|
self.number = num;
|
||||||
|
|
||||||
PinButton *button = [[PinButton alloc] initWithFrame:NSZeroRect];
|
PinButton *button = [[PinButton alloc] initWithFrame:NSZeroRect];
|
||||||
|
[button setSession:_session];
|
||||||
NSButtonCell *cell = [[NSButtonCell alloc] init];
|
NSButtonCell *cell = [[NSButtonCell alloc] init];
|
||||||
[cell setBezelStyle:NSBezelStyleCircular];
|
[cell setBezelStyle:NSBezelStyleCircular];
|
||||||
button.cell = cell;
|
button.cell = cell;
|
||||||
|
@ -540,7 +554,7 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
}
|
}
|
||||||
|
|
||||||
base::ObservableViewer(
|
base::ObservableViewer(
|
||||||
Auth().downloaderTaskFinished()
|
_session->downloaderTaskFinished()
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
if (isWaitingUserpicLoad) {
|
if (isWaitingUserpicLoad) {
|
||||||
[self updateUserpic];
|
[self updateUserpic];
|
||||||
|
@ -592,7 +606,7 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
if (!App::wnd()) {
|
if (!App::wnd()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (const auto folder = Auth().data().folderLoaded(Data::Folder::kId)) {
|
if (const auto folder = _session->data().folderLoaded(Data::Folder::kId)) {
|
||||||
App::wnd()->sessionController()->openFolder(folder);
|
App::wnd()->sessionController()->openFolder(folder);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -600,7 +614,7 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
self.number == kArchiveId
|
self.number == kArchiveId
|
||||||
? openFolder()
|
? openFolder()
|
||||||
: App::main()->choosePeer(self.number == kSavedMessagesId
|
: App::main()->choosePeer(self.number == kSavedMessagesId
|
||||||
? Auth().userPeerId()
|
? _session->userPeerId()
|
||||||
: self.peer->id, ShowAtUnreadMsgId);
|
: self.peer->id, ShowAtUnreadMsgId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -616,7 +630,7 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
if (self.number != kArchiveId) {
|
if (self.number != kArchiveId) {
|
||||||
Ui::EmptyUserpic::PaintSavedMessages(paint, 0, 0, s, s);
|
Ui::EmptyUserpic::PaintSavedMessages(paint, 0, 0, s, s);
|
||||||
} else if (const auto folder =
|
} else if (const auto folder =
|
||||||
Auth().data().folderLoaded(Data::Folder::kId)) {
|
_session->data().folderLoaded(Data::Folder::kId)) {
|
||||||
// Not used in the folders.
|
// Not used in the folders.
|
||||||
auto view = std::shared_ptr<Data::CloudImageView>();
|
auto view = std::shared_ptr<Data::CloudImageView>();
|
||||||
folder->paintUserpic(paint, view, 0, 0, s);
|
folder->paintUserpic(paint, view, 0, 0, s);
|
||||||
|
@ -683,7 +697,8 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)addDocument:(not_null<DocumentData*>)document {
|
- (void)addDocument:(not_null<DocumentData*>)document
|
||||||
|
loadProducer:(rpl::producer<>)loadProducer {
|
||||||
if (!document->sticker()) {
|
if (!document->sticker()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -696,8 +711,8 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
[self updateImage];
|
[self updateImage];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
base::ObservableViewer(
|
std::move(
|
||||||
Auth().downloaderTaskFinished()
|
loadProducer
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
_image = _media->getStickerSmall();
|
_image = _media->getStickerSmall();
|
||||||
if (_image) {
|
if (_image) {
|
||||||
|
@ -733,15 +748,19 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
std::vector<PickerScrubberItem> _stickers;
|
std::vector<PickerScrubberItem> _stickers;
|
||||||
NSPopoverTouchBarItem *_parentPopover;
|
NSPopoverTouchBarItem *_parentPopover;
|
||||||
DocumentId _lastPreviewedSticker;
|
DocumentId _lastPreviewedSticker;
|
||||||
|
Main::Session* _session;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) init:(ScrubberItemType)type popover:(NSPopoverTouchBarItem *)popover {
|
- (id) init:(ScrubberItemType)type
|
||||||
|
popover:(NSPopoverTouchBarItem *)popover
|
||||||
|
session:(not_null<Main::Session*>)session {
|
||||||
self = [super initWithIdentifier:IsSticker(type)
|
self = [super initWithIdentifier:IsSticker(type)
|
||||||
? kScrubberStickersItemIdentifier
|
? kScrubberStickersItemIdentifier
|
||||||
: kScrubberEmojiItemIdentifier];
|
: kScrubberEmojiItemIdentifier];
|
||||||
if (!self) {
|
if (!self) {
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
_session = session;
|
||||||
_parentPopover = popover;
|
_parentPopover = popover;
|
||||||
IsSticker(type) ? [self updateStickers] : [self updateEmoji];
|
IsSticker(type) ? [self updateStickers] : [self updateEmoji];
|
||||||
NSScrubber *scrubber = [[[NSScrubber alloc] initWithFrame:NSZeroRect] autorelease];
|
NSScrubber *scrubber = [[[NSScrubber alloc] initWithFrame:NSZeroRect] autorelease];
|
||||||
|
@ -831,7 +850,10 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
const auto item = _stickers[index];
|
const auto item = _stickers[index];
|
||||||
if (const auto document = item.document) {
|
if (const auto document = item.document) {
|
||||||
PickerScrubberItemView *itemView = [scrubber makeItemWithIdentifier:kStickerItemIdentifier owner:nil];
|
PickerScrubberItemView *itemView = [scrubber makeItemWithIdentifier:kStickerItemIdentifier owner:nil];
|
||||||
[itemView addDocument:(std::move(document))];
|
auto loadProducer = base::ObservableViewer(
|
||||||
|
_session->downloaderTaskFinished());
|
||||||
|
[itemView addDocument:(std::move(document))
|
||||||
|
loadProducer:(std::move(loadProducer))];
|
||||||
return itemView;
|
return itemView;
|
||||||
} else if (const auto emoji = item.emoji) {
|
} else if (const auto emoji = item.emoji) {
|
||||||
NSScrubberImageItemView *itemView = [scrubber makeItemWithIdentifier:kEmojiItemIdentifier owner:nil];
|
NSScrubberImageItemView *itemView = [scrubber makeItemWithIdentifier:kEmojiItemIdentifier owner:nil];
|
||||||
|
@ -889,6 +911,7 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateStickers {
|
- (void)updateStickers {
|
||||||
|
auto &stickers = _session->data().stickers();
|
||||||
std::vector<PickerScrubberItem> temp;
|
std::vector<PickerScrubberItem> temp;
|
||||||
if (const auto error = RestrictionToSendStickers()) {
|
if (const auto error = RestrictionToSendStickers()) {
|
||||||
temp.emplace_back(PickerScrubberItem(
|
temp.emplace_back(PickerScrubberItem(
|
||||||
|
@ -896,11 +919,11 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
_stickers = std::move(temp);
|
_stickers = std::move(temp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AppendFavedStickers(temp);
|
AppendFavedStickers(stickers.sets(), temp);
|
||||||
AppendRecentStickers(temp);
|
AppendRecentStickers(stickers.sets(), stickers.getRecentPack(), temp);
|
||||||
auto count = 0;
|
auto count = 0;
|
||||||
for (const auto setId : Auth().data().stickerSetsOrder()) {
|
for (const auto setId : stickers.setsOrderRef()) {
|
||||||
AppendStickerSet(temp, setId);
|
AppendStickerSet(stickers.sets(), temp, setId);
|
||||||
if (++count == kMaxStickerSets) {
|
if (++count == kMaxStickerSets) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -914,7 +937,7 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
|
|
||||||
- (void)updateEmoji {
|
- (void)updateEmoji {
|
||||||
std::vector<PickerScrubberItem> temp;
|
std::vector<PickerScrubberItem> temp;
|
||||||
AppendEmojiPacks(temp);
|
AppendEmojiPacks(_session->data().stickers().sets(), temp);
|
||||||
_stickers = std::move(temp);
|
_stickers = std::move(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -936,6 +959,8 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
Platform::TouchBarType _touchBarType;
|
Platform::TouchBarType _touchBarType;
|
||||||
Platform::TouchBarType _touchBarTypeBeforeLock;
|
Platform::TouchBarType _touchBarTypeBeforeLock;
|
||||||
|
|
||||||
|
Main::Session* _session;
|
||||||
|
|
||||||
double _duration;
|
double _duration;
|
||||||
double _position;
|
double _position;
|
||||||
|
|
||||||
|
@ -943,11 +968,12 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
rpl::lifetime _lifetimeSessionControllerChecker;
|
rpl::lifetime _lifetimeSessionControllerChecker;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) init:(NSView *)view {
|
- (id) init:(NSView *)view session:(not_null<Main::Session*>)session {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (!self) {
|
if (!self) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
_session = session;
|
||||||
|
|
||||||
const auto iconSize = kIdealIconSize / 3;
|
const auto iconSize = kIdealIconSize / 3;
|
||||||
_position = 0;
|
_position = 0;
|
||||||
|
@ -1038,12 +1064,12 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
}
|
}
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
|
|
||||||
Auth().data().pinnedDialogsOrderUpdated(
|
_session->data().pinnedDialogsOrderUpdated(
|
||||||
) | rpl::start_with_next([self] {
|
) | rpl::start_with_next([self] {
|
||||||
[self updatePinnedButtons];
|
[self updatePinnedButtons];
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
|
|
||||||
Auth().data().chatsListChanges(
|
_session->data().chatsListChanges(
|
||||||
) | rpl::filter([](Data::Folder *folder) {
|
) | rpl::filter([](Data::Folder *folder) {
|
||||||
return folder
|
return folder
|
||||||
&& folder->chatsList()
|
&& folder->chatsList()
|
||||||
|
@ -1057,12 +1083,12 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
// not yet exist. But at the time of chatsListChanges event
|
// not yet exist. But at the time of chatsListChanges event
|
||||||
// the sessionController is valid and we can work with it.
|
// the sessionController is valid and we can work with it.
|
||||||
// So _lifetimeSessionControllerChecker is needed only once.
|
// So _lifetimeSessionControllerChecker is needed only once.
|
||||||
Auth().data().chatsListChanges(
|
_session->data().chatsListChanges(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
if (const auto window = App::wnd()) {
|
if (const auto window = App::wnd()) {
|
||||||
if (const auto controller = window->sessionController()) {
|
if (const auto controller = window->sessionController()) {
|
||||||
if (Auth().data().stickerSets().empty()) {
|
if (_session->data().stickers().setsRef().empty()) {
|
||||||
Auth().api().updateStickers();
|
_session->api().updateStickers();
|
||||||
}
|
}
|
||||||
_lifetimeSessionControllerChecker.destroy();
|
_lifetimeSessionControllerChecker.destroy();
|
||||||
controller->activeChatChanges(
|
controller->activeChatChanges(
|
||||||
|
@ -1077,8 +1103,8 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
}, _lifetimeSessionControllerChecker);
|
}, _lifetimeSessionControllerChecker);
|
||||||
|
|
||||||
rpl::merge(
|
rpl::merge(
|
||||||
Auth().data().stickersUpdated(),
|
_session->data().stickers().updated(),
|
||||||
Auth().data().recentStickersUpdated()
|
_session->data().stickers().recentUpdated()
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
[self updatePickerPopover:ScrubberItemType::Sticker];
|
[self updatePickerPopover:ScrubberItemType::Sticker];
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
|
@ -1178,7 +1204,7 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
? _popoverPicker
|
? _popoverPicker
|
||||||
: nil;
|
: nil;
|
||||||
PickerCustomTouchBarItem *item = [[PickerCustomTouchBarItem alloc]
|
PickerCustomTouchBarItem *item = [[PickerCustomTouchBarItem alloc]
|
||||||
init:type popover:popover];
|
init:type popover:popover session:_session];
|
||||||
return item;
|
return item;
|
||||||
} else if (isType(kTypePicker)) {
|
} else if (isType(kTypePicker)) {
|
||||||
NSPopoverTouchBarItem *item = [[NSPopoverTouchBarItem alloc] initWithIdentifier:identifier];
|
NSPopoverTouchBarItem *item = [[NSPopoverTouchBarItem alloc] initWithIdentifier:identifier];
|
||||||
|
@ -1206,7 +1232,9 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
|
|
||||||
for (auto i = kArchiveId; i <= Global::PinnedDialogsCountMax(); i++) {
|
for (auto i = kArchiveId; i <= Global::PinnedDialogsCountMax(); i++) {
|
||||||
PinnedDialogButton *button =
|
PinnedDialogButton *button =
|
||||||
[[[PinnedDialogButton alloc] init:i] autorelease];
|
[[[PinnedDialogButton alloc]
|
||||||
|
init:i
|
||||||
|
session:_session] autorelease];
|
||||||
[_mainPinnedButtons addObject:button];
|
[_mainPinnedButtons addObject:button];
|
||||||
if (i == kArchiveId) {
|
if (i == kArchiveId) {
|
||||||
button.isDeletedFromView = true;
|
button.isDeletedFromView = true;
|
||||||
|
@ -1298,7 +1326,7 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
const auto popover = IsSticker(type)
|
const auto popover = IsSticker(type)
|
||||||
? _popoverPicker
|
? _popoverPicker
|
||||||
: nil;
|
: nil;
|
||||||
[[PickerCustomTouchBarItem alloc] init:type popover:popover];
|
[[PickerCustomTouchBarItem alloc] init:type popover:popover session:_session];
|
||||||
const auto identifier = IsSticker(type)
|
const auto identifier = IsSticker(type)
|
||||||
? kScrubberStickersItemIdentifier
|
? kScrubberStickersItemIdentifier
|
||||||
: kScrubberEmojiItemIdentifier;
|
: kScrubberEmojiItemIdentifier;
|
||||||
|
@ -1329,7 +1357,7 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) updatePinnedButtons {
|
- (void) updatePinnedButtons {
|
||||||
const auto &order = Auth().data().pinnedChatsOrder(nullptr, FilterId());
|
const auto &order = _session->data().pinnedChatsOrder(nullptr, FilterId());
|
||||||
auto isSelfPeerPinned = false;
|
auto isSelfPeerPinned = false;
|
||||||
auto isArchivePinned = false;
|
auto isArchivePinned = false;
|
||||||
PinnedDialogButton *selfChatButton;
|
PinnedDialogButton *selfChatButton;
|
||||||
|
@ -1356,7 +1384,7 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
if (const auto history = pinned.history()) {
|
if (const auto history = pinned.history()) {
|
||||||
button.peer = history->peer;
|
button.peer = history->peer;
|
||||||
[button updateUserpic];
|
[button updateUserpic];
|
||||||
if (history->peer->id == Auth().userPeerId()) {
|
if (history->peer->id == _session->userPeerId()) {
|
||||||
isSelfPeerPinned = true;
|
isSelfPeerPinned = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -485,7 +485,7 @@ void MainWindow::initTouchBar() {
|
||||||
if (auto view = reinterpret_cast<NSView*>(winId())) {
|
if (auto view = reinterpret_cast<NSView*>(winId())) {
|
||||||
// Create TouchBar.
|
// Create TouchBar.
|
||||||
[NSApplication sharedApplication].automaticCustomizeTouchBarMenuItemEnabled = YES;
|
[NSApplication sharedApplication].automaticCustomizeTouchBarMenuItemEnabled = YES;
|
||||||
_private->_touchBar = [[TouchBar alloc] init:view];
|
_private->_touchBar = [[TouchBar alloc] init:view session:session];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -15,7 +15,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "media/audio/media_audio.h"
|
#include "media/audio/media_audio.h"
|
||||||
#include "media/player/media_player_instance.h"
|
#include "media/player/media_player_instance.h"
|
||||||
#include "platform/mac/mac_touchbar.h"
|
|
||||||
#include "base/platform/mac/base_utilities_mac.h"
|
#include "base/platform/mac/base_utilities_mac.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
|
Loading…
Add table
Reference in a new issue