mergeObject

Ccalego8/25/2021
mergeObject is a beast of a function which lets you smash two objects together and that options argument lets you control how exactly you want to merge things.

Argument 1: Source Object --> What we are merging into (this is going to be mutated by default)
Argument 2: Mod Object --> What we are applying to the Source

insertKeys [true] -> If the Mod Object has keys in it which the Source does not have, add those keys to the Source object.

insertValues [true] -> If the Source Object's values are objects themselves, this controls whether to merge those values as part of this operation (kind of discount recursive)


So for your case:
mergeObject(defaultValues, clientSettingsValues, {
  insertKeys: false,
  insertValues: false,
});

Where defaultValues is the setting's default, and the clientSettingsValues is the current setting value.

This would take the baseline default value and overwrite any existing key/value, but not merge value objects (instead, it would replace them). It'll overwrite because the overwrite option is true by default.
Ccalego8/25/2021
@Mouse0270 what are you up to that isn't workin?
UUUnknown User8/25/2021
5 Messages Not Public
Sign In & Join Server To View
Ccalego8/25/2021
aye
Ccalego8/25/2021
First one is defaultValues
Second one is clientSettingsValues
?
UUUnknown User8/25/2021
2 Messages Not Public
Sign In & Join Server To View
Ccalego8/25/2021
so far this is my understanding as well
UUUnknown User8/25/2021
Message Not Public
Sign In & Join Server To View
Ccalego8/25/2021
let me guess, you're seeing square-corners in theme
Ccalego8/25/2021
balls
Ccalego8/25/2021
try adding: recursive: false
UUUnknown User8/25/2021
2 Messages Not Public
Sign In & Join Server To View
Ccalego8/25/2021
ok, we're going off the rails here, can you remove the -- from the start of each key?
UUUnknown User8/25/2021
Message Not Public
Sign In & Join Server To View
Ccalego8/25/2021
ok good (bad but not super bad)
UUUnknown User8/25/2021
4 Messages Not Public
Sign In & Join Server To View
Ccalego8/25/2021
wuuuut
Ccalego8/25/2021
You've just hit "escalate to #dev-support on the mothership" territory
UUUnknown User8/25/2021
2 Messages Not Public
Sign In & Join Server To View
Ccalego8/25/2021
One more thing to try, clone the object first, then don't do inplace: false
UUUnknown User8/25/2021
Message Not Public
Sign In & Join Server To View
Ccalego8/25/2021
(hollering about that, which module did you release under your name again?)
UUUnknown User8/25/2021
Message Not Public
Sign In & Join Server To View
Ccalego8/25/2021
👍
UUUnknown User8/25/2021
Message Not Public
Sign In & Join Server To View
Ccalego8/25/2021
something's real off
Ccalego8/25/2021
because if this doesn't work, that's got some big implications
UUUnknown User8/25/2021
Message Not Public
Sign In & Join Server To View
Ccalego8/25/2021
norc hooked you up with the right role
Ccalego8/25/2021
you should be able to post now
Ccalego8/25/2021
@Mouse0270 I'd suggest using a minimal reproduction case to keep that channel clean 🙂
UUUnknown User8/25/2021
Message Not Public
Sign In & Join Server To View
Ccalego8/25/2021
awesome
Ccalego8/25/2021
thanks @Mouse0270
Sorry I couldn't get you sorted. I'm hoping this is something stupid we're both missing.
LTLLLeo The League Lion8/25/2021
@Calego gave :vote: LeaguePoints™ to @Mouse0270 (#40 • 43)
UUUnknown User8/25/2021
2 Messages Not Public
Sign In & Join Server To View
Ccalego8/25/2021
that only activates if recursive: true though
Ccalego8/25/2021
(or should)
UUUnknown User8/25/2021
2 Messages Not Public
Sign In & Join Server To View
Ccalego8/25/2021
what in tarnation
UUUnknown User8/25/2021
2 Messages Not Public
Sign In & Join Server To View
Ccalego8/25/2021
you could try putting a breakpoint on it and step through to see where it's going wrong
Ccalego8/25/2021
in a meeting but I'll see if I can after
UUUnknown User8/25/2021
Message Not Public
Sign In & Join Server To View
Ccalego8/25/2021
I understand you now, ugh
Ccalego8/25/2021
where's that emoji...
Ccalego8/25/2021
:codyunderthebus:
UUUnknown User8/25/2021
Message Not Public
Sign In & Join Server To View
Ccalego8/25/2021
Don't libwrap mergeObject, better to DIY it or work around.
There's the off chance that something is relying on this behavior and mergeObject is so prolific in the foundry core that patching it is likely to cause gods knows what issues
Ccalego8/25/2021
if this is a bug, that sucks
Ccalego8/25/2021
But, right now is the perfect time to find it, as it can get fixed in V9 prototype phase
UUUnknown User8/25/2021
5 Messages Not Public
Sign In & Join Server To View