Исправление нестабильности HTTP соединения
This commit is contained in:
@@ -17,7 +17,7 @@ export function usePrepareAttachment() {
|
||||
const {uploadFile} = useTransport();
|
||||
const {updateDialog} = useDialogsList();
|
||||
const {runQuery, getQuery} = useDatabase();
|
||||
const {info} = useConsoleLogger('usePrepareAttachment');
|
||||
const {info, error} = useConsoleLogger('usePrepareAttachment');
|
||||
const {getDialogCache} = useDialogsCache();
|
||||
const context = useContext(DialogContext);
|
||||
const transportServer = useTransportServer();
|
||||
@@ -197,11 +197,19 @@ export function usePrepareAttachment() {
|
||||
const upid = attachment.id;
|
||||
info(`Uploading attachment with upid: ${upid}`);
|
||||
info(`Attachment content length: ${content.length}`);
|
||||
let tag = await uploadFile(upid, content);
|
||||
info(`Uploaded attachment with upid: ${upid}, received tag: ${tag}`);
|
||||
if(intervalsRef.current != null){
|
||||
clearInterval(intervalsRef.current);
|
||||
let tag = await uploadFile(upid, content).catch(() => {
|
||||
error(`Network error while uploading attachment ${upid}`);
|
||||
});
|
||||
if(!tag){
|
||||
/**
|
||||
* При ошибке загрузки по сети
|
||||
*/
|
||||
stopUpdateTimeInUpAttachment();
|
||||
console.info("stop upd")
|
||||
continue;
|
||||
}
|
||||
info(`Uploaded attachment with upid: ${upid}, received tag: ${tag}`);
|
||||
stopUpdateTimeInUpAttachment();
|
||||
const preparedAttachment : Attachment = {
|
||||
...attachment,
|
||||
transport: {
|
||||
@@ -220,6 +228,12 @@ export function usePrepareAttachment() {
|
||||
}
|
||||
}
|
||||
|
||||
const stopUpdateTimeInUpAttachment = () => {
|
||||
if(intervalsRef.current != null){
|
||||
clearInterval(intervalsRef.current);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
prepareAttachmentsToSend
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user