Оптимизирован код вложений, исправлена установка аватарки на диалог, а не у отправителя
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user