internet4000/radio4000

Broken add track when pasting URL on mobile

4www opened this issue · 1 comments

4www commented

To reproduce, on mobile, paste in a youtube URL, in the URL field of adding a new track.

It should normally fetch the title, but it does not.

To fetch the title, adding a space at the end of the URL, will make the automatic title work.

Expected behavior would be that pasting a URL from mobile fetch the title.

I'm wondering if it is not the paste event that has issues on mobile, need to investigate the issue deeper.

Is it on /add or via the modal window?

I just looked, and we're not using the paste even any more. We have an {{input-paste}} component, which is only used in {{track-add-inline}}, which is not used anywhere.

Maybe it is something here

// Gets called when you paste into the input-url component.
// Takes an URL and turns it into a YouTube ID,
// which we use to query the API for a title.
automaticSetTitle: observer('track.url', function () {
const track = get(this, 'track');
// Can not continue without a track or URL.
if (!track || !track.get('url')) {
return;
}
// Don't overwrite already existing titles
if (track.get('title')) {
return;
}
// Because the URL might have changed
const newid = youtubeUrlToId(track.get('url'));
if (newid) {
track.set('ytid', newid);
get(this, 'fetchTitle').perform();
}
}),
fetchTitle: task(function * () {
yield timeout(250); // throttle
const track = get(this, 'track');
const ytid = track.get('ytid');
const url = `https://www.googleapis.com/youtube/v3/videos?id=${ytid}&key=${config.youtubeApiKey}&fields=items(id,snippet(title))&part=snippet`;
const response = yield fetch(url);
const data = yield response.json();
if (!data.items.length) {
debug('Could not find title for track');
return;
}
const title = data.items[0].snippet.title;
track.set('title', title);
}).restartable(),