Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#32035 closed defect (bug) (fixed)

Media views EmbedLink debounce

Reported by: afercia's profile afercia Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.3 Priority: normal
Severity: normal Version: 4.1
Component: Media Keywords: has-patch
Focuses: ui, javascript Cc:

Description

Not sure the current usage of _.debounce is correct when embedding a link from "Insert from URL". To my understanding, the updateoEmbed function should not be debounced and fetch should be debounced instead.
See discussion about _.debounce on #26600

Attachments (1)

32035.diff (2.8 KB) - added by wonderboymusic 9 years ago.

Download all attachments as: .zip

Change History (3)

@wonderboymusic
9 years ago

#1 @wonderboymusic
9 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 4.3
  • Owner set to wonderboymusic
  • Status changed from new to assigned

_.debounce is correctly placed on the typing callback. The real issue is stampede of XHRs on fetch(). These aren't necessarily a problem, but the browser shouldn't try to handle all of them.

If a fetch() is happening, and another one is triggered, the currently pending XHR should be aborted. You can't call abort() on $.Deferred, but you can on $.ajax, so we will use that instead of wp.media.ajax, which returns a deferred Promise.

#2 @wonderboymusic
9 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 32460:

When fetching in media/views/embed/link.js, call abort() on any existing XHRs.
Use $.ajax instead of wp.ajax.send() to allow this.
Pass this as context to the options to remove the need to bind callbacks.

Fixes #32035.

Note: See TracTickets for help on using tickets.