diff --git a/.eslintrc.json b/.eslintrc.json index ea26ba3be..4d0e75628 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -44,6 +44,7 @@ "prefer-rest-params": 0, "prettier/prettier": "error", "quote-props": 0, - "unicorn/filename-case": 0 + "unicorn/filename-case": 0, + "jsx-a11y/media-has-caption": 0 } } diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index f99e6a775..84d3e0482 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -128,10 +128,10 @@ export class PostListing extends Component { componentDidMount(): void { if (UserService.Instance.myUserInfo) { - const { auto_expand, blur_nsfw } = UserService.Instance.myUserInfo.local_user_view.local_user; + const { auto_expand, blur_nsfw } = + UserService.Instance.myUserInfo.local_user_view.local_user; this.setState({ - imageExpanded: - auto_expand && !(blur_nsfw && this.postView.post.nsfw), + imageExpanded: auto_expand && !(blur_nsfw && this.postView.post.nsfw), }); } } @@ -214,7 +214,13 @@ export class PostListing extends Component { if (url && isVideo(url)) { return (
-
@@ -766,6 +772,24 @@ export class PostListing extends Component { this.setState({ showEdit: false }); } + handleVideoLoadStart(_i: PostListing, e: Event) { + const video = e.target as HTMLVideoElement; + const volume = localStorage.getItem("video_volume_level"); + const muted = localStorage.getItem("video_muted"); + video.volume = Number(volume || 0); + video.muted = muted !== "false"; + if (!(volume || muted)) { + localStorage.setItem("video_muted", "true"); + localStorage.setItem("volume_level", "0"); + } + } + + handleVideoVolumeChange(_i: PostListing, e: Event) { + const video = e.target as HTMLVideoElement; + localStorage.setItem("video_muted", video.muted.toString()); + localStorage.setItem("video_volume_level", video.volume.toString()); + } + // The actual editing is done in the receive for post handleEditPost(form: EditPost) { this.setState({ showEdit: false });