Skip to content

Commit 18fe2b0

Browse files
committed
fix(mobile): improve GlassView compatibility and decryption performance
1 parent cce32e1 commit 18fe2b0

File tree

3 files changed

+39
-22
lines changed

3 files changed

+39
-22
lines changed

apps/mobile/v1/src/screens/FolderNotes/components/NotesList/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,14 +756,13 @@ export default function NotesList({ navigation, route, renderHeader, scrollY: pa
756756
/>
757757

758758
{/* Floating Action Button - Only visible when Create Note button scrolls off screen */}
759-
{viewType !== 'trash' && (
759+
{viewType !== 'trash' && isCreateNoteButtonOffScreen && (
760760
<Animated.View
761761
style={[
762762
styles.fab,
763763
{
764764
bottom: insets.bottom + 20,
765765
right: 20,
766-
opacity: fabOpacity,
767766
transform: [{ translateY: fabTranslateY }],
768767
}
769768
]}

apps/mobile/v1/src/screens/ViewNote/ViewHeader.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ export function ViewHeader({
8888
</TouchableOpacity>
8989
</GlassView>
9090

91-
<Animated.View style={[styles.glassTitleButton, { opacity: titleOpacity }]}>
92-
<GlassView glassEffectStyle="regular" style={{ flex: 1, borderRadius: 19, overflow: 'hidden', backgroundColor: theme.isDark ? 'rgba(255, 255, 255, 0.01)' : 'rgba(0, 0, 0, 0.01)' }}>
91+
<View style={styles.glassTitleButton}>
92+
<GlassView glassEffectStyle="regular" style={{ flex: 1, borderRadius: 19, overflow: 'hidden' }}>
9393
<View style={styles.titleButton}>
9494
<Text
9595
style={[styles.headerTitle, { color: theme.colors.foreground }]}
@@ -100,7 +100,7 @@ export function ViewHeader({
100100
</Text>
101101
</View>
102102
</GlassView>
103-
</Animated.View>
103+
</View>
104104

105105
<View style={styles.headerActions}>
106106
{attachmentsCount > 0 && (

apps/mobile/v1/src/services/api/encryption.ts

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,13 @@ export async function decryptNote(note: Note, userId: string): Promise<Note> {
4747
}
4848
}
4949

50+
// Yield to main thread to prevent UI blocking
51+
const yieldToMain = (): Promise<void> => {
52+
return new Promise(resolve => setTimeout(resolve, 0));
53+
};
54+
5055
/**
51-
* Decrypts an array of notes
56+
* Decrypts an array of notes in batches to prevent UI blocking
5257
*/
5358
export async function decryptNotes(
5459
notes: Note[],
@@ -61,22 +66,35 @@ export async function decryptNotes(
6166
const decryptStart = performance.now();
6267
console.log(`[PERF] Starting decryption of ${notes.length} notes...`);
6368

69+
const BATCH_SIZE = 10; // Process 10 notes at a time
70+
const result: Note[] = [];
71+
6472
try {
65-
// Decrypt notes individually to handle failures gracefully
66-
const result = await Promise.all(
67-
notes.map(async (note) => {
68-
try {
69-
return await decryptNote(note, userId);
70-
} catch {
71-
// Return note with fallback content if decryption fails
72-
return {
73-
...note,
74-
title: note.title || '[Encrypted - Unable to decrypt]',
75-
content: note.content || '[This note could not be decrypted]',
76-
};
77-
}
78-
})
79-
);
73+
// Process notes in batches to prevent UI blocking
74+
for (let i = 0; i < notes.length; i += BATCH_SIZE) {
75+
const batch = notes.slice(i, i + BATCH_SIZE);
76+
77+
const decryptedBatch = await Promise.all(
78+
batch.map(async (note) => {
79+
try {
80+
return await decryptNote(note, userId);
81+
} catch {
82+
return {
83+
...note,
84+
title: note.title || '[Encrypted - Unable to decrypt]',
85+
content: note.content || '[This note could not be decrypted]',
86+
};
87+
}
88+
})
89+
);
90+
91+
result.push(...decryptedBatch);
92+
93+
// Yield to main thread between batches to keep UI responsive
94+
if (i + BATCH_SIZE < notes.length) {
95+
await yieldToMain();
96+
}
97+
}
8098

8199
const decryptEnd = performance.now();
82100
console.log(`[PERF] Decryption completed in ${(decryptEnd - decryptStart).toFixed(2)}ms for ${notes.length} notes`);
@@ -86,7 +104,7 @@ export async function decryptNotes(
86104
if (__DEV__) {
87105
console.error('Error during note decryption batch:', error);
88106
}
89-
return notes; // Return original notes if batch decryption fails
107+
return notes;
90108
}
91109
}
92110

0 commit comments

Comments
 (0)