How to use the timm.setIn function in timm

To help you get started, we’ve selected a few timm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github guigrpa / storyboard / packages / storyboard-extension-chrome / src / reducers / storiesReducer.js View on Github external
if (record.signalType) continue;
    if (record.fStory) {
      const [tempState, pathStr] = rxStory(state, record, options);
      state = tempState;
      if (pathStr) newStories.push(pathStr);
    } else {
      state = rxLog(state, record, options);
    }
  }

  // Don't expand stories that are already closed upon reception
  for (let j = 0, len1 = newStories.length; j < len1; j++) {
    const pathStr = newStories[j];
    const fOpen = timm.getIn(state, (`mainStory/${pathStr}/fOpen`).split('/'));
    if (fOpen) continue;
    state = timm.setIn(state, (`mainStory/${pathStr}/fExpanded`).split('/'), false);
  }
  return state;
};
github guigrpa / storyboard / packages / storyboard-extension-chrome / src / reducers / storiesReducer.js View on Github external
const forgetRecords = (state0, action, settings) => {
  let state = state0;
  const { pathStr } = action;
  const { maxRecords, forgetHysteresis } = settings;
  const path = `mainStory/${pathStr}`.split('/');
  const prevStory = timm.getIn(state, path);
  const { numRecords } = prevStory;
  const targetForget = Math.ceil((numRecords - maxRecords) + (maxRecords * forgetHysteresis));
  const { nextStory, numForgotten, updatedStoryPaths } =
    forgetRecursively(prevStory, targetForget, {}, prevStory.pathStr);
  nextStory.numRecords = numRecords - numForgotten;
  state = timm.setIn(state, path, nextStory);
  const openStories = updateStoryPaths(state.openStories, updatedStoryPaths);
  const closedStories = updateStoryPaths(state.closedStories, updatedStoryPaths);
  state = timm.merge(state, { openStories, closedStories });
  return state;
};
github guigrpa / storyboard / packages / storyboard-extension-chrome / src / reducers / storiesReducer.js View on Github external
const updateStory = (state0, pathStr, record) => {
  let state = state0;
  const { fOpen, title, status, action, storyId } = record;
  const path = `mainStory/${pathStr}`.split('/');
  const prevStory = timm.getIn(state, path);
  const nextStory = timm.merge(prevStory, { fOpen, title, status, lastAction: action });
  state = timm.setIn(state, path, nextStory);
  if (!nextStory.fOpen) {
    state = timm.setIn(state, ['openStories', storyId], undefined);
    state = timm.setIn(state, ['closedStories', storyId], pathStr);
  }
  return state;
};
github ThemeFuse / Brizy / public / editor-src / editor / js / editorComponents / RichText / toolbar / color.js View on Github external
const getPopulationColor = (populationColor, type, value) => {
  if (value.isChanged === "hex") {
    const newValue = setIn(populationColor, [type, "hex"], value.hex);
    return encodeToString(setIn(newValue, [type, "colorPalette"], null));
  }

  if (value.isChanged === "opacity") {
    return encodeToString(
      setIn(populationColor, [type, "opacity"], value.opacity)
    );
  }

  const newValue = setIn(
    populationColor,
    [type, "colorPalette"],
    value.palette
  );
  return encodeToString(setIn(newValue, [type, "hex"], null));
};
github guigrpa / oao / src / addRemoveUpgrade.js View on Github external
Object.keys(nextSpecs[type] || {}).forEach(depName => {
      if (!isLinked(pkgNames, linkPattern, depName)) return;
      let depVersion = targetVersions[depName];
      if (!depVersion && allSpecs[depName]) {
        depVersion = `^${allSpecs[depName].specs.version}`;
      }
      nextSpecs = setIn(nextSpecs, [type, depName], depVersion);
    });
  });
github ThemeFuse / Brizy / public / editor-src / editor / js / editorComponents / RichText / toolbar / color.js View on Github external
const getPopulationColor = (populationColor, type, value) => {
  if (value.isChanged === "hex") {
    const newValue = setIn(populationColor, [type, "hex"], value.hex);
    return encodeToString(setIn(newValue, [type, "colorPalette"], null));
  }

  if (value.isChanged === "opacity") {
    return encodeToString(
      setIn(populationColor, [type, "opacity"], value.opacity)
    );
  }

  const newValue = setIn(
    populationColor,
    [type, "colorPalette"],
    value.palette
  );
  return encodeToString(setIn(newValue, [type, "hex"], null));
};
github ThemeFuse / Brizy / public / editor-src / editor / js / editorComponents / Page / utils / changeValueAfterDND.js View on Github external
const removeIn = (object, [...path]) => {
  let index = path.pop();
  index = Number(index) ? Number(index) : index;
  let newObj = getIn(object, path);
  newObj = removeAt(newObj, index);

  return setIn(object, path, newObj);
};