Оптимизирован код вложений, исправлена установка аватарки на диалог, а не у отправителя

This commit is contained in:
RoyceDa
2026-02-20 17:43:56 +02:00
parent db72246e5a
commit c64a7005d3
6 changed files with 22 additions and 17 deletions

View File

@@ -7,7 +7,15 @@ import { useConsoleLogger } from "@/app/hooks/useConsoleLogger";
import { useSystemAccounts } from "../SystemAccountsProvider/useSystemAccounts";
import { AVATAR_PASSWORD_TO_ENCODE } from "@/app/constants";
export const AvatarContext = createContext({});
export interface AvatarProviderContextValue {
deliveredAvatars: string[];
saveAvatar: (fromPublicKey: string, path : string, decryptedContent : string) => Promise<void>;
loadAvatarsFromCacheByPublicKey: (publicKey : string, allDecode? : boolean) => Promise<void>;
changeAvatar: (base64Image : string, entity : string) => Promise<void>;
decodedAvatarsCache: AvatarCacheEntry[];
}
export const AvatarContext = createContext<AvatarProviderContextValue | null>(null);
interface AvatarProviderProps {
children: React.ReactNode;

View File

@@ -1,9 +1,9 @@
import { useContext } from "react";
import { AvatarContext } from "./AvatarProvider";
export function useSaveAvatar() {
export function useSaveAvatar() : (fromPublicKey: string, path : string, decryptedContent : string) => Promise<void> {
const context : any = useContext(AvatarContext);
if(!context){
if(!context){
throw new Error("useSaveAvatar must be used within an AvatarProvider");
}
return context.saveAvatar;