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

api boomark shows 1962 #1988

Merged
merged 12 commits into from
Jan 3, 2017
Merged

api boomark shows 1962 #1988

merged 12 commits into from
Jan 3, 2017

Conversation

snittoor
Copy link

@snittoor snittoor commented Dec 29, 2016

Closes #1962

Apibookmarks where not showing . This is because instance.subscription('myApibookmarks') was not ready. This instance.subscription is now initialized in cataloge.js (parent) instead of bookmark.js

@brylie brylie self-assigned this Dec 29, 2016
@brylie brylie assigned jykae and unassigned brylie Dec 29, 2016
@jykae
Copy link
Contributor

jykae commented Dec 29, 2016

Reviewing

// Get current user bookmark (should be only one API Bookmarks result available)
const userBookmarks = ApiBookmarks.findOne({ userId: Meteor.user()._id, apiIds: apiId });
// Get API ID from instance data context
const apiId = instance.api._id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@snittoor @brylie this line returns undefined. To get template instance you could use instance.data.api._id or Template.currentData() Personally I prefer the latter as it's straight access to dynamic data context without using "this".

// Get current user bookmarks, only if this API is bookmarked
const userBookmarks = ApiBookmarks.findOne({
userId: Meteor.user()._id,
apiIds: apiId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also make sure to check case "undefined" by using if (apiId) structure before using apiId.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes even i got it while testing , but didnt know how to fix it .. will try what you have suggested.

Copy link
Contributor

@brylie brylie Dec 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is resolved by fixing line 36. Change line 36 to instance.data.api._id

@@ -6,16 +6,28 @@ import { FlowRouter } from 'meteor/kadira:flow-router';
import { Apis } from '/apis/collection';
import { ApiBookmarks } from '/bookmarks/collection';

import { $ } from 'jquery';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import is incorrect and results error later on code.

TypeError: $ is not a function
    at Blaze.TemplateInstance.<anonymous> (catalogue.js:127)
    at blaze.js?hash=891d5a1…:3341
    at Function.Template._withTemplateInstanceFunc (blaze.js?hash=891d5a1…:3687)
    at fireCallbacks (blaze.js?hash=891d5a1…:3337)
    at Blaze.View.<anonymous> (blaze.js?hash=891d5a1…:3430)
    at blaze.js?hash=891d5a1…:1783
    at Object.Blaze._withCurrentView (blaze.js?hash=891d5a1…:2214)
    at blaze.js?hash=891d5a1…:1782
    at Object.Tracker._runFlush (tracker.js?hash=e52e5fe…:539)
    at onGlobalMessage (meteor.js?hash=f9ccb2f…:401)

Changing to "import $ from jquery" should fix issue. Or possibly better to use local jquery http://blazejs.org/api/templates.html#Blaze-TemplateInstance-\$
eg.

Template.catalogue.onRendered(function () {
  // Activate tooltips on all relevant items
  this.$('.toolbar-tooltip').tooltip({ placement: 'bottom' });
});

Here this points to Template instance, you could also save it to variable to make it more clear, "const instance = this", and then use "instance.$"

This is safer, efficient & does not require importing jquery.
So import can be removed if you decide to use local jquery on line 127.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Ville ,
Thank you for comments and suggestions. Will implement them , though i did not get the above error will look into this error also.Glad that you tested it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @jykae mentioned, change line 9 to import $ from jquery

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brylie : Done , changed the code . Please review.

@jykae
Copy link
Contributor

jykae commented Dec 29, 2016

@snittoor @brylie Overall 2 small errors, provided suggestions for fixes. Keep up good work 👍 @snittoor welcome to community!


// Get current user bookmarks, only if this API is bookmarked
const userBookmarks = ApiBookmarks.findOne({
userId: Meteor.user()._id,
apiIds: apiId,
});

console.log("User Bookmarks",userBookmarks);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove console logs. We try not to leave these logging messages.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@brylie
Copy link
Contributor

brylie commented Jan 3, 2017

@snittoor this looks great. One last request is that you remove the console.log() statement. We try not to have console logs in our app.

@brylie brylie assigned brylie and unassigned jykae Jan 3, 2017
@brylie brylie merged commit fe28c1b into develop Jan 3, 2017
@brylie brylie removed the in progress label Jan 3, 2017
@brylie brylie deleted the bookmark_1962 branch January 3, 2017 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants