Merge pull request #254 from kmycode/upstream-20231108
Upstream 20231108
This commit is contained in:
commit
cea042e7c9
107 changed files with 973 additions and 706 deletions
|
@ -207,7 +207,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
|||
modalType: 'IMAGE',
|
||||
modalProps: {
|
||||
src: account.get('avatar'),
|
||||
alt: account.get('acct'),
|
||||
alt: '',
|
||||
},
|
||||
}));
|
||||
},
|
||||
|
|
|
@ -19,6 +19,7 @@ import { throttle } from 'lodash';
|
|||
|
||||
import { Blurhash } from 'mastodon/components/blurhash';
|
||||
import { Icon } from 'mastodon/components/icon';
|
||||
import { playerSettings } from 'mastodon/settings';
|
||||
|
||||
import { displayMedia, useBlurhash } from '../../initial_state';
|
||||
import { isFullscreen, requestFullscreen, exitFullscreen } from '../ui/util/fullscreen';
|
||||
|
@ -226,8 +227,8 @@ class Video extends PureComponent {
|
|||
|
||||
if(!isNaN(x)) {
|
||||
this.setState((state) => ({ volume: x, muted: state.muted && x === 0 }), () => {
|
||||
this.video.volume = x;
|
||||
this.video.muted = this.state.muted;
|
||||
this._syncVideoToVolumeState(x);
|
||||
this._saveVolumeState(x);
|
||||
});
|
||||
}
|
||||
}, 15);
|
||||
|
@ -365,6 +366,8 @@ class Video extends PureComponent {
|
|||
document.addEventListener('MSFullscreenChange', this.handleFullscreenChange, true);
|
||||
|
||||
window.addEventListener('scroll', this.handleScroll);
|
||||
|
||||
this._syncVideoFromLocalStorage();
|
||||
}
|
||||
|
||||
componentWillUnmount () {
|
||||
|
@ -437,8 +440,24 @@ class Video extends PureComponent {
|
|||
const muted = !(this.video.muted || this.state.volume === 0);
|
||||
|
||||
this.setState((state) => ({ muted, volume: Math.max(state.volume || 0.5, 0.05) }), () => {
|
||||
this.video.volume = this.state.volume;
|
||||
this.video.muted = this.state.muted;
|
||||
this._syncVideoToVolumeState();
|
||||
this._saveVolumeState();
|
||||
});
|
||||
};
|
||||
|
||||
_syncVideoToVolumeState = (volume = null, muted = null) => {
|
||||
this.video.volume = volume ?? this.state.volume;
|
||||
this.video.muted = muted ?? this.state.muted;
|
||||
};
|
||||
|
||||
_saveVolumeState = (volume = null, muted = null) => {
|
||||
playerSettings.set('volume', volume ?? this.state.volume);
|
||||
playerSettings.set('muted', muted ?? this.state.muted);
|
||||
};
|
||||
|
||||
_syncVideoFromLocalStorage = () => {
|
||||
this.setState({ volume: playerSettings.get('volume') ?? 0.5, muted: playerSettings.get('muted') ?? false }, () => {
|
||||
this._syncVideoToVolumeState();
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -480,6 +499,7 @@ class Video extends PureComponent {
|
|||
|
||||
handleVolumeChange = () => {
|
||||
this.setState({ volume: this.video.volume, muted: this.video.muted });
|
||||
this._saveVolumeState(this.video.volume, this.video.muted);
|
||||
};
|
||||
|
||||
handleOpenVideo = () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue