Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Handle consecutive repetitions
if (fShorthandForDuplicates && !record.fStory) {
const idx = prevRecords.length - 1;
const prevLastRecord = prevRecords[idx];
if (prevLastRecord != null &&
prevLastRecord.msg === record.msg &&
prevLastRecord.src === record.src &&
_.isEqual(prevLastRecord.obj, record.obj)
) {
fDuplicate = true;
const repetitions = prevLastRecord.repetitions || 0;
const nextLastRecord = timm.merge(prevLastRecord, {
repetitions: repetitions + 1,
tLastRepetition: record.t,
});
nextRecords = timm.replaceAt(prevRecords, idx, nextLastRecord);
}
}
// Normal case
if (nextRecords == null) nextRecords = timm.addLast(prevRecords, record);
return nextRecords;
});
onUpdateListItem = (ev: SyntheticEvent) => {
if (!(ev.currentTarget instanceof HTMLInputElement)) return;
const value = ev.currentTarget.value;
const [id, idx] = ev.currentTarget.id.split('.');
const newList = timm.replaceAt(this.state[id], Number(idx), value);
this.setState({ [id]: newList });
};
replaceItem(itemIndex, itemData, meta) {
const itemDataStripped = stripSystemKeys(itemData, { exclude: ["_id"] });
const itemDataWithIds = setIds(itemDataStripped, meta.idOptions);
const dbValue = this.getDBValue() || [];
const updatedValue = replaceAt(dbValue, itemIndex, itemDataWithIds);
this.handleValueChange(updatedValue, {
arrayOperation: "replace",
itemIndex,
oldValue: dbValue
});
}
handleActive = (id, target) => {
const { formFields } = this.state;
const index = formFields.findIndex(({ sourceId }) => sourceId === id);
this.setState({
formFields: replaceAt(formFields, index, { ...formFields[index], target })
});
};
onChange = (inputId, linked) => {
const { app } = this.props;
const { appFields } = this.state;
let newAppFields;
if (app === "wordpress") {
newAppFields = Object.assign({}, appFields, {
[`${inputId}`]: linked
});
} else {
let index = _.indexOf(_.pluck(appFields, "id"), inputId);
const newObj = Object.assign({}, appFields[index], { linked });
newAppFields = replaceAt(appFields, index, newObj);
}
this.setState({
appFields: newAppFields
});
};
handleActive = (id, target) => {
const { formFields } = this.state;
const index = formFields.findIndex(({ sourceId }) => sourceId === id);
this.setState({
formFields: replaceAt(formFields, index, { ...formFields[index], target })
});
};
const prevLangs = this.state.langs;
if (!(ev.currentTarget instanceof HTMLElement)) return;
const idx = Number(ev.currentTarget.id);
let fFound = false;
for (let i = 0; i < prevLangs.length; i++) {
if (i === idx) continue;
if (prevLangs[i] === lang) {
fFound = true;
break;
}
}
if (fFound) {
this.removeLang(idx);
return;
}
const nextLangs = timm.replaceAt(this.state.langs, idx, lang);
this.updateLangs(nextLangs);
};
handleOptionsChange = (value, index) => {
const options = replaceAt(this.props.options, index, value);
this.props.onChange({ options });
};
handleOptionsAdd = () => {