Новый протокол кодирования и декодирования вложений
This commit is contained in:
@@ -11,6 +11,7 @@ import { useConsoleLogger } from "@/app/hooks/useConsoleLogger";
|
||||
import { useDialogsCache } from "../DialogProvider/useDialogsCache";
|
||||
import { DialogContext } from "../DialogProvider/DialogProvider";
|
||||
import { useTransportServer } from "../TransportProvider/useTransportServer";
|
||||
import { usePublicKey } from "../AccountProvider/usePublicKey";
|
||||
|
||||
export function usePrepareAttachment() {
|
||||
const intervalsRef = useRef<NodeJS.Timeout>(null);
|
||||
@@ -21,6 +22,7 @@ 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);
|
||||
@@ -117,9 +119,9 @@ export function usePrepareAttachment() {
|
||||
const blurhash = await base64ImageToBlurhash(attachment.blob);
|
||||
attachment.preview = blurhash;
|
||||
}
|
||||
if(rePrepared && attachment.encoded_for == dialog){
|
||||
if(rePrepared && (attachment.encoding.encoded_for == dialog || attachment.encoding.encoder == dialog)){
|
||||
/**
|
||||
* Это пересланное сообщение и оно уже закодировано для этого диалога, значит не нужно его кодировать и загружать заново
|
||||
* Это пересланное сообщение и оно уже закодировано для этого диалога, или закодировано отправителем, значит не нужно его кодировать и загружать заново
|
||||
*/
|
||||
prepared.push({
|
||||
...attachment,
|
||||
@@ -141,7 +143,10 @@ export function usePrepareAttachment() {
|
||||
...attachment,
|
||||
transport_server: transportServer || "",
|
||||
transport_tag: tag,
|
||||
encoded_for: dialog,
|
||||
encoding: {
|
||||
encoded_for: dialog,
|
||||
encoder: publicKey
|
||||
},
|
||||
preview: attachment.preview,
|
||||
blob: ""
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user