#metabrainz

/

      • MajorLurker has quit
      • 2018-01-01 00149, 2018

      • arthelon[m]
        PR looks really solid
      • 2018-01-01 00106, 2018

      • arthelon[m]
        caught a few small things but this looks great
      • 2018-01-01 00155, 2018

      • arthelon[m]
        hmm actually nvm
      • 2018-01-01 00100, 2018

      • naiveai
        arthelon[m]: are you referring to ny PR?
      • 2018-01-01 00113, 2018

      • arthelon[m]
        yup
      • 2018-01-01 00147, 2018

      • naiveai
        can't see your review, lemme check again
      • 2018-01-01 00102, 2018

      • arthelon[m]
        haven't made a review yet
      • 2018-01-01 00110, 2018

      • naiveai
        ah
      • 2018-01-01 00112, 2018

      • arthelon[m]
        still looking through
      • 2018-01-01 00118, 2018

      • arthelon[m]
        hmm I'm not a big fan of mutating function arguments, even when documented it's easy to miss
      • 2018-01-01 00133, 2018

      • naiveai
        arthelon[m]: agreed, but since entityEditorMarkup is the only one with acess to `store` (and ideally should be the only one), I don't see any other way
      • 2018-01-01 00148, 2018

      • naiveai
        other than perhaps returning the store.getState(), but that seems less clean
      • 2018-01-01 00102, 2018

      • arthelon[m]
        you can change the final expression to "{markup, props: {...props, initialState: store.getState()}};"
      • 2018-01-01 00117, 2018

      • naiveai
        arthelon[m]: ah, that makes sense.
      • 2018-01-01 00128, 2018

      • naiveai
        arthelon[m]: that won't break caller code either!
      • 2018-01-01 00143, 2018

      • naiveai
        arthelon[m]: am making a commit that does this
      • 2018-01-01 00145, 2018

      • arthelon[m]
        yeah, I'll leave that snippet in my review
      • 2018-01-01 00148, 2018

      • Nyanko-sensei has quit
      • 2018-01-01 00116, 2018

      • MajorLurker joined the channel
      • 2018-01-01 00121, 2018

      • naiveai
        arthelon[m]: should I use Object.assign instead?
      • 2018-01-01 00143, 2018

      • arthelon[m]
        Up to you. Both constructs get transpiled with babel anyways. Personally I prefer using spread though.
      • 2018-01-01 00127, 2018

      • Slurpee joined the channel
      • 2018-01-01 00106, 2018

      • arthelon[m]
        I think the props mutation was the only issue I identified.
      • 2018-01-01 00151, 2018

      • naiveai
        kewl, am pushing in a minute
      • 2018-01-01 00118, 2018

      • arthelon[m]
        I'm wary of writing functions with more than 3 arguments, probably means that something can be simplified, but I don't see a better way at the moment.
      • 2018-01-01 00104, 2018

      • arthelon[m]
        LordSputnik: I'll leave it up to you to approve naiveai's gci task
      • 2018-01-01 00128, 2018

      • naiveai
        arthelon[m]: putting entityType and action in req seem to be the most obvious changes
      • 2018-01-01 00141, 2018

      • naiveai
        arthelon[m]: might figure out a way to do them in a different PR after gci
      • 2018-01-01 00100, 2018

      • naiveai
        arthelon[m]: for consistency I'm leaning towards Object.assign
      • 2018-01-01 00129, 2018

      • arthelon[m]
        alright
      • 2018-01-01 00130, 2018

      • arthelon[m]
        sure
      • 2018-01-01 00122, 2018

      • Ashish joined the channel
      • 2018-01-01 00157, 2018

      • naiveai
        arthelon[m]: done!
      • 2018-01-01 00141, 2018

      • arthelon[m]
        if the initialState field exists on props, the initialState of the object literal you passed in as the first argument will be overriden
      • 2018-01-01 00148, 2018

      • arthelon[m]
        You should swap their places
      • 2018-01-01 00133, 2018

      • arthelon[m]
        make sure you add an empty object literal as the first argument though otherwise 'props' will be mutated by Object.assign
      • 2018-01-01 00132, 2018

      • naiveai
        arthelon[m]: Object.assign({}, props, { initialState: store.getState() })
      • 2018-01-01 00133, 2018

      • naiveai
        ?
      • 2018-01-01 00155, 2018

      • arthelon[m]
        yup
      • 2018-01-01 00129, 2018

      • naiveai
        arthelon[m]: ah, I should probably do that in generateEntityProps as well
      • 2018-01-01 00109, 2018

      • arthelon[m]
        mhm yeah I missed that
      • 2018-01-01 00142, 2018

      • naiveai
        arthelon[m]: done!
      • 2018-01-01 00110, 2018

      • naiveai
        LordSputnik: as it turns out I was wrong, *now* its 25 commits
      • 2018-01-01 00126, 2018

      • naiveai
        lemme know if I can feasibly squash any of these
      • 2018-01-01 00136, 2018

      • naiveai
        arthelon[m]: come to think of it, when you do props.intialState = something; it'll override right?
      • 2018-01-01 00153, 2018

      • naiveai
        that line was used originally
      • 2018-01-01 00154, 2018

      • arthelon[m]
        yeah that
      • 2018-01-01 00159, 2018

      • arthelon[m]
        's why I was against it
      • 2018-01-01 00118, 2018

      • naiveai
        this may or may not have broken something
      • 2018-01-01 00121, 2018

      • naiveai
        lemme check
      • 2018-01-01 00143, 2018

      • arthelon[m]
        objects are passed by reference
      • 2018-01-01 00134, 2018

      • naiveai
        arthelon[m]: yeah, it didn't. phew
      • 2018-01-01 00131, 2018

      • naiveai
        man, i should probably try replacing coveralls with codecov sometime
      • 2018-01-01 00145, 2018

      • naiveai
        codecov has a single comment at the top that it keeps editing
      • 2018-01-01 00104, 2018

      • CatCat has quit
      • 2018-01-01 00129, 2018

      • CatCat joined the channel
      • 2018-01-01 00129, 2018

      • CatCat has quit
      • 2018-01-01 00129, 2018

      • CatCat joined the channel
      • 2018-01-01 00139, 2018

      • Ashish has quit
      • 2018-01-01 00124, 2018

      • LordSputnik
        naiveai: hmm
      • 2018-01-01 00133, 2018

      • LordSputnik
        I think your last commit does the opposite of what you want it to
      • 2018-01-01 00138, 2018

      • LordSputnik
      • 2018-01-01 00147, 2018

      • LordSputnik
        later arguments take priority over earlier ones
      • 2018-01-01 00115, 2018

      • LordSputnik
        (essentially it's copying the properties of the objects in the arguments to the first argument in a sequence)
      • 2018-01-01 00122, 2018

      • KassOtsimine
        great now I read "man, i should probably try replacing coveralls with codecov sometime"
      • 2018-01-01 00122, 2018

      • KassOtsimine
        as "man, i should probably try replacing overalls with corderoy sometime"
      • 2018-01-01 00124, 2018

      • KassOtsimine
        >_<
      • 2018-01-01 00150, 2018

      • KassOtsimine
        srsly, brain
      • 2018-01-01 00119, 2018

      • drsaunders joined the channel
      • 2018-01-01 00129, 2018

      • LordSputnik
        KassOtsimine: Possibly also a good choice ;)
      • 2018-01-01 00104, 2018

      • KassOtsimine
        :D
      • 2018-01-01 00118, 2018

      • naiveai
        LordSputnik: gimme a sec
      • 2018-01-01 00135, 2018

      • naiveai
        will fix
      • 2018-01-01 00111, 2018

      • naiveai
        LordSputnik: should I do a git revert --hard HEAD~1?
      • 2018-01-01 00127, 2018

      • naiveai
        it'll require a force push but a revert commit would clutter the history
      • 2018-01-01 00128, 2018

      • LordSputnik
        naiveai: yeah can do, then just force push to your repo
      • 2018-01-01 00104, 2018

      • LordSputnik
        My force push policy is a bit looser than Leftmost's - as long as the branch is unlikely to have been pulled since you made the original commit, I'm fine with it
      • 2018-01-01 00113, 2018

      • naiveai
        LordSputnik: done.
      • 2018-01-01 00104, 2018

      • naiveai
        now only 24 commits :(
      • 2018-01-01 00115, 2018

      • naiveai
        suggest something so I can make it 25 :D
      • 2018-01-01 00144, 2018

      • dragonzeron has quit
      • 2018-01-01 00155, 2018

      • naiveai
        LordSputnik: wait, bit slow today, should I do Object.assign({}, {blah blah}, additionalProps) in getEntityProps
      • 2018-01-01 00108, 2018

      • LordSputnik
        Err let me see
      • 2018-01-01 00134, 2018

      • arthelon[m]
        if you want additionalProps to override then yes
      • 2018-01-01 00156, 2018

      • naiveai
        oof
      • 2018-01-01 00118, 2018

      • LordSputnik
        naiveai: I think it's fine as is
      • 2018-01-01 00118, 2018

      • naiveai
        what would the commit message for that be?
      • 2018-01-01 00136, 2018

      • naiveai
        LordSputnik: now I am confused.
      • 2018-01-01 00141, 2018

      • naiveai
        lemme check the docs again
      • 2018-01-01 00142, 2018

      • LordSputnik
        Object.assign({}, {a: 1}) is the same as Object.assign({a: 1})
      • 2018-01-01 00111, 2018

      • LordSputnik
        You already do Object.assign({blah blah}, additionalProps) so gain nothing by adding an extra empty object on the front
      • 2018-01-01 00128, 2018

      • naiveai
        LordSputnik: ya but arthelon[m] seems to be implying that Object.assign({}, {a: 1}, {a: 2}) would be the correct way to override
      • 2018-01-01 00133, 2018

      • naiveai
        LordSputnik: MDN uses Object.assign({}, obj) to clone `obj`
      • 2018-01-01 00115, 2018

      • naiveai
        though they do result in the same object
      • 2018-01-01 00134, 2018

      • naiveai
        var obj = {a: 1}; Object.assign({}, obj, {a: 2}) doesn't mutate
      • 2018-01-01 00105, 2018

      • naiveai
        but Object.assign(obj, {a: 2}) does mutate
      • 2018-01-01 00132, 2018

      • naiveai
        so, arthelon[m], it seems Object.assign({}, props, {initialState: something}) will indeed override
      • 2018-01-01 00138, 2018

      • naiveai
        but it will also mutate prop
      • 2018-01-01 00140, 2018

      • naiveai
        *props
      • 2018-01-01 00148, 2018

      • naiveai
        it seems the correct way to do it in entityEditorMarkup would be Object.assign(props, {initialState: store.getState()})
      • 2018-01-01 00119, 2018

      • naiveai
        and in generateEntityprops Object.assign({stuff}, additionalProps) - what we're already doing
      • 2018-01-01 00134, 2018

      • naiveai
        if confirmed I will push the change
      • 2018-01-01 00154, 2018

      • LordSputnik
        naiveai: hold on
      • 2018-01-01 00107, 2018

      • LordSputnik
        OK, so Object.assign mutates the first argument using the remaining arguments
      • 2018-01-01 00121, 2018

      • LordSputnik
        It then returns a reference to the first argument
      • 2018-01-01 00112, 2018

      • LordSputnik
        If you do Object.assign(props, {initialState: store.getState()}) that'll mutate props, which isn't what you want to do, I think
      • 2018-01-01 00126, 2018

      • naiveai
        ah, that makes sense
      • 2018-01-01 00100, 2018

      • naiveai
        but that means Object.assign({}, {intialState: store.getState()}, props) is correct
      • 2018-01-01 00125, 2018

      • naiveai
        and I need to add that {} in generateEntityProps
      • 2018-01-01 00128, 2018

      • LordSputnik
        It is, but in this case you don't mind that {initialState: store.getState()} is mutated
      • 2018-01-01 00133, 2018

      • LordSputnik
        So both are correct
      • 2018-01-01 00149, 2018

      • LordSputnik
        Since that's just a temporary object you've made which isn't referred to anywhere else
      • 2018-01-01 00156, 2018

      • naiveai
        for consisentcy I'll use {}, it's used in generateProps too
      • 2018-01-01 00121, 2018

      • LordSputnik
        I wouldn't worry about consistency here, because you're doing different things in both instances
      • 2018-01-01 00150, 2018

      • LordSputnik
        (in fact I'd probably do const stuff = {initialState: store.getState(), ...props};)
      • 2018-01-01 00124, 2018

      • naiveai
        ok, end of day, what should I do
      • 2018-01-01 00133, 2018

      • naiveai
        in generateEntityProps
      • 2018-01-01 00140, 2018

      • naiveai
        it makes sense to keep the current thing
      • 2018-01-01 00144, 2018

      • LordSputnik
        Anything that's correct, I don't really mind :)
      • 2018-01-01 00104, 2018

      • LordSputnik
        If it works, it's good
      • 2018-01-01 00115, 2018

      • naiveai
        i'm going with Object.assign({initialState: store.getState()}, props) then
      • 2018-01-01 00122, 2018

      • LordSputnik
        OK
      • 2018-01-01 00123, 2018

      • naiveai
        and keeping generateEntityProps as-is
      • 2018-01-01 00147, 2018

      • naiveai
        LordSputnik: force pushed changes
      • 2018-01-01 00126, 2018

      • LordSputnik
        Oh hold on, I think I've misread what you were asking about
      • 2018-01-01 00108, 2018

      • LordSputnik
        generateEntityProps is fine
      • 2018-01-01 00117, 2018

      • LordSputnik
        So Object.assign({initialState: ...}, props) will override initialState if it's present in props
      • 2018-01-01 00127, 2018

      • naiveai
        LordSputnik: no
      • 2018-01-01 00129, 2018

      • naiveai
        afaik
      • 2018-01-01 00137, 2018

      • LordSputnik
        What you want to do, I think, is Object.assign({}, props, {initialState: ...})
      • 2018-01-01 00104, 2018

      • LordSputnik
        the assign applies from left to right. So props is assigned to {}, and then {initialState:...} is applied to the result of that
      • 2018-01-01 00120, 2018

      • naiveai
      • 2018-01-01 00146, 2018

      • LordSputnik
        Let me say that differently :P
      • 2018-01-01 00128, 2018

      • LordSputnik
        If props has an initialState key, the resulting object will have initialState= props.initialState with Object.assign({initialState: ...}, props)
      • 2018-01-01 00125, 2018

      • naiveai
        yes
      • 2018-01-01 00146, 2018

      • LordSputnik
        But in the original context, the last thing to happen to props was that initialState got set, so you want to do Object.assign({}, props, {initialState: ...})
      • 2018-01-01 00149, 2018

      • SothoTalKer
        props to you :D
      • 2018-01-01 00111, 2018

      • LordSputnik
        Which will create a new object, update it with the data from props, and then update the initialState
      • 2018-01-01 00115, 2018

      • naiveai wishes that god kill me soon
      • 2018-01-01 00127, 2018

      • naiveai
        LordSputnik: i think so
      • 2018-01-01 00132, 2018

      • SothoTalKer
        i can do that too, how much do you pay?
      • 2018-01-01 00155, 2018

      • LordSputnik
        This is why spread syntax is so much nicer xD
      • 2018-01-01 00105, 2018

      • naiveai
        SothoTalKer: 0.0000000000000000000000000000000000000000000000000000000000000000001BTC
      • 2018-01-01 00119, 2018

      • SothoTalKer
        i only take real money
      • 2018-01-01 00137, 2018

      • naiveai
        SothoTalKer: $€0.25
      • 2018-01-01 00138, 2018

      • SothoTalKer
        and i can eat you then, right?
      • 2018-01-01 00144, 2018

      • naiveai
        SothoTalKer: sure, whatever
      • 2018-01-01 00102, 2018

      • naiveai
        LordSputnik: seriously, it works. i think it's fine for now
      • 2018-01-01 00107, 2018

      • naiveai
        it's not unreadable