Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleAdd = () => {
const { tableData, table } = this.state;
// 新建的时候如果有栏位是来源于父值的话,对其进行赋值
const newData = TableObject.buildDefaultModel(table.fields, this.props.parentObject);
newData[DefaultRowKey] = uuid.v1();
newData["newFlag"] = true;
this.setState({
tableData: [...tableData, newData],
editingKey: newData.objectRrn,
});
}
export const addTodo = (text, category) => async dispatch => {
try {
const userId = AWS.config.credentials.identityId;
const todo = {
userId,
text,
category,
todoId: uuid.v1(),
completed: false,
creationDate: new Date().getTime(),
};
console.log(todo);
await db
.put({
TableName,
Item: todo,
ConditionExpression: 'attribute_not_exists(id)',
})
.promise();
dispatch(syncTodos());
} catch (err) {
console.log('Add Todo Error');
console.log(err);
if (imageNode === null) {
return Promise.resolve();
}
const { image } = imageNode;
const result = {};
if (Platform.OS === 'ios') {
result.type = mime.lookup(image.filename);
} else {
result.type = imageNode.type;
}
const extension = mime.extension(result.type);
const imagePath = image.uri;
const picName = `${uuid.v1()}.${extension}`;
const key = `${picName}`;
return files.readFile(imagePath)
.then(buffer => Storage.put(key, buffer, { level: 'private', contentType: result.type }))
.then(fileInfo => ({ key: fileInfo.key }))
.then(x => console.log('SAVED', x) || x);
}