Add trim to subscribe textarea fields #908
This commit is contained in:
parent
04ea6254b7
commit
0aa5ef5b31
|
|
@ -3,7 +3,7 @@ import APIClient from '../../functions/APIClient';
|
|||
const createCustomPlaylist = async (playlistId: string) => {
|
||||
return APIClient('/api/playlist/custom/', {
|
||||
method: 'POST',
|
||||
body: { playlist_name: playlistId },
|
||||
body: { playlist_name: playlistId.trim() },
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ const updateBulkChannelSubscriptions = async (channelIds: string, status: boolea
|
|||
const youtubeChannelIds = channelIds.split('\n');
|
||||
|
||||
youtubeChannelIds.forEach(channelId => {
|
||||
channels.push({ channel_id: channelId, channel_subscribed: status });
|
||||
if (channelId.trim()) {
|
||||
channels.push({ channel_id: channelId, channel_subscribed: status });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
channels.push({ channel_id: channelIds, channel_subscribed: status });
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ const updateBulkPlaylistSubscriptions = async (playlistIds: string, status: bool
|
|||
const youtubePlaylistIds = playlistIds.split('\n');
|
||||
|
||||
youtubePlaylistIds.forEach(playlistId => {
|
||||
playlists.push({ playlist_id: playlistId, playlist_subscribed: status });
|
||||
if (playlistId.trim()) {
|
||||
playlists.push({ playlist_id: playlistId, playlist_subscribed: status });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
playlists.push({ playlist_id: playlistIds, playlist_subscribed: status });
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ const updateDownloadQueue = async (youtubeIdStrings: string, autostart: boolean)
|
|||
const youtubeIds = youtubeIdStrings.split('\n');
|
||||
|
||||
youtubeIds.forEach(youtubeId => {
|
||||
urls.push({ youtube_id: youtubeId, status: 'pending' });
|
||||
if (youtubeId.trim()) {
|
||||
urls.push({ youtube_id: youtubeId, status: 'pending' });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
urls.push({ youtube_id: youtubeIdStrings, status: 'pending' });
|
||||
|
|
|
|||
|
|
@ -119,10 +119,12 @@ const Channels = () => {
|
|||
label="Subscribe"
|
||||
type="submit"
|
||||
onClick={async () => {
|
||||
await updateBulkChannelSubscriptions(channelsToSubscribeTo, true);
|
||||
if (channelsToSubscribeTo.trim()) {
|
||||
await updateBulkChannelSubscriptions(channelsToSubscribeTo, true);
|
||||
|
||||
setShowNotification(true);
|
||||
setShowAddForm(false);
|
||||
setShowNotification(true);
|
||||
setShowAddForm(false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -200,19 +200,23 @@ const Download = () => {
|
|||
<Button
|
||||
label="Add to queue"
|
||||
onClick={async () => {
|
||||
await updateDownloadQueue(downloadQueueText, false);
|
||||
setDownloadQueueText('');
|
||||
setRefresh(true);
|
||||
setShowHiddenForm(false);
|
||||
if (downloadQueueText.trim()) {
|
||||
await updateDownloadQueue(downloadQueueText, false);
|
||||
setDownloadQueueText('');
|
||||
setRefresh(true);
|
||||
setShowHiddenForm(false);
|
||||
}
|
||||
}}
|
||||
/>{' '}
|
||||
<Button
|
||||
label="Download now"
|
||||
onClick={async () => {
|
||||
await updateDownloadQueue(downloadQueueText, true);
|
||||
setDownloadQueueText('');
|
||||
setRefresh(true);
|
||||
setShowHiddenForm(false);
|
||||
if (downloadQueueText.trim()) {
|
||||
await updateDownloadQueue(downloadQueueText, true);
|
||||
setDownloadQueueText('');
|
||||
setRefresh(true);
|
||||
setShowHiddenForm(false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -102,9 +102,11 @@ const Playlists = () => {
|
|||
label="Subscribe"
|
||||
type="submit"
|
||||
onClick={async () => {
|
||||
await updateBulkPlaylistSubscriptions(playlistsToAddText, true);
|
||||
setShowNotification(true);
|
||||
setShowAddForm(false);
|
||||
if (playlistsToAddText.trim()) {
|
||||
await updateBulkPlaylistSubscriptions(playlistsToAddText, true);
|
||||
setShowNotification(true);
|
||||
setShowAddForm(false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
|
@ -125,8 +127,10 @@ const Playlists = () => {
|
|||
label="Create"
|
||||
type="submit"
|
||||
onClick={async () => {
|
||||
await createCustomPlaylist(customPlaylistsToAddText);
|
||||
setRefresh(true);
|
||||
if (customPlaylistsToAddText.trim()) {
|
||||
await createCustomPlaylist(customPlaylistsToAddText);
|
||||
setRefresh(true);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue