mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-07 17:29:25 +00:00
refac channel about page settings, #852
This commit is contained in:
33
frontend/src/api/actions/updateChannelOverwrite.ts
Normal file
33
frontend/src/api/actions/updateChannelOverwrite.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import defaultHeaders from '../../configuration/defaultHeaders';
|
||||
import getApiUrl from "../../configuration/getApiUrl"
|
||||
import getFetchCredentials from '../../configuration/getFetchCredentials';
|
||||
import getCookie from "../../functions/getCookie";
|
||||
|
||||
const updateChannelOverwrites = async (channelId: string, configKey: string, configValue: any) => {
|
||||
const apiUrl = getApiUrl();
|
||||
const csrfCookie = getCookie('csrftoken');
|
||||
|
||||
const data = {
|
||||
channel_overwrites: {
|
||||
[configKey]: configValue
|
||||
}
|
||||
};
|
||||
|
||||
const response = await fetch(`${apiUrl}/api/channel/${channelId}/`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...defaultHeaders,
|
||||
'X-CSRFToken': csrfCookie || '',
|
||||
},
|
||||
credentials: getFetchCredentials(),
|
||||
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
|
||||
const channelSubscription = await response.json();
|
||||
console.log('updateChannelOverwrites', channelSubscription);
|
||||
|
||||
return channelSubscription;
|
||||
}
|
||||
|
||||
export default updateChannelOverwrites;
|
||||
@@ -1,39 +0,0 @@
|
||||
import defaultHeaders from '../../configuration/defaultHeaders';
|
||||
import getApiUrl from '../../configuration/getApiUrl';
|
||||
import getFetchCredentials from '../../configuration/getFetchCredentials';
|
||||
import getCookie from '../../functions/getCookie';
|
||||
|
||||
export type ChannelAboutConfigType = {
|
||||
index_playlists?: boolean;
|
||||
download_format?: boolean | string;
|
||||
autodelete_days?: boolean | number;
|
||||
integrate_sponsorblock?: boolean | null;
|
||||
subscriptions_channel_size?: number;
|
||||
subscriptions_live_channel_size?: number;
|
||||
subscriptions_shorts_channel_size?: number;
|
||||
};
|
||||
|
||||
const updateChannelSettings = async (channelId: string, config: ChannelAboutConfigType) => {
|
||||
const apiUrl = getApiUrl();
|
||||
const csrfCookie = getCookie('csrftoken');
|
||||
|
||||
const response = await fetch(`${apiUrl}/api/channel/${channelId}/`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...defaultHeaders,
|
||||
'X-CSRFToken': csrfCookie || '',
|
||||
},
|
||||
credentials: getFetchCredentials(),
|
||||
|
||||
body: JSON.stringify({
|
||||
channel_overwrites: config,
|
||||
}),
|
||||
});
|
||||
|
||||
const channelSubscription = await response.json();
|
||||
console.log('updateChannelSettings', channelSubscription);
|
||||
|
||||
return channelSubscription;
|
||||
};
|
||||
|
||||
export default updateChannelSettings;
|
||||
Reference in New Issue
Block a user