[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;
|
rid?: string;
|
||||||
path: string;
|
path: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
|
tmid?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
size: number;
|
size: number;
|
||||||
type?: string;
|
type?: string;
|
||||||
|
|
|
@ -16,6 +16,8 @@ export default class Upload extends Model {
|
||||||
|
|
||||||
@field('name') name;
|
@field('name') name;
|
||||||
|
|
||||||
|
@field('tmid') tmid;
|
||||||
|
|
||||||
@field('description') description;
|
@field('description') description;
|
||||||
|
|
||||||
@field('size') size;
|
@field('size') size;
|
||||||
|
|
|
@ -239,6 +239,15 @@ export default schemaMigrations({
|
||||||
columns: [{ name: 'hide_mention_status', type: 'boolean', isOptional: true }]
|
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';
|
import { appSchema, tableSchema } from '@nozbe/watermelondb';
|
||||||
|
|
||||||
export default appSchema({
|
export default appSchema({
|
||||||
version: 18,
|
version: 19,
|
||||||
tables: [
|
tables: [
|
||||||
tableSchema({
|
tableSchema({
|
||||||
name: 'subscriptions',
|
name: 'subscriptions',
|
||||||
|
@ -222,6 +222,7 @@ export default appSchema({
|
||||||
{ name: 'path', type: 'string', isOptional: true },
|
{ name: 'path', type: 'string', isOptional: true },
|
||||||
{ name: 'rid', type: 'string', isIndexed: true },
|
{ name: 'rid', type: 'string', isIndexed: true },
|
||||||
{ name: 'name', type: 'string', isOptional: true },
|
{ name: 'name', type: 'string', isOptional: true },
|
||||||
|
{ name: 'tmid', type: 'string', isOptional: true },
|
||||||
{ name: 'description', type: 'string', isOptional: true },
|
{ name: 'description', type: 'string', isOptional: true },
|
||||||
{ name: 'size', type: 'number' },
|
{ name: 'size', type: 'number' },
|
||||||
{ name: 'type', type: 'string', isOptional: true },
|
{ name: 'type', type: 'string', isOptional: true },
|
||||||
|
|
|
@ -46,7 +46,8 @@ export function sendFileMessage(
|
||||||
fileInfo: IUpload,
|
fileInfo: IUpload,
|
||||||
tmid: string | undefined,
|
tmid: string | undefined,
|
||||||
server: string,
|
server: string,
|
||||||
user: Partial<Pick<IUser, 'id' | 'token'>>
|
user: Partial<Pick<IUser, 'id' | 'token'>>,
|
||||||
|
isForceTryAgain?: boolean
|
||||||
): Promise<FetchBlobResponse | void> {
|
): Promise<FetchBlobResponse | void> {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
|
@ -62,7 +63,7 @@ export function sendFileMessage(
|
||||||
let uploadRecord: TUploadModel;
|
let uploadRecord: TUploadModel;
|
||||||
try {
|
try {
|
||||||
uploadRecord = await uploadsCollection.find(uploadPath);
|
uploadRecord = await uploadsCollection.find(uploadPath);
|
||||||
if (uploadRecord.id) {
|
if (uploadRecord.id && !isForceTryAgain) {
|
||||||
return Alert.alert(i18n.t('FileUpload_Error'), i18n.t('Upload_in_progress'));
|
return Alert.alert(i18n.t('FileUpload_Error'), i18n.t('Upload_in_progress'));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -71,6 +72,9 @@ export function sendFileMessage(
|
||||||
uploadRecord = await uploadsCollection.create(u => {
|
uploadRecord = await uploadsCollection.create(u => {
|
||||||
u._raw = sanitizedRaw({ id: uploadPath }, uploadsCollection.schema);
|
u._raw = sanitizedRaw({ id: uploadPath }, uploadsCollection.schema);
|
||||||
Object.assign(u, fileInfo);
|
Object.assign(u, fileInfo);
|
||||||
|
if (tmid) {
|
||||||
|
u.tmid = tmid;
|
||||||
|
}
|
||||||
if (u.subscription) {
|
if (u.subscription) {
|
||||||
u.subscription.id = rid;
|
u.subscription.id = rid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,7 @@ class UploadProgress extends Component<IUploadProgressProps, IUploadProgressStat
|
||||||
item.error = false;
|
item.error = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
await sendFileMessage(rid, item, undefined, server, user);
|
await sendFileMessage(rid, item, item.tmid, server, user, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e);
|
log(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue