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

Fix the public library getting into my libraries collection bug #2242

Merged
merged 1 commit into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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