diff --git a/src/components/appMediaPlaybackController.ts b/src/components/appMediaPlaybackController.ts index 6199835a..e767280b 100644 --- a/src/components/appMediaPlaybackController.ts +++ b/src/components/appMediaPlaybackController.ts @@ -703,10 +703,12 @@ class AppMediaPlaybackController { return () => { this.toggleSwitchers(true); - if(this.mediaDetails.get(playingMedia)) { - this.setMedia(playingMedia, this.getMessageByMedia(playingMedia)); - } else { - this.next() || this.previous(); + if(playingMedia) { + if(this.mediaDetails.get(playingMedia)) { + this.setMedia(playingMedia, this.getMessageByMedia(playingMedia)); + } else { + this.next() || this.previous(); + } } if(this.playingMedia === media) { diff --git a/src/components/audio.ts b/src/components/audio.ts index 4aa6b415..5c9b2458 100644 --- a/src/components/audio.ts +++ b/src/components/audio.ts @@ -246,7 +246,7 @@ function wrapAudio(audioEl: AudioElement) { } if(withTime) { - parts.push(formatFullSentTime(doc.date)); + parts.push(formatFullSentTime(message.date)); } else if(!parts.length) { parts.push(formatBytes(doc.size)); } diff --git a/src/components/chat/pinnedContainer.ts b/src/components/chat/pinnedContainer.ts index 7ec70aaf..75fe30ac 100644 --- a/src/components/chat/pinnedContainer.ts +++ b/src/components/chat/pinnedContainer.ts @@ -32,7 +32,7 @@ export default class PinnedContainer { protected floating = false; - protected onClose?: () => void | Promise; + public onClose?: () => void | Promise; constructor(options: { topbar: PinnedContainer['topbar'], @@ -45,7 +45,7 @@ export default class PinnedContainer { }) { safeAssign(this, options); - const {divAndCaption, className, onClose} = this; + const {divAndCaption, className} = this; divAndCaption.container.classList.add(CLASSNAME_BASE, 'hide'); divAndCaption.title.classList.add(CLASSNAME_BASE + '-title'); divAndCaption.subtitle.classList.add(CLASSNAME_BASE + '-subtitle'); @@ -66,10 +66,14 @@ export default class PinnedContainer { divAndCaption.container.append(this.wrapper/* , this.close */); - attachClickEvent(this.btnClose, (e) => { + this.attachOnCloseEvent(this.btnClose); + } + + public attachOnCloseEvent(elem: HTMLElement) { + attachClickEvent(elem, (e) => { cancelEvent(e); - ((onClose ? onClose() : null) || Promise.resolve(true)).then(needClose => { + ((this.onClose ? this.onClose() : null) || Promise.resolve(true)).then(needClose => { if(needClose) { this.toggle(true); } diff --git a/src/components/chat/pinnedMessage.ts b/src/components/chat/pinnedMessage.ts index a50eed27..e8da3ad2 100644 --- a/src/components/chat/pinnedMessage.ts +++ b/src/components/chat/pinnedMessage.ts @@ -288,7 +288,9 @@ export default class ChatPinnedMessage { this.animatedCounter = new AnimatedCounter(true); dAC.title.append(i18n('PinnedMessage'), ' ', this.animatedCounter.container); - dAC.container.prepend(this.pinnedMessageContainer.btnClose); + const btnClose = this.pinnedMessageContainer.btnClose.cloneNode(true) as HTMLElement; + this.pinnedMessageContainer.attachOnCloseEvent(btnClose); + dAC.container.prepend(btnClose); this.btnOpen = ButtonIcon('pinlist pinned-container-close pinned-message-pinlist', {noRipple: true}); diff --git a/src/components/wrappers.ts b/src/components/wrappers.ts index ebf7173d..cf5efc0f 100644 --- a/src/components/wrappers.ts +++ b/src/components/wrappers.ts @@ -611,7 +611,7 @@ export function wrapDocument({message, withTime, fontWeight, voiceAsMusic, showS const descriptionParts: (HTMLElement | string | DocumentFragment)[] = [formatBytes(doc.size)]; if(withTime) { - descriptionParts.push(formatFullSentTime(doc.date)); + descriptionParts.push(formatFullSentTime(message.date)); } if(showSender) { diff --git a/src/scss/partials/_chatPinned.scss b/src/scss/partials/_chatPinned.scss index fd0ba4fe..2b8a3f6f 100644 --- a/src/scss/partials/_chatPinned.scss +++ b/src/scss/partials/_chatPinned.scss @@ -271,6 +271,7 @@ height: 100%; border-radius: 0; z-index: 0; + max-width: 100%; @include respond-to(handhelds) { padding: 0 .5rem; @@ -334,10 +335,6 @@ flex: 0 0 auto; } - &-close { - display: none; - } - &-wrapper { display: flex; flex: 1 1 auto; @@ -421,7 +418,11 @@ margin-right: 2.25rem; } */ - .pinned-message-close { + .pinned-container-wrapper-utils { + display: none; + } + + > .pinned-message-close { display: flex; margin-right: .75rem; order: 0; @@ -582,6 +583,7 @@ &.is-floating { --container-height: var(--pinned-audio-height); + z-index: 1; // fix z-index for volume selector } &:not(.is-floating) {