diff --git a/src/components/appMediaViewer.ts b/src/components/appMediaViewer.ts index 9790b37b..f5515925 100644 --- a/src/components/appMediaViewer.ts +++ b/src/components/appMediaViewer.ts @@ -1242,7 +1242,7 @@ export default class AppMediaViewer extends AppMediaViewerBase<'caption', 'delet const peerId = this.peerId; const promise = appMessagesManager.getSearch(peerId, '', - {_: this.inputFilter}, maxId, loadCount/* older ? loadCount : 0 */, 0, backLimit).then(value => { + {_: this.inputFilter}, maxId, backLimit ? 0 : loadCount/* older ? loadCount : 0 */, 0, backLimit).then(value => { if(this.peerId != peerId) { this.log.warn('peer changed'); return; diff --git a/src/components/chat/bubbles.ts b/src/components/chat/bubbles.ts index c0f25d08..60d0b95e 100644 --- a/src/components/chat/bubbles.ts +++ b/src/components/chat/bubbles.ts @@ -402,6 +402,20 @@ export default class ChatBubbles { }); } + public constructPinnedHelpers() { + this.listenerSetter.add(rootScope, 'peer_pinned_messages', (e) => { + const {peerId, mids, pinned} = e.detail; + + if(peerId !== this.peerId) return; + + if(mids) { + if(!pinned) { + this.deleteMessagesByIds(mids); + } + } + }); + } + public onBubblesClick = (e: Event) => { let target = e.target as HTMLElement; let bubble: HTMLElement = null; diff --git a/src/components/chat/chat.ts b/src/components/chat/chat.ts index 3ce946ee..4d534222 100644 --- a/src/components/chat/chat.ts +++ b/src/components/chat/chat.ts @@ -70,6 +70,8 @@ export default class Chat extends EventListenerBase<{ if(this.type == 'chat') { this.topbar.constructPeerHelpers(); + } else if(this.type == 'pinned') { + this.topbar.constructPinnedHelpers(); } this.topbar.construct(); @@ -79,8 +81,10 @@ export default class Chat extends EventListenerBase<{ this.input.constructPeerHelpers(); } else if(this.type == 'pinned') { this.input.constructPinnedHelpers(); + this.bubbles.constructPinnedHelpers(); } + this.container.classList.add('type-' + this.type); this.container.append(this.topbar.container, this.bubbles.bubblesContainer, this.input.chatInput); } diff --git a/src/components/chat/pinnedMessage.ts b/src/components/chat/pinnedMessage.ts index d5cedf3f..59d42166 100644 --- a/src/components/chat/pinnedMessage.ts +++ b/src/components/chat/pinnedMessage.ts @@ -276,7 +276,7 @@ export default class ChatPinnedMessage { }); this.listenerSetter.add(rootScope, 'peer_pinned_messages', (e) => { - const peerId = e.detail; + const peerId = e.detail.peerId; if(peerId == this.topbar.peerId) { //this.wasPinnedIndex = 0; diff --git a/src/components/chat/topbar.ts b/src/components/chat/topbar.ts index 0bd3fbf2..38dd160e 100644 --- a/src/components/chat/topbar.ts +++ b/src/components/chat/topbar.ts @@ -281,6 +281,18 @@ export default class ChatTopbar { return this; } + public constructPinnedHelpers() { + this.listenerSetter.add(rootScope, 'peer_pinned_messages', (e) => { + const {peerId, mids, pinned} = e.detail; + + if(peerId !== this.peerId) return; + + if(mids) { + this.setTitle(); + } + }); + } + public openPinned(byCurrent: boolean) { this.chat.appImManager.setInnerPeer(this.peerId, byCurrent ? +this.pinnedMessage.pinnedMessageContainer.divAndCaption.container.dataset.mid : 0, 'pinned'); } @@ -366,7 +378,19 @@ export default class ChatTopbar { if(count === undefined) { this.appMessagesManager.getSearchCounters(this.peerId, [{_: 'inputMessagesFilterPinned'}]).then(result => { - this.setTitle(result[0].count); + const count = result[0].count; + this.setTitle(count); + + // ! костыль х2, это нужно делать в другом месте + if(!count) { + this.chat.appImManager.setPeer(0); // * close tab + + // ! костыль, это скроет закреплённые сообщения сразу, вместо того, чтобы ждать пока анимация перехода закончится + const originalChat = this.chat.appImManager.chat; + if(originalChat.topbar.pinnedMessage) { + originalChat.topbar.pinnedMessage.pinnedMessageContainer.toggle(true); + } + } }); } } else { diff --git a/src/lib/appManagers/appMessagesManager.ts b/src/lib/appManagers/appMessagesManager.ts index 91b925fc..46049c80 100644 --- a/src/lib/appManagers/appMessagesManager.ts +++ b/src/lib/appManagers/appMessagesManager.ts @@ -1683,7 +1683,7 @@ export class AppMessagesManager { } } - rootScope.broadcast('peer_pinned_messages', peerId); + rootScope.broadcast('peer_pinned_messages', {peerId, unpinAll: true}); delete this.pinnedMessages[peerId]; return true; @@ -3726,7 +3726,7 @@ export class AppMessagesManager { delete this.pinnedMessages[peerId]; appStateManager.getState().then(state => { delete state.hiddenPinnedMessages[peerId]; - rootScope.broadcast('peer_pinned_messages', peerId); + rootScope.broadcast('peer_pinned_messages', {peerId, mids: messages, pinned: werePinned}); }); }); diff --git a/src/lib/rootScope.ts b/src/lib/rootScope.ts index 654a81ea..061f8781 100644 --- a/src/lib/rootScope.ts +++ b/src/lib/rootScope.ts @@ -11,7 +11,7 @@ type BroadcastEvents = { 'user_update': number, 'user_auth': UserAuth, 'peer_changed': number, - 'peer_pinned_messages': number, + 'peer_pinned_messages': {peerId: number, mids?: number[], pinned?: boolean, unpinAll?: true}, 'peer_pinned_hidden': {peerId: number, maxId: number}, 'peer_typings': {peerId: number, typings: UserTyping[]}, diff --git a/src/scss/partials/_chatBubble.scss b/src/scss/partials/_chatBubble.scss index 5c2d76bc..ada9cd37 100644 --- a/src/scss/partials/_chatBubble.scss +++ b/src/scss/partials/_chatBubble.scss @@ -154,13 +154,13 @@ $bubble-margin: .25rem; &.channel-post { .message.poll-message { - .time { - position: unset; - } + .time { + position: unset; + } } poll-element .poll-footer { - height: auto; + height: auto; } } @@ -189,7 +189,7 @@ $bubble-margin: .25rem; } */ } - .bubble__container { + .chat:not(.type-pinned) & .bubble__container { cursor: pointer; pointer-events: all; } @@ -665,17 +665,17 @@ $bubble-margin: .25rem; } &.is-selected { - //border-radius: 0; + border-radius: 0; .album-item-media { transform: scale(1); } &.animating { - //transition: border-radius var(--layer-transition); + transition: border-radius var(--layer-transition); .album-item-media { - transition: transform var(--layer-transition)/* , border-radius var(--layer-transition) */; + transition: transform var(--layer-transition), border-radius var(--layer-transition); } } @@ -684,9 +684,10 @@ $bubble-margin: .25rem; transform: scale(.883333); } - /* &, .album-item-media { - border-radius: .5rem; - } */ + &, .album-item-media { + //border-radius: .5rem; + border-radius: 0; + } } } }