Feature / Add loading state to camera app (#200)

* (feat/camera-loading): Add loading state to camera app

* Fix imports + Add timeout

* Use actual function :D
This commit is contained in:
J Francisco Rader authored and GitHub committed 2021-04-10 16:19:25 -03:00
1 parent e1e6e8440d
commit b97cc4102d
10 files changed
+43 -36

No files matched your search

+5 -4
View File
@@ -5,9 +5,10 @@ import { mainLogger } from './sv_logger';
const photoLogger = mainLogger.child({ module: 'photo' });
async function uploadPhoto(identifier: string, image: string) {
async function uploadPhoto(identifier: string, image: string): Promise<IPhoto> {
const query = 'INSERT INTO npwd_phone_gallery (identifier, image) VALUES (?, ?)';
await pool.query(query, [identifier, image]);
const [results] = (await pool.query(query, [identifier, image])) as any;
return { id: results.insertId, image };
}
async function getPhotosByIdentifier(identifier: string): Promise<IPhoto[]> {
@@ -25,8 +26,8 @@ onNet(PhotoEvents.UPLOAD_PHOTO, async (image: string) => {
const _source = getSource();
try {
const identifier = getIdentifier(_source);
await uploadPhoto(identifier, image);
emitNet(PhotoEvents.UPLOAD_PHOTO_SUCCESS, _source);
const photo = await uploadPhoto(identifier, image);
emitNet(PhotoEvents.UPLOAD_PHOTO_SUCCESS, _source, photo);
} catch (e) {
photoLogger.error(`Failed to upload photo, ${e.message}`, {
source: _source,