Browse Source

Unpin from pinned list

Delete unpinned bubble
Media viewer fix search back limit
Fix album item selection border-radius
master
Eduard Kuzmenko 4 years ago
parent
commit
bf0268c480
  1. 2
      src/components/appMediaViewer.ts
  2. 14
      src/components/chat/bubbles.ts
  3. 4
      src/components/chat/chat.ts
  4. 2
      src/components/chat/pinnedMessage.ts
  5. 26
      src/components/chat/topbar.ts
  6. 4
      src/lib/appManagers/appMessagesManager.ts
  7. 2
      src/lib/rootScope.ts
  8. 15
      src/scss/partials/_chatBubble.scss

2
src/components/appMediaViewer.ts

@ -1242,7 +1242,7 @@ export default class AppMediaViewer extends AppMediaViewerBase<'caption', 'delet
const peerId = this.peerId; const peerId = this.peerId;
const promise = appMessagesManager.getSearch(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) { if(this.peerId != peerId) {
this.log.warn('peer changed'); this.log.warn('peer changed');
return; return;

14
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) => { public onBubblesClick = (e: Event) => {
let target = e.target as HTMLElement; let target = e.target as HTMLElement;
let bubble: HTMLElement = null; let bubble: HTMLElement = null;

4
src/components/chat/chat.ts

@ -70,6 +70,8 @@ export default class Chat extends EventListenerBase<{
if(this.type == 'chat') { if(this.type == 'chat') {
this.topbar.constructPeerHelpers(); this.topbar.constructPeerHelpers();
} else if(this.type == 'pinned') {
this.topbar.constructPinnedHelpers();
} }
this.topbar.construct(); this.topbar.construct();
@ -79,8 +81,10 @@ export default class Chat extends EventListenerBase<{
this.input.constructPeerHelpers(); this.input.constructPeerHelpers();
} else if(this.type == 'pinned') { } else if(this.type == 'pinned') {
this.input.constructPinnedHelpers(); 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); this.container.append(this.topbar.container, this.bubbles.bubblesContainer, this.input.chatInput);
} }

2
src/components/chat/pinnedMessage.ts

@ -276,7 +276,7 @@ export default class ChatPinnedMessage {
}); });
this.listenerSetter.add(rootScope, 'peer_pinned_messages', (e) => { this.listenerSetter.add(rootScope, 'peer_pinned_messages', (e) => {
const peerId = e.detail; const peerId = e.detail.peerId;
if(peerId == this.topbar.peerId) { if(peerId == this.topbar.peerId) {
//this.wasPinnedIndex = 0; //this.wasPinnedIndex = 0;

26
src/components/chat/topbar.ts

@ -281,6 +281,18 @@ export default class ChatTopbar {
return this; 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) { public openPinned(byCurrent: boolean) {
this.chat.appImManager.setInnerPeer(this.peerId, byCurrent ? +this.pinnedMessage.pinnedMessageContainer.divAndCaption.container.dataset.mid : 0, 'pinned'); 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) { if(count === undefined) {
this.appMessagesManager.getSearchCounters(this.peerId, [{_: 'inputMessagesFilterPinned'}]).then(result => { 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 { } else {

4
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]; delete this.pinnedMessages[peerId];
return true; return true;
@ -3726,7 +3726,7 @@ export class AppMessagesManager {
delete this.pinnedMessages[peerId]; delete this.pinnedMessages[peerId];
appStateManager.getState().then(state => { appStateManager.getState().then(state => {
delete state.hiddenPinnedMessages[peerId]; delete state.hiddenPinnedMessages[peerId];
rootScope.broadcast('peer_pinned_messages', peerId); rootScope.broadcast('peer_pinned_messages', {peerId, mids: messages, pinned: werePinned});
}); });
}); });

2
src/lib/rootScope.ts

@ -11,7 +11,7 @@ type BroadcastEvents = {
'user_update': number, 'user_update': number,
'user_auth': UserAuth, 'user_auth': UserAuth,
'peer_changed': number, '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_pinned_hidden': {peerId: number, maxId: number},
'peer_typings': {peerId: number, typings: UserTyping[]}, 'peer_typings': {peerId: number, typings: UserTyping[]},

15
src/scss/partials/_chatBubble.scss

@ -189,7 +189,7 @@ $bubble-margin: .25rem;
} */ } */
} }
.bubble__container { .chat:not(.type-pinned) & .bubble__container {
cursor: pointer; cursor: pointer;
pointer-events: all; pointer-events: all;
} }
@ -665,17 +665,17 @@ $bubble-margin: .25rem;
} }
&.is-selected { &.is-selected {
//border-radius: 0; border-radius: 0;
.album-item-media { .album-item-media {
transform: scale(1); transform: scale(1);
} }
&.animating { &.animating {
//transition: border-radius var(--layer-transition); transition: border-radius var(--layer-transition);
.album-item-media { .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); transform: scale(.883333);
} }
/* &, .album-item-media { &, .album-item-media {
border-radius: .5rem; //border-radius: .5rem;
} */ border-radius: 0;
}
} }
} }
} }

Loading…
Cancel
Save