Улучшение протокола, чистка кода
This commit is contained in:
@@ -11,7 +11,6 @@ import { useConsoleLogger } from "@/app/hooks/useConsoleLogger";
|
||||
import { useDialogsCache } from "../DialogProvider/useDialogsCache";
|
||||
import { AttachmentMeta, DialogContext } from "../DialogProvider/DialogProvider";
|
||||
import { useTransportServer } from "../TransportProvider/useTransportServer";
|
||||
import { usePublicKey } from "../AccountProvider/usePublicKey";
|
||||
|
||||
export function usePrepareAttachment() {
|
||||
const intervalsRef = useRef<NodeJS.Timeout>(null);
|
||||
@@ -22,7 +21,6 @@ export function usePrepareAttachment() {
|
||||
const {getDialogCache} = useDialogsCache();
|
||||
const context = useContext(DialogContext);
|
||||
const transportServer = useTransportServer();
|
||||
const publicKey = usePublicKey();
|
||||
|
||||
const updateTimestampInDialogCache = (dialog : string, message_id: string) => {
|
||||
const dialogCache = getDialogCache(dialog);
|
||||
@@ -158,7 +156,7 @@ export function usePrepareAttachment() {
|
||||
* а так же из-за надежности доставки файлов через HTTP
|
||||
* @param attachments Attachments to prepare for sending
|
||||
*/
|
||||
const prepareAttachmentsToSend = async (message_id: string, dialog: string, password: string, attachments : Attachment[], rePrepared : boolean = false) : Promise<Attachment[]> => {
|
||||
const prepareAttachmentsToSend = async (message_id: string, dialog: string, password: string, attachments : Attachment[]) : Promise<Attachment[]> => {
|
||||
if(attachments.length <= 0){
|
||||
return [];
|
||||
}
|
||||
@@ -174,7 +172,7 @@ export function usePrepareAttachment() {
|
||||
continue;
|
||||
}
|
||||
if(attachment.type == AttachmentType.MESSAGES){
|
||||
let reply : MessageReply[] = JSON.parse(attachment.blob)
|
||||
let reply : MessageReply[] = JSON.parse(attachment.blob);
|
||||
for(let j = 0; j < reply.length; j++){
|
||||
for(let k = 0; k < reply[j].attachments.length; k++){
|
||||
reply[j].attachments[k].blob = "";
|
||||
@@ -194,16 +192,6 @@ export function usePrepareAttachment() {
|
||||
const blurhash = await base64ImageToBlurhash(attachment.blob);
|
||||
attachment.preview = blurhash;
|
||||
}
|
||||
// if(rePrepared && (attachment.encoding.encoded_for == dialog || attachment.encoding.encoder == dialog)){
|
||||
// /**
|
||||
// * Это пересланное сообщение и оно уже закодировано для этого диалога, или закодировано отправителем, значит не нужно его кодировать и загружать заново
|
||||
// */
|
||||
// prepared.push({
|
||||
// ...attachment,
|
||||
// blob: ""
|
||||
// });
|
||||
// continue;
|
||||
// }
|
||||
doTimestampUpdateImMessageWhileAttachmentsSend(message_id, dialog);
|
||||
const content = await encodeWithPassword(password, attachment.blob);
|
||||
const upid = attachment.id;
|
||||
@@ -220,10 +208,6 @@ export function usePrepareAttachment() {
|
||||
transport_server: transportServer || "",
|
||||
transport_tag: tag
|
||||
},
|
||||
encoding: {
|
||||
encoded_for: dialog,
|
||||
encoder: publicKey
|
||||
},
|
||||
preview: attachment.preview,
|
||||
blob: ""
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user