-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
(perf, refactor) Remove unnecessary code in Media subscription. #3558
(perf, refactor) Remove unnecessary code in Media subscription. #3558
Conversation
@prinzdezibel This publication might still be used. Uploading a logo for the shop brand, unless that has been removed from shop settings, uses this publication. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prinzdezibel Please always include test instructions in every PR you submit |
* CollectionFS - Image/Video Publication | ||
* @params {Array} shops - array of current shop object | ||
*/ | ||
Meteor.publish("Media", function (shops) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @mikemurray notes we still need brandAssets
but I wonder if we still need all this code which seems like it just gets negated by
return Media.find({
- "metadata.type": "brandAsset"
- });
at the bottom?
Do we still need this for reactivity or is this handled in the Products publication?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zenweasel @mikemurray It does seem that this publication could be simplified significantly.
Thanks for the hint with the brand asset, @mikemurray. I've been thinking hard and could not imagine a place where this pub would have still been in use. Now I know better. I'm going to strip this pub down to something along the lines.
|
…ively' into fix-3557-prinzdezibel-remove-media-publication
Your statement would correlate with that code snippet, if I'm correct:
I don't think it's necessary at all. For one all it does looks to me like an unnecessary roundtrip to the client, because it pushes revision and images when the revision is created and deletes it when the revision is published. Also I'm wondering about the following two things: a) The first push (the media object) b) The second push (the Revision object) NOTE In case you're asking where the 3.rd push is coming from: This results from my PR #3559. Here is a gif for a better explanation (click on it to have it enlarged in a separate tab window): |
…for the brand assets. But it's significantly less code.
Changed as requested, @mikemurray. Also this PR does now incorporate the already approved & merged PR#3559. |
@@ -545,6 +545,27 @@ Meteor.publish("Products", function (productScrollLimit = 24, productFilters, so | |||
const mediaProductIds = productCursor.fetch().map((p) => p._id); | |||
const mediaCursor = findProductMedia(this, mediaProductIds); | |||
|
|||
const handle = productCursor.observe({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prinzdezibel Isn't this equivalent to lines 546
and 571
? All the media from the products and their variants should already be published unless I'm missing something here.
Should probably be flagged as a breaking change since we are changing the name of a publication? |
Would probably only break, if somebody has overwritten the pub/sub, I guess. |
Or if they were subscribing to it in their own code. I would say changing the name of publication is probably one of the bigger API changes one could make. |
@prinzdezibel - Assigning you this doc ticket reactioncommerce/reaction-docs#490 to update https://docs.reactioncommerce.com/reaction-docs/master/image-handling to reflect this name change |
Closes #3557
This ticket addresses:
selector
variable