These are chat archives for reactioncommerce/reaction

18th
Dec 2017
Josh Cox
@joshuacox
Dec 18 2017 03:56
@nurub52 feel free to make issues at the repo and I'll be notified immediately
Josh Cox
@joshuacox
Dec 18 2017 05:42
@nurub52 also, I'd love some feedback on my reactionetes give that a shot, and open issues there, I'll respond pretty quickly for anything there.
Tse
@tse2909
Dec 18 2017 11:49
reaction run takes time on starting app . is it runs faster on linux ?
hitachi19
@hitachi19
Dec 18 2017 14:05
it seems that each insert triggers the shopIdAutoValue() tunction twice,according to the documentation(https://github.com/aldeed/meteor-collection2-core ),is this function correct?
export function shopIdAutoValue() {
// we should always have a shopId
if (this.isSet && Meteor.isServer) {
return this.value;
} else if (Meteor.isServer && !this.isUpdate || Meteor.isClient && this.isInsert) {
return Reaction.getShopId();
}
return this.unset();
}
hitachi19
@hitachi19
Dec 18 2017 14:12
the example of the documentation(https://github.com/aldeed/meteor-collection2-core ) // Whenever the "content" field is updated, automatically
// update a history array.
updatesHistory: {
type: Array,
optional: true,
autoValue: function() {
var content = this.field("content");
if (content.isSet) {
if (this.isInsert) {
return [{
date: new Date(),
content: content.value
}];
} else {
return {
$push: {
date: new Date,
content: content.value
}
};
}
} else {
this.unset();
}
}
},
'updatesHistory.$': {
type: Object,
},
'updatesHistory.$.date': {
type: Date,
optional: true
},
'updatesHistory.$.content': {
type: String,
optional: true
},
Michael Jenny
@prinzdezibel
Dec 18 2017 14:15
Is this function shopIdAutoValue used for SimpleSchema's autoValue option?
@hitachi19
?
hitachi19
@hitachi19
Dec 18 2017 14:15
yes
Michael Jenny
@prinzdezibel
Dec 18 2017 14:16
Yes, this function may be called multiple times. for instance it will be called automatically during/before schema validation
it's an implementation detail of Aldeed's SimpleSchema
nurub52
@nurub52
Dec 18 2017 14:25
@here what is best way to implement usecase where user can see price of products only when they are signed in? I am working on B2b implmentation only registered business should be able to see price.
hitachi19
@hitachi19
Dec 18 2017 14:28
@prinzdezibel if isSet =( isInsert || is Upadate)? and insert triggers "return this.value;" first ,then triggers "return Reaction.getShopId();" in shopIdAutoValue() ?
export function shopIdAutoValue() {
// we should always have a shopId
if (this.isSet && Meteor.isServer) {
return this.value;
} else if (Meteor.isServer && !this.isUpdate || Meteor.isClient && this.isInsert) {
return Reaction.getShopId();
}
return this.unset();
}
hitachi19
@hitachi19
Dec 18 2017 14:44
@prinzdezibel it seems "Meteor.isServer && !this.isUpdate" has not been executed,right?
Michael Jenny
@prinzdezibel
Dec 18 2017 14:46
@hitachi19 I don't know.
hitachi19
@hitachi19
Dec 18 2017 14:48
@prinzdezibel still thank you very much for your patience !
Michael Jenny
@prinzdezibel
Dec 18 2017 14:50
sorry I couldn't help you. I don't know what the code is intended to do.
hitachi19
@hitachi19
Dec 18 2017 14:53
@prinzdezibel it does not matter, you're good ! thank you very much for your patience !
Michael Jenny
@prinzdezibel
Dec 18 2017 14:54
@nurub52 Probably you'd have to overwrite the Products subscription, and then filter out the field price for all not-logged in users.
something along the lines:
 Products.find(newSelector, {
     fields: {
      price: 0
    }
  });
which would prevent the field price to be published
hitachi19
@hitachi19
Dec 18 2017 14:56
@zenweasel if isSet == ( isInsert || is Upadate)? and each insert triggers "return this.value;" first ,then triggers "return Reaction.getShopId();" in shopIdAutoValue() ?
export function shopIdAutoValue() {
// we should always have a shopId
if (this.isSet && Meteor.isServer) {
return this.value;
} else if (Meteor.isServer && !this.isUpdate || Meteor.isClient && this.isInsert) {
return Reaction.getShopId();
}
return this.unset();
}
nurub52
@nurub52
Dec 18 2017 14:57
@prinzdezibel Thanks a lot, will check it out
Michael Jenny
@prinzdezibel
Dec 18 2017 14:58
@nurub52 for an example how to overwrite the publication/subscription for Products collection, see:
publication (server side)
and
subscription (client side)
(probably you wouldn't even need to change the client-side subscription)
Kenneth Beartusk
@beartusk
Dec 18 2017 17:44
I am trying insert an image as a background for the reaction store. I have had multiple issues though. Below is my code as well as the error that i get. The file path is "imports/plugins/included/default-theme/client/styles/base.less"
.......................................
main {
min-height: 80vh;
// padding: 20px 60px 135px 60px;
// padding: 20px 0 135px
// background-color: @body-bg;
background-image: url("https://cdn.pixabay.com/some_image.jpg");
}
.......................................
Refused to load the image 'https://cdn.pixabay.com/some_image.jpg' because it violates the following Content Security Policy directive: "img-src data: 'self' localhost:*
........................................
I'm not sure how to get around this as I've also tried using JPEGs that are stored within the reaction project directory. But, I still get this same error.
Michael Jenny
@prinzdezibel
Dec 18 2017 19:05
@beartusk Have a look at /server/security/policy.js and see if it makes a difference when you add your CDN's domain there.
José Luis Di Biase
@josx
Dec 18 2017 20:09
i am trying to use a beforeHook on func1 , but can i change the params sent to func1 on the beforehook
i know i have the options on beforehook with the arguments but i can change them
Kenneth Beartusk
@beartusk
Dec 18 2017 21:10

@prinzdezibel Hey that did seem to work, I don't understand why it wasn't working before since this if statement was in play inside "policy.js".

if (process.env.NODE_ENV === "development") {
BrowserPolicy.content.allowOriginForAll("localhost:");
BrowserPolicy.content.allowConnectOrigin("ws://localhost:
");
BrowserPolicy.content.allowConnectOrigin("http://localhost:*");
BrowserPolicy.content.allowConnectOrigin("https://localhost:*");
BrowserPolicy.framing.allowAll();
}

But either way thank you very much @prinzdezibel

Brent Hoover
@zenweasel
Dec 18 2017 21:57
@nurub52 I think you could just override the component that displays the price, and add a role check around it