Skip to content

Commit

Permalink
Touchups to faceplate showcurrenttrack listener
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurt Ruppel committed Feb 18, 2011
1 parent d5ffbbd commit aeeb424
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
4 changes: 3 additions & 1 deletion chrome/content/directory.js
Expand Up @@ -306,7 +306,9 @@ CloudDirectory.onUnload = function CloudDirectory_onUnload() {
this._directory = null;
}

this._service.removeListener(this.listener);
if (this._service) {
this._service.removeListener(this.listener);
}

if (this._domEventListenerSet) {
this._domEventListenerSet.removeAll();
Expand Down
8 changes: 2 additions & 6 deletions chrome/content/main.js.in
Expand Up @@ -897,8 +897,6 @@ function SoundCloud_onShowCurrentTrack(aEvent) {
.getService(Ci.sbIMediacoreManager);
var item = mediacoreManager.sequencer.currentItem;
var streamSrc = SoundCloud._service.soundcloudURL;
Cu.reportError(item.contentSrc.spec);
Cu.reportError(streamSrc);
// This could potentially problematic if we have a SoundCloud streaming item
// outside of the addon context... meh don't care.
if (item.contentSrc.spec.indexOf(streamSrc) != -1) {
Expand All @@ -920,9 +918,10 @@ function SoundCloud_onShowCurrentTrack(aEvent) {
if (node != gServicePane.activeNode) {
gServicePane.activateAndLoadNode(node);
}

var view = mediacoreManager.sequencer.view;
var row = mediacoreManager.sequencer.viewPosition;
view.selection.selectOnly(row);
view.treeView.selection.select(row);
view.treeView.selection.tree.ensureRowIsVisible(row);
}

Expand Down Expand Up @@ -956,9 +955,6 @@ function SoundCloud_observe(aSubject, aTopic, aData) {
case "em-action-requested":
// Extension flagged for uninstall
aSubject.QueryInterface(Ci.nsIUpdateItem);
Cu.reportError(aSubject.id);
Cu.reportError("@EXTENSION_UUID@");
Cu.reportError(data);

if (aSubject.id == "@EXTENSION_UUID@") {
if (data == "item-uninstalled") {
Expand Down
2 changes: 1 addition & 1 deletion chrome/skin/waveform.css
Expand Up @@ -62,7 +62,7 @@ body#socl-wf-body {
border-right: 1px solid rgb(255,85,0);
position: absolute;
height: 100%;
width: 0%;
width: 0;
z-index: 1;
}

Expand Down
26 changes: 19 additions & 7 deletions components/src/sbSoundCloud.js
Expand Up @@ -587,10 +587,11 @@ function sbSoundCloudService() {
*
* \param aItems JSON object of items to add.
* \param aLibrary Target library for added items.
* \param aComplete Boolean to dispatch search completed event.
*
*/
this._addItemsToLibrary =
function sbSoundCloudService__addItemsToLibrary(aItems, aLibrary) {
function sbSoundCloudService__addItemsToLibrary(aItems, aLibrary, aComplete) {
var self = this;
if (aItems != null) {
var itemArray = Cc["@songbirdnest.com/moz/xpcom/threadsafe-array;1"]
Expand Down Expand Up @@ -687,6 +688,9 @@ function sbSoundCloudService() {
var batchListener = {
onProgress: function(aIndex) {},
onComplete: function(aMediaItems, aResult) {
if (aComplete) {
self.notifyListeners("onSearchCompleted");
}
self.notifyListeners("onTracksAdded", [aLibrary]);
if (aLibrary == self.dashboard) {
self.updateDashboardCount();
Expand Down Expand Up @@ -1337,16 +1341,18 @@ sbSoundCloudService.prototype = {
}
}

self._addItemsToLibrary(tracks, self._library);
var completed = false;

if (tracks.length > 40) {
self._track_retries = 0;
aOffset += tracks.length
self.getTracks(aUser, aQuery, aFlags, aOffset);
} else {
self._track_xhr = null;
self.notifyListeners("onSearchCompleted");
completed = true;
}

self._addItemsToLibrary(tracks, self._library, completed);
}

var failure = function(xhr) {
Expand Down Expand Up @@ -1405,9 +1411,8 @@ sbSoundCloudService.prototype = {
}
}

self._addItemsToLibrary(activities.collection, self._dashboard);

let next_href = activities.next_href;
var next_href = activities.next_href;
var completed = (next_href == null);
self._dash_retries = null;

if (next_href) {
Expand All @@ -1418,6 +1423,10 @@ sbSoundCloudService.prototype = {
} else {
self._dash_xhr = null;
}

self._addItemsToLibrary(activities.collection,
self._dashboard,
completed);
}

var failure = function(xhr) {
Expand Down Expand Up @@ -1518,15 +1527,18 @@ sbSoundCloudService.prototype = {
}
}

self._addItemsToLibrary(favorites, self._favorites);
var completed = false;

if (favorites.length < 50) {
self._fav_xhr = null;
self._fav_retries = null;
completed = true;
} else {
self._fav_retries = 0;
self._fav_xhr = self.getFavorites(aUserId, offset + favorites.length);
}

self._addItemsToLibrary(favorites, self._favorites, completed);
}

var failure = function(xhr) {
Expand Down

0 comments on commit aeeb424

Please sign in to comment.