[FIX] Try again to resend a file on a thread (#4756)
This commit is contained in:
parent
0b5dab3ddf
commit
68066d487f
|
@ -5,6 +5,7 @@ export interface IUpload {
|
|||
rid?: string;
|
||||
path: string;
|
||||
name?: string;
|
||||
tmid?: string;
|
||||
description?: string;
|
||||
size: number;
|
||||
type?: string;
|
||||
|
|
|
@ -16,6 +16,8 @@ export default class Upload extends Model {
|
|||
|
||||
@field('name') name;
|
||||
|
||||
@field('tmid') tmid;
|
||||
|
||||
@field('description') description;
|
||||
|
||||
@field('size') size;
|
||||
|
|
|
@ -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 }]
|
||||
})
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
|
|
@ -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 },
|
||||
|
|
|
@ -46,7 +46,8 @@ export function sendFileMessage(
|
|||
fileInfo: IUpload,
|
||||
tmid: string | undefined,
|
||||
server: string,
|
||||
user: Partial<Pick<IUser, 'id' | 'token'>>
|
||||
user: Partial<Pick<IUser, 'id' | 'token'>>,
|
||||
isForceTryAgain?: boolean
|
||||
): Promise<FetchBlobResponse | void> {
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ class UploadProgress extends Component<IUploadProgressProps, IUploadProgressStat
|
|||
item.error = false;
|
||||
});
|
||||
});
|
||||
await sendFileMessage(rid, item, undefined, server, user);
|
||||
await sendFileMessage(rid, item, item.tmid, server, user, true);
|
||||
} catch (e) {
|
||||
log(e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue