mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-06-22 14:38:49 -04:00
* Add typescript parser and fix Flow errors in JS files * Uninstall packages from react-native/eslint-config * Fix all flow errors (or ignore them for unknowns
53 lines
1.0 KiB
JavaScript
53 lines
1.0 KiB
JavaScript
// @flow
|
|
|
|
import inatjs from "inaturalistjs";
|
|
import Comment from "realmModels/Comment";
|
|
|
|
import handleError from "./error";
|
|
|
|
const PARAMS = {
|
|
fields: Comment.COMMENT_FIELDS
|
|
};
|
|
|
|
const createComment = async (
|
|
params: Object = {},
|
|
opts: Object = {}
|
|
): Promise<?Object> => {
|
|
try {
|
|
const { results } = await inatjs.comments.create( { ...PARAMS, ...params }, opts );
|
|
return results;
|
|
} catch ( e ) {
|
|
return handleError( e );
|
|
}
|
|
};
|
|
|
|
const updateComment = async (
|
|
params: Object = {},
|
|
opts: Object = {}
|
|
): Promise<?Object> => {
|
|
try {
|
|
const { results } = await inatjs.comments.update( { ...PARAMS, ...params }, opts );
|
|
return results;
|
|
} catch ( e ) {
|
|
return handleError( e );
|
|
}
|
|
};
|
|
|
|
const deleteComments = async (
|
|
id: number,
|
|
opts: Object = {}
|
|
): Promise<?Object> => {
|
|
try {
|
|
const { results } = await inatjs.comments.delete( { id }, opts );
|
|
return results;
|
|
} catch ( e ) {
|
|
return handleError( e );
|
|
}
|
|
};
|
|
|
|
export {
|
|
createComment,
|
|
deleteComments,
|
|
updateComment
|
|
};
|