add cast to appsettings

This commit is contained in:
Simon 2025-03-08 18:32:13 +07:00
parent 73f7e8945c
commit 7229cf1930
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
7 changed files with 24 additions and 7 deletions

View File

@ -62,6 +62,7 @@ class AppConfigAppSerializer(
"""serialize app config"""
enable_snapshot = serializers.BooleanField()
enable_cast = serializers.BooleanField()
class AppConfigSerializer(ValidateUnknownFieldsMixin, serializers.Serializer):

View File

@ -51,6 +51,7 @@ class ApplicationConfigType(TypedDict):
"""describes application config"""
enable_snapshot: bool
enable_cast: bool
class AppConfigType(TypedDict):
@ -93,7 +94,10 @@ class AppConfig:
"integrate_ryd": False,
"integrate_sponsorblock": False,
},
"application": {"enable_snapshot": True},
"application": {
"enable_snapshot": True,
"enable_cast": False,
},
}
def __init__(self):

View File

@ -29,6 +29,7 @@ export type AppSettingsConfigType = {
};
application: {
enable_snapshot: boolean;
enable_cast: boolean;
};
};

View File

@ -92,8 +92,7 @@ const EmbeddableVideoPlayer = ({ videoId }: EmbeddableVideoPlayerProps) => {
const likes = formatNumbers(video.stats.like_count);
const hasDislikes = video.stats.dislike_count > 0 && appSettingsConfig.downloads.integrate_ryd;
const dislikes = formatNumbers(video.stats.dislike_count);
// const config = videoResponse.config;
const cast = false; // config.enable_cast;
const cast = appSettingsConfig.application.enable_cast;
return (
<>

View File

@ -92,6 +92,7 @@ const SettingsApplication = () => {
const [showApiToken, setShowApiToken] = useState(false);
const [downloadDislikes, setDownloadDislikes] = useState(false);
const [enableSponsorBlock, setEnableSponsorBlock] = useState(false);
const [enableCast, setEnableCast] = useState(false);
// Snapshots
const [enableSnapshots, setEnableSnapshots] = useState(false);
@ -135,6 +136,7 @@ const SettingsApplication = () => {
// Integrations
setDownloadDislikes(appSettingsConfig.downloads.integrate_ryd);
setEnableSponsorBlock(appSettingsConfig.downloads.integrate_sponsorblock);
setEnableCast(appSettingsConfig.application.enable_cast);
// Snapshots
setEnableSnapshots(appSettingsConfig.application.enable_snapshot);
@ -867,6 +869,16 @@ const SettingsApplication = () => {
updateCallback={handleUpdateConfig}
/>
</div>
<div className="settings-box-wrapper">
<div>
<p>Enable Cast</p>
</div>
<ToggleConfig
name="application.enable_cast"
value={enableCast}
updateCallback={handleUpdateConfig}
/>
</div>
</div>
<div className="info-box-item">
<h2>Snapshots</h2>

View File

@ -39,7 +39,7 @@ import loadVideoNav, { VideoNavResponseType } from '../api/loader/loadVideoNav';
import useIsAdmin from '../functions/useIsAdmin';
import ToggleConfig from '../components/ToggleConfig';
import { PlaylistType } from '../api/loader/loadPlaylistById';
// import { useAppSettingsStore } from '../stores/AppSettingsStore';
import { useAppSettingsStore } from '../stores/AppSettingsStore';
const isInPlaylist = (videoId: string, playlist: PlaylistType) => {
return playlist.playlist_entries.some(entry => {
@ -110,7 +110,7 @@ const Video = () => {
const { videoId } = useParams() as VideoParams;
const navigate = useNavigate();
const isAdmin = useIsAdmin();
// const { appSettingsConfig } = useAppSettingsStore();
const { appSettingsConfig } = useAppSettingsStore();
const [videoEnded, setVideoEnded] = useState(false);
const [playlistAutoplay, setPlaylistAutoplay] = useState(
@ -193,7 +193,6 @@ const Video = () => {
const video = videoResponse;
const watched = videoResponse.player.watched;
// const config = appSettingsConfig;
const playlistNav = videoPlaylistNav;
const sponsorBlock = videoResponse.sponsorblock;
const customPlaylists = customPlaylistsResponse?.data;
@ -202,7 +201,7 @@ const Video = () => {
console.log('playlistNav', playlistNav);
const cast = false; // config.enable_cast;
const cast = appSettingsConfig.application.enable_cast;
return (
<>

View File

@ -36,6 +36,7 @@ export const useAppSettingsStore = create<AppSettingsState>(set => ({
},
application: {
enable_snapshot: false,
enable_cast: false,
},
},
setAppSettingsConfig: appSettingsConfig => set({ appSettingsConfig }),