fix: resolve non-null assertion linting in Reader and add null check for fabricRef in ComposeCanvas

This commit is contained in:
ramvignesh-b
2026-04-15 17:57:18 +05:30
parent 198f9c32dd
commit 8f6fd6a529
2 changed files with 9 additions and 4 deletions
@@ -401,6 +401,8 @@ export const ComposeCanvas = forwardRef<
fabricRef.current?.add(img); fabricRef.current?.add(img);
fabricRef.current?.setActiveObject(img); fabricRef.current?.setActiveObject(img);
if (!fabricRef.current) return;
logicalSizeRef.current.height = measureLogicalContentHeight( logicalSizeRef.current.height = measureLogicalContentHeight(
fabricRef.current, fabricRef.current,
logicalSizeRef.current.height, logicalSizeRef.current.height,
+7 -4
View File
@@ -69,7 +69,8 @@ export default function Reader() {
) )
: await cryptoUtils.decryptMetadata( : await cryptoUtils.decryptMetadata(
{ encrypted_content: encrypted_metadata, encrypted_dek }, { encrypted_content: encrypted_metadata, encrypted_dek },
masterKey, // biome-ignore lint/style/noNonNullAssertion: masterKey is guaranteed to be non-null here as isDecryptionKeyAvailable is true
masterKey!,
); );
setMetadata(decryptedMetadata as LetterMetadata); setMetadata(decryptedMetadata as LetterMetadata);
@@ -81,7 +82,8 @@ export default function Reader() {
) )
: await cryptoUtils.decryptLetter( : await cryptoUtils.decryptLetter(
{ encrypted_content, encrypted_dek }, { encrypted_content, encrypted_dek },
masterKey, // biome-ignore lint/style/noNonNullAssertion: masterKey is guaranteed to be non-null here as isDecryptionKeyAvailable is true
masterKey!,
); );
const canvasData: CanvasJSON = JSON.parse(decryptedContent); const canvasData: CanvasJSON = JSON.parse(decryptedContent);
@@ -100,7 +102,8 @@ export default function Reader() {
canvasData, canvasData,
images, images,
encrypted_dek, encrypted_dek,
masterKey, // biome-ignore lint/style/noNonNullAssertion: masterKey is guaranteed to be non-null here as isDecryptionKeyAvailable is true
masterKey!,
cryptoUtils, cryptoUtils,
); );
} }
@@ -108,7 +111,7 @@ export default function Reader() {
setWarning({ setWarning({
message: message:
"Failed to decrypt elements. Images might not render in the letter as intended.", "Failed to decrypt elements. Images might not render in the letter as intended.",
log: err, log: err instanceof Error ? err.message : "Unknown error",
}); });
} }