mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-07 19:29:33 +00:00
add synchronous channel subscribe frontend, #862
This commit is contained in:
23
frontend/src/api/actions/updateBulkChannelSubscriptions.ts
Normal file
23
frontend/src/api/actions/updateBulkChannelSubscriptions.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import APIClient from '../../functions/APIClient';
|
||||
|
||||
const updateBulkChannelSubscriptions = async (channelIds: string, status: boolean) => {
|
||||
const channels = [];
|
||||
const containsMultiple = channelIds.includes('\n');
|
||||
|
||||
if (containsMultiple) {
|
||||
const youtubeChannelIds = channelIds.split('\n');
|
||||
|
||||
youtubeChannelIds.forEach(channelId => {
|
||||
channels.push({ channel_id: channelId, channel_subscribed: status });
|
||||
});
|
||||
} else {
|
||||
channels.push({ channel_id: channelIds, channel_subscribed: status });
|
||||
}
|
||||
|
||||
return APIClient('/api/channel/', {
|
||||
method: 'POST',
|
||||
body: { data: [...channels] },
|
||||
});
|
||||
};
|
||||
|
||||
export default updateBulkChannelSubscriptions;
|
||||
@@ -1,22 +1,9 @@
|
||||
import APIClient from '../../functions/APIClient';
|
||||
|
||||
const updateChannelSubscription = async (channelIds: string, status: boolean) => {
|
||||
const channels = [];
|
||||
const containsMultiple = channelIds.includes('\n');
|
||||
|
||||
if (containsMultiple) {
|
||||
const youtubeChannelIds = channelIds.split('\n');
|
||||
|
||||
youtubeChannelIds.forEach(channelId => {
|
||||
channels.push({ channel_id: channelId, channel_subscribed: status });
|
||||
});
|
||||
} else {
|
||||
channels.push({ channel_id: channelIds, channel_subscribed: status });
|
||||
}
|
||||
|
||||
return APIClient('/api/channel/', {
|
||||
const updateChannelSubscription = async (channelId: string, status: boolean) => {
|
||||
return APIClient(`/api/channel/${channelId}/`, {
|
||||
method: 'POST',
|
||||
body: { data: [...channels] },
|
||||
body: { channel_subscribed: status },
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user