Optimize profile avatar uploads and sync urls
This commit is contained in:
parent
703bb8a3a3
commit
36ce4f27a2
15 changed files with 147 additions and 77 deletions
|
@ -10,11 +10,12 @@ import {
|
|||
encryptProfile,
|
||||
encryptProfileItemWithPadding,
|
||||
} from '../Crypto';
|
||||
import type { AvatarUpdateType } from '../types/Avatar';
|
||||
import { deriveProfileKeyCommitment, deriveProfileKeyVersion } from './zkgroup';
|
||||
|
||||
export async function encryptProfileData(
|
||||
conversation: ConversationType,
|
||||
avatarBuffer?: Uint8Array
|
||||
{ oldAvatar, newAvatar }: AvatarUpdateType
|
||||
): Promise<[ProfileRequestDataType, Uint8Array | undefined]> {
|
||||
const {
|
||||
aboutEmoji,
|
||||
|
@ -55,10 +56,12 @@ export async function encryptProfileData(
|
|||
)
|
||||
: null;
|
||||
|
||||
const encryptedAvatarData = avatarBuffer
|
||||
? encryptProfile(avatarBuffer, keyBuffer)
|
||||
const encryptedAvatarData = newAvatar
|
||||
? encryptProfile(newAvatar, keyBuffer)
|
||||
: undefined;
|
||||
|
||||
const sameAvatar = Bytes.areEqual(oldAvatar, newAvatar);
|
||||
|
||||
const profileData = {
|
||||
version: deriveProfileKeyVersion(profileKey, uuid),
|
||||
name: Bytes.toBase64(bytesName),
|
||||
|
@ -66,7 +69,8 @@ export async function encryptProfileData(
|
|||
aboutEmoji: bytesAboutEmoji ? Bytes.toBase64(bytesAboutEmoji) : null,
|
||||
badgeIds: (badges || []).map(({ id }) => id),
|
||||
paymentAddress: window.storage.get('paymentAddress') || null,
|
||||
avatar: Boolean(avatarBuffer),
|
||||
avatar: Boolean(newAvatar),
|
||||
sameAvatar,
|
||||
commitment: deriveProfileKeyCommitment(profileKey, uuid),
|
||||
};
|
||||
|
||||
|
|
|
@ -7226,13 +7226,6 @@
|
|||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-05-05T23:11:22.692Z"
|
||||
},
|
||||
{
|
||||
"rule": "React-useRef",
|
||||
"path": "ts/components/AvatarPreview.tsx",
|
||||
"line": " const startingAvatarPathRef = useRef<undefined | string>(",
|
||||
"reasonCategory": "usageTrusted",
|
||||
"updated": "2021-08-03T21:17:38.615Z"
|
||||
},
|
||||
{
|
||||
"rule": "React-useRef",
|
||||
"path": "ts/components/AvatarTextEditor.tsx",
|
||||
|
@ -8079,4 +8072,4 @@
|
|||
"reasonCategory": "usageTrusted",
|
||||
"updated": "2021-09-17T21:02:59.414Z"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue