Skip to content

Commit

Permalink
Merge pull request #2242 from shinyichen/lib-bug
Browse files Browse the repository at this point in the history
Fix the public library getting into my libraries collection bug
  • Loading branch information
thostetler authored Feb 24, 2022
2 parents e397a7b + e6a10cb commit 2527fbf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/js/apps/discovery/navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ define([
.then(function() {
app
.getObject('LibraryController')
.getLibraryMetadata(data.id)
.getLibraryMetadata(data.id, !data.publicView)
.done(function(metadata) {
data.editRecords =
_.contains(
Expand Down
10 changes: 6 additions & 4 deletions src/js/components/library_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ define([
* about the lib with that id
* */

getLibraryMetadata: function(id) {
getLibraryMetadata: function(id, merge = true) {
// check to see if the id is even in the collection,
// if not return fetchLibraryMetadata;
if (id && !this.collection.get(id)) {
return this.fetchLibraryMetadata(id);
return this.fetchLibraryMetadata(id, merge);
}
var deferred = $.Deferred();
var that = this;
Expand Down Expand Up @@ -278,7 +278,7 @@ define([
* in case the new data hasn't been added to the collection yet
* */

fetchLibraryMetadata: function(id) {
fetchLibraryMetadata: function(id, merge = true) {
var that = this;
if (!id) throw new Error('need to provide a library id');
var deferred = $.Deferred();
Expand All @@ -287,7 +287,9 @@ define([
.done(function(data) {
deferred.resolve(data.metadata);
// set into collection
that.collection.add(data.metadata, { merge: true });
if (merge) {
that.collection.add(data.metadata, { merge: true });
}
})
.fail(function(xhr) {
deferred.reject(xhr);
Expand Down
2 changes: 1 addition & 1 deletion src/js/widgets/library_individual/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ define([

this.getBeeHive()
.getObject('LibraryController')
.getLibraryMetadata(this.model.get('id'))
.getLibraryMetadata(this.model.get('id'), !this.model.get('publicView'))
.done(done);
},

Expand Down

0 comments on commit 2527fbf

Please sign in to comment.