Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken add track when pasting URL on mobile #262

Open
4www opened this issue Oct 18, 2018 · 1 comment
Open

Broken add track when pasting URL on mobile #262

4www opened this issue Oct 18, 2018 · 1 comment
Labels

Comments

@4www
Copy link
Contributor

4www commented Oct 18, 2018

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.

@4www 4www added the bug label Oct 18, 2018
@oskarrough
Copy link
Member

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(),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants