diff --git a/app/definitions/IUpload.ts b/app/definitions/IUpload.ts index 059555130..52d3c1995 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 d03a87729..a96e2c995 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 aacbd5903..3a5374e56 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 6380084af..f354b34eb 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 dbbe6317e..08033cb60 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 2509870c9..6c78ef204 100644 --- a/app/views/RoomView/UploadProgress.tsx +++ b/app/views/RoomView/UploadProgress.tsx @@ -160,7 +160,7 @@ class UploadProgress extends Component