Skip to content

Commit 08e64ea

Browse files
committed
fix(mobile): resolve master password stuck button and improve editor toolbar
- Add strikethrough and highlighter buttons to editor toolbar - Install lucide-react-native for consistent icons across platforms - Fix master password button stuck after logout/login by: - Adding key prop to force component remount on userId change - Awaiting handleSubmit in onPress handler - Resetting loading state on component mount - Change decryption error logging from console.error to console.log
1 parent 10bfd91 commit 08e64ea

File tree

6 files changed

+187
-9
lines changed

6 files changed

+187
-9
lines changed

apps/mobile/v1/package-lock.json

Lines changed: 157 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/mobile/v1/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"expo-symbols": "~1.0.7",
3737
"expo-system-ui": "~6.0.7",
3838
"expo-web-browser": "~15.0.7",
39+
"lucide-react-native": "^0.545.0",
3940
"newrelic-react-native-agent": "^1.5.10",
4041
"node-forge": "^1.3.1",
4142
"react": "19.1.0",

apps/mobile/v1/src/components/AppWrapper.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export const AppWrapper: React.FC<AppWrapperProps> = ({ children }) => {
8383
if (needsUnlock) {
8484
return (
8585
<MasterPasswordScreen
86+
key={userId} // Force remount when userId changes to reset all state
8687
userId={userId || ''}
8788
isNewSetup={isNewSetup}
8889
onSuccess={onPasswordSuccess}

apps/mobile/v1/src/components/MasterPasswordDialog/MasterPasswordForm.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useRef } from 'react';
1+
import React, { useState, useRef, useEffect } from 'react';
22
import {
33
View,
44
Text,
@@ -43,6 +43,12 @@ export function MasterPasswordForm({
4343
setPasswordError,
4444
} = usePasswordValidation();
4545

46+
// Reset loading state when component mounts
47+
// This fixes the stuck button issue after logout/login
48+
useEffect(() => {
49+
setIsLoading(false);
50+
}, []);
51+
4652
const handleSubmit = async () => {
4753
// Validate passwords
4854
const validation = validatePasswords(password, confirmPassword, isNewSetup);
@@ -199,7 +205,7 @@ export function MasterPasswordForm({
199205
// Small delay to allow UI to render the loading state before blocking computation
200206
await new Promise((resolve) => setTimeout(resolve, 100));
201207

202-
handleSubmit();
208+
await handleSubmit();
203209
}}
204210
disabled={isLoading}
205211
activeOpacity={0.7}

apps/mobile/v1/src/screens/EditNote/EditorToolbar.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { View, Text, StyleSheet, TouchableOpacity, ScrollView } from 'react-native';
33
import { Ionicons } from '@expo/vector-icons';
4+
import { Highlighter } from 'lucide-react-native';
45
import type { EditorBridge } from '@10play/tentap-editor';
56

67
interface EditorToolbarProps {
@@ -52,6 +53,20 @@ export function EditorToolbar({ editor, keyboardHeight, theme }: EditorToolbarPr
5253
<Text style={[styles.toolbarButtonText, { color: theme.colors.foreground, textDecorationLine: 'underline' }]}>U</Text>
5354
</TouchableOpacity>
5455

56+
<TouchableOpacity
57+
onPress={() => editor.toggleStrike()}
58+
style={styles.toolbarButton}
59+
>
60+
<Text style={[styles.toolbarButtonText, { color: theme.colors.foreground, textDecorationLine: 'line-through' }]}>S</Text>
61+
</TouchableOpacity>
62+
63+
<TouchableOpacity
64+
onPress={() => editor.toggleHighlight('#FFFF00')}
65+
style={styles.toolbarButton}
66+
>
67+
<Highlighter size={18} color={theme.colors.foreground} />
68+
</TouchableOpacity>
69+
5570
<View style={[styles.toolbarDivider, { backgroundColor: theme.colors.border }]} />
5671

5772
<TouchableOpacity
@@ -125,14 +140,14 @@ const styles = StyleSheet.create({
125140
toolbarButtons: {
126141
flexDirection: 'row',
127142
alignItems: 'center',
128-
justifyContent: 'space-between',
129-
flex: 1,
143+
gap: 4,
144+
paddingHorizontal: 4,
130145
},
131146
toolbarButton: {
132-
paddingHorizontal: 6,
147+
paddingHorizontal: 12,
133148
paddingVertical: 8,
134149
borderRadius: 4,
135-
flex: 1,
150+
minWidth: 40,
136151
alignItems: 'center',
137152
justifyContent: 'center',
138153
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function decryptNote(note: Note, userId: string): Promise<Note> {
3636
};
3737
} catch (error) {
3838
if (__DEV__) {
39-
console.error('Failed to decrypt note:', note.id, error);
39+
console.log('Failed to decrypt note (likely wrong master password):', note.id);
4040
}
4141
// Return note with placeholder content if decryption fails
4242
return {

0 commit comments

Comments
 (0)