add synchronous channel subscribe frontend, #862

This commit is contained in:
Simon
2025-01-08 16:06:23 +07:00
parent d79fbcd168
commit 0411b14c5c
7 changed files with 36 additions and 36 deletions

View 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;

View File

@@ -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 },
});
};