From df3e4bfb823baa0e39133ef04cad4bc7de922aff Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Fri, 16 Dec 2022 17:18:17 +0800 Subject: [PATCH] fix(music player): cannot preview audio in single file shares (https://github.com/cloudreve/Cloudreve/issues/1541) --- src/component/FileManager/MusicPlayer.js | 3 +++ src/component/Share/SharedFile.js | 17 ++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/component/FileManager/MusicPlayer.js b/src/component/FileManager/MusicPlayer.js index 60fc3b5..1e46afc 100644 --- a/src/component/FileManager/MusicPlayer.js +++ b/src/component/FileManager/MusicPlayer.js @@ -103,6 +103,9 @@ class MusicPlayerComponent extends Component { //isOpen: true, }); this.props.audioPreviewSetIsOpen(true); + this.props.showAudioPreview( + explorer.initState.audioPreview.first + ); return; } // eslint-disable-next-line diff --git a/src/component/Share/SharedFile.js b/src/component/Share/SharedFile.js index 901a744..d0e677c 100644 --- a/src/component/Share/SharedFile.js +++ b/src/component/Share/SharedFile.js @@ -13,6 +13,7 @@ import { openMusicDialog, openResaveDialog, setSelectedTarget, + showAudioPreview, showImgPreivew, toggleSnackbar, } from "../../redux/explorer"; @@ -105,8 +106,8 @@ const mapDispatchToProps = (dispatch) => { toggleSnackbar: (vertical, horizontal, msg, color) => { dispatch(toggleSnackbar(vertical, horizontal, msg, color)); }, - openMusicDialog: () => { - dispatch(openMusicDialog()); + openMusicDialog: (first) => { + dispatch(showAudioPreview(first)); }, setSelectedTarget: (targets) => { dispatch(setSelectedTarget(targets)); @@ -166,13 +167,11 @@ class SharedFileCompoment extends Component { ); return; case "audio": - this.props.setSelectedTarget([ - { - key: this.props.share.key, - type: "share", - }, - ]); - this.props.openMusicDialog(); + this.props.openMusicDialog({ + key: this.props.share.key, + name: this.props.share.source.name, + type: "share", + }); return; case "video": this.props.history.push(