From 68066d487f25da5236cc32eb296584b555f828d2 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Wed, 21 Dec 2022 14:34:48 -0300 Subject: [PATCH] [FIX] Try again to resend a file on a thread (#4756) --- app/definitions/IUpload.ts | 1 + app/lib/database/model/Upload.js | 2 ++ app/lib/database/model/migrations.js | 9 +++++++++ app/lib/database/schema/app.js | 3 ++- app/lib/methods/sendFileMessage.ts | 8 ++++++-- app/views/RoomView/UploadProgress.tsx | 2 +- 6 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/definitions/IUpload.ts b/app/definitions/IUpload.ts index 05955513..52d3c199 100644 --- a/app/definitions/IUpload.ts +++ b/app/definitions/IUpload.ts @@ -5,6 +5,7 @@ export interface IUpload { rid?: string; path: string; name?: string; + tmid?: string; description?: string; size: number; type?: string; diff --git a/app/lib/database/model/Upload.js b/app/lib/database/model/Upload.js index d03a8772..a96e2c99 100644 --- a/app/lib/database/model/Upload.js +++ b/app/lib/database/model/Upload.js @@ -16,6 +16,8 @@ export default class Upload extends Model { @field('name') name; + @field('tmid') tmid; + @field('description') description; @field('size') size; diff --git a/app/lib/database/model/migrations.js b/app/lib/database/model/migrations.js index aacbd590..3a5374e5 100644 --- a/app/lib/database/model/migrations.js +++ b/app/lib/database/model/migrations.js @@ -239,6 +239,15 @@ export default schemaMigrations({ columns: [{ name: 'hide_mention_status', type: 'boolean', isOptional: true }] }) ] + }, + { + toVersion: 19, + steps: [ + addColumns({ + table: 'uploads', + columns: [{ name: 'tmid', type: 'string', isOptional: true }] + }) + ] } ] }); diff --git a/app/lib/database/schema/app.js b/app/lib/database/schema/app.js index 6380084a..f354b34e 100644 --- a/app/lib/database/schema/app.js +++ b/app/lib/database/schema/app.js @@ -1,7 +1,7 @@ import { appSchema, tableSchema } from '@nozbe/watermelondb'; export default appSchema({ - version: 18, + version: 19, tables: [ tableSchema({ name: 'subscriptions', @@ -222,6 +222,7 @@ export default appSchema({ { name: 'path', type: 'string', isOptional: true }, { name: 'rid', type: 'string', isIndexed: true }, { name: 'name', type: 'string', isOptional: true }, + { name: 'tmid', type: 'string', isOptional: true }, { name: 'description', type: 'string', isOptional: true }, { name: 'size', type: 'number' }, { name: 'type', type: 'string', isOptional: true }, diff --git a/app/lib/methods/sendFileMessage.ts b/app/lib/methods/sendFileMessage.ts index dbbe6317..08033cb6 100644 --- a/app/lib/methods/sendFileMessage.ts +++ b/app/lib/methods/sendFileMessage.ts @@ -46,7 +46,8 @@ export function sendFileMessage( fileInfo: IUpload, tmid: string | undefined, server: string, - user: Partial> + user: Partial>, + isForceTryAgain?: boolean ): Promise { return new Promise(async (resolve, reject) => { try { @@ -62,7 +63,7 @@ export function sendFileMessage( let uploadRecord: TUploadModel; try { uploadRecord = await uploadsCollection.find(uploadPath); - if (uploadRecord.id) { + if (uploadRecord.id && !isForceTryAgain) { return Alert.alert(i18n.t('FileUpload_Error'), i18n.t('Upload_in_progress')); } } catch (error) { @@ -71,6 +72,9 @@ export function sendFileMessage( uploadRecord = await uploadsCollection.create(u => { u._raw = sanitizedRaw({ id: uploadPath }, uploadsCollection.schema); Object.assign(u, fileInfo); + if (tmid) { + u.tmid = tmid; + } if (u.subscription) { u.subscription.id = rid; } diff --git a/app/views/RoomView/UploadProgress.tsx b/app/views/RoomView/UploadProgress.tsx index 2509870c..6c78ef20 100644 --- a/app/views/RoomView/UploadProgress.tsx +++ b/app/views/RoomView/UploadProgress.tsx @@ -160,7 +160,7 @@ class UploadProgress extends Component