Skip to content

Commit

Permalink
use uniqByIContacts in onContactsChanged event (#265)
Browse files Browse the repository at this point in the history
* use uniqByIContacts in onContactsChanged event

* use uniq instead of uniqByIContacts

* add nostr issue popup

* add contacts options in setings

* update translations, update nostr data check
  • Loading branch information
KKA11010 authored Nov 21, 2023
1 parent 04f6018 commit 9679a39
Show file tree
Hide file tree
Showing 16 changed files with 162 additions and 52 deletions.
7 changes: 5 additions & 2 deletions assets/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"delHistoryQ": "Verlauf löschen?",
"resetQ": "Wallet zurücksetzen?",
"delHistoryTxt": "Die Daten können nachträglich nicht wiederhergestellt werden.",
"plsRestart": "Bitte starten Sie die App neu",
"disclaimer": "Haftungsausschluss",
"ecashPayment": "Ecash Zahlung",
"english": "Englisch",
Expand Down Expand Up @@ -211,7 +210,11 @@
"zap": "Zap",
"zapNow": "Zap",
"meltNostrProfileHint": "Senden Sie Ihr Guthaben zu der LN-Adresse, die mit Ihrem Nostr-Profil verknüpft ist.",
"nostrDmHint": "eNuts kann nicht auf Ihre Nostr-Nachrichten zugreifen, da es keinen Zugriff auf Ihren privaten Schlüssel hat. Stattdessen generiert es einen neuen Schlüssel zum Senden von Ecash. Wenn Sie Ecash über Nostr senden, erhält der Empfänger es mit Ihrem neuen öffentlichen eNuts-Schlüssel. Wenn der Empfänger auf die Nachricht mit einem Ecash-Token antwortet, wird es hier angezeigt. Wir arbeiten aktiv an einer sicheren Lösung für private Schlüssel."
"nostrDmHint": "eNuts kann nicht auf Ihre Nostr-Nachrichten zugreifen, da es keinen Zugriff auf Ihren privaten Schlüssel hat. Stattdessen generiert es einen neuen Schlüssel zum Senden von Ecash. Wenn Sie Ecash über Nostr senden, erhält der Empfänger es mit Ihrem neuen öffentlichen eNuts-Schlüssel. Wenn der Empfänger auf die Nachricht mit einem Ecash-Token antwortet, wird es hier angezeigt. Wir arbeiten aktiv an einer sicheren Lösung für private Schlüssel.",
"nostrIssueHeader": "Nostr-Kontaktproblem",
"nostrIssueHint": "Wenn Sie Schwierigkeiten haben, Ihre Nostr-Kontakte zu öffnen, klicken Sie auf die Schaltfläche unten oder setzen Sie die Nostr-Daten in \"Optionen > Kontakte > Daten zurücksetzen\" zurück, um das Problem zu lösen.",
"submitNostrIssue": "Daten zurücksetzen",
"nostrIssueSuccess": "Nostr-Daten erfolgreich zurückgesetzt!"
},
"error": {
"checkSpendableErr": "Fehler beim Überprüfen, ob der Token ausgegeben werden kann",
Expand Down
7 changes: 5 additions & 2 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"delHistoryQ": "Delete history?",
"resetQ": "Reset your wallet?",
"delHistoryTxt": "The data can not be retrieved afterwards.",
"plsRestart": "Please restart the app now",
"disclaimer": "Disclaimer",
"ecashPayment": "Ecash payment",
"english": "English",
Expand Down Expand Up @@ -211,7 +210,11 @@
"zap": "Zap",
"zapNow": "Zap now",
"meltNostrProfileHint": "Transfer funds to the LN address associated with your Nostr profile.",
"nostrDmHint": "eNuts can't access your Nostr account DMs due to its lack of access to your private key. Instead, it generates a new key for sending Ecash. When you send Ecash via Nostr, the recipient gets it using your new eNuts public key. If the recipient replies to the DM with an Ecash token, you can view it here. We're actively working on a secure private key solution."
"nostrDmHint": "eNuts can't access your Nostr account DMs due to its lack of access to your private key. Instead, it generates a new key for sending Ecash. When you send Ecash via Nostr, the recipient gets it using your new eNuts public key. If the recipient replies to the DM with an Ecash token, you can view it here. We're actively working on a secure private key solution.",
"nostrIssueHeader": "Nostr contacts issue",
"nostrIssueHint": "If you're having trouble opening your Nostr contacts, click the button below or reset the Nostr data in \"options > contacts > reset data now\" data to resolve the issue.",
"submitNostrIssue": "Reset data now",
"nostrIssueSuccess": "Nostr data reset successfully!"
},
"error": {
"checkSpendableErr": "Error while checking if token is spendable",
Expand Down
11 changes: 7 additions & 4 deletions assets/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"resetQ": "Réinitialiser?",
"delHistoryQ": "Supprimer l'historique?",
"delHistoryTxt": "Les données ne pourront pas être récupérées ultérieurement.",
"plsRestart": "Veuillez redémarrer l'application maintenant",
"disclaimer": "Clause de non-responsabilité",
"ecashPayment": "Paiement Ecash",
"english": "Anglais",
Expand Down Expand Up @@ -185,9 +184,9 @@
"disclaimerHint": "Cette clause de non-responsabilité doit être prise au sérieux et ne doit pas être ignorée ni sous-estimée. Nous apprécions votre intérêt pour ce projet et continuerons à travailler à son amélioration.",
"searchContacts": "Recherchez ou saisissez NPUB",
"submit": "Soumettre",
"clearMetadataCache": "Vider le cache",
"clearMetadataCache": "Vider le cache métadonnées",
"clearMetadataCacheHint": "Vider le cache des métadonnées?",
"clearImageCache": "Vider le cache",
"clearImageCache": "Vider le cache des images",
"clearImageCacheHint": "Vider le cache des images?",
"pullRefresh": "Tirer pour rafraîchir",
"processTestPay": "Traitement du paiement de test...",
Expand All @@ -211,7 +210,11 @@
"zap": "Zap",
"zapNow": "Zap",
"meltNostrProfileHint": "Transférez des fonds vers l'adresse du LN associée à votre profil Nostr.",
"nostrDmHint": "eNuts ne peut pas accéder aux DM de votre compte Nostr en raison de son manque d'accès à votre clé privée. À la place, il génère une nouvelle clé pour l'envoi d'Ecash. Lorsque vous envoyez de l'Ecash via Nostr, le destinataire le reçoit en utilisant votre nouvelle clé publique eNuts. Si le destinataire répond au DM avec un jeton Ecash, vous pouvez le voir ici. Nous travaillons activement sur une solution sécurisée pour les clés privées."
"nostrDmHint": "eNuts ne peut pas accéder aux DM de votre compte Nostr en raison de son manque d'accès à votre clé privée. À la place, il génère une nouvelle clé pour l'envoi d'Ecash. Lorsque vous envoyez de l'Ecash via Nostr, le destinataire le reçoit en utilisant votre nouvelle clé publique eNuts. Si le destinataire répond au DM avec un jeton Ecash, vous pouvez le voir ici. Nous travaillons activement sur une solution sécurisée pour les clés privées.",
"nostrIssueHeader": "Problème de contacts Nostr",
"nostrIssueHint": "Si vous rencontrez des problèmes pour ouvrir vos contacts Nostr, cliquez sur le bouton ci-dessous ou réinitialisez les données Nostr dans \"options > contacts > Réinitialiser maintenant\" pour résoudre le problème.",
"submitNostrIssue": "Réinitialiser maintenant",
"nostrIssueSuccess": "Réinitialisation des données Nostr réussie!"
},
"error": {
"checkSpendableErr": "Erreur lors de la vérification si le token est dépensable",
Expand Down
7 changes: 5 additions & 2 deletions assets/translations/sw.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"delHistoryQ": "Futa historia?",
"resetQ": "Weka upya mkoba wako?",
"delHistoryTxt": "Data haiwezi kurudishwa baadaye.",
"plsRestart": "Tafadhali anzisha tena programu sasa",
"disclaimer": "Taarifa ya kutumia",
"ecashPayment": "Malipo ya Ecash",
"english": "Kiingereza",
Expand Down Expand Up @@ -211,7 +210,11 @@
"zap": "Zap",
"zapNow": "Zap",
"meltNostrProfileHint": "Hamishia fedha kwa anwani ya Mtandao wa Lightning (LN) inayohusishwa na wasifu wako wa Nostr.",
"nostrDmHint": "eNuts hawezi kupata ujumbe wako wa Nostr kutokana na kutokuwa na ufikiaji wa ufunguo wako wa faragha. Badala yake, inazalisha ufunguo mpya kwa ajili ya kutuma Ecash. Ukipeleka Ecash kupitia Nostr, mpokeaji atapokea kwa kutumia ufunguo wa umma mpya wa eNuts. Ikiwa mpokeaji atajibu ujumbe huo na alama ya Ecash, unaweza kuiona hapa. Tunafanya kazi kwa bidii kwenye suluhisho salama la ufunguo wa faragha."
"nostrDmHint": "eNuts hawezi kupata ujumbe wako wa Nostr kutokana na kutokuwa na ufikiaji wa ufunguo wako wa faragha. Badala yake, inazalisha ufunguo mpya kwa ajili ya kutuma Ecash. Ukipeleka Ecash kupitia Nostr, mpokeaji atapokea kwa kutumia ufunguo wa umma mpya wa eNuts. Ikiwa mpokeaji atajibu ujumbe huo na alama ya Ecash, unaweza kuiona hapa. Tunafanya kazi kwa bidii kwenye suluhisho salama la ufunguo wa faragha.",
"nostrIssueHeader": "Tatizo la Mawasiliano ya Nostr",
"nostrIssueHint": "Kama unakumbana na shida kufungua mawasiliano yako ya Nostr, bonyeza kitufe hapa chini au rudisha data ya Nostr katika \"chaguo > mawasiliano > rudisha data sasa\" ili kutatua tatizo.",
"submitNostrIssue": "Rudisha data sasa",
"nostrIssueSuccess": "Urejeshaji wa data ya Nostr umefanikiwa!"
},
"error": {
"checkSpendableErr": "Kumetokea kosa wakati wa kuangalia ikiwa kijenzi kina pesa za kutumiwa",
Expand Down
15 changes: 14 additions & 1 deletion src/components/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,20 @@ export function SendMsgIcon({ width, height, color }: TIconProps) {
</Svg>
)
}

export function DatabaseIcon({ width, height, color }: TIconProps) {
return (
<Svg width={width || 24} height={height || 24} viewBox="0 0 24 24" fill="none">
<Path d="M3 7.39095V10C3 10.3436 3.85363 10.8747 5.40973 11.2842C7.13505 11.7383 9.48657 12 12 12C14.5134 12 16.8649 11.7383 18.5903 11.2842C20.1464 10.8747 21 10.3436 21 10V7.39095C19.3864 8.40254 15.9832 9 12 9C8.01684 9 4.61364 8.40254 3 7.39095ZM2 6C2 4.16677 6.43371 3 12 3C17.5663 3 22 4.16677 22 6V18C22 19.8332 17.5663 21 12 21C6.43371 21 2 19.8332 2 18V6ZM21 11.3909C19.3864 12.4025 15.9832 13 12 13C8.01684 13 4.61364 12.4025 3 11.3909V14C3 14.3436 3.85363 14.8747 5.40973 15.2842C7.13505 15.7383 9.48657 16 12 16C14.5134 16 16.8649 15.7383 18.5903 15.2842C20.1464 14.8747 21 14.3436 21 14V11.3909ZM21 15.3909C19.3864 16.4025 15.9832 17 12 17C8.01684 17 4.61364 16.4025 3 15.3909V18C3 18.3436 3.85363 18.8747 5.40973 19.2842C7.13505 19.7383 9.48657 20 12 20C14.5134 20 16.8649 19.7383 18.5903 19.2842C20.1464 18.8747 21 18.3436 21 18V15.3909ZM12 8C14.5134 8 16.8649 7.73826 18.5903 7.28423C20.1464 6.87473 21 6.34362 21 6C21 5.65638 20.1464 5.12527 18.5903 4.71577C16.8649 4.26174 14.5134 4 12 4C9.48657 4 7.13505 4.26174 5.40973 4.71577C3.85363 5.12527 3 5.65638 3 6C3 6.34362 3.85363 6.87473 5.40973 7.28423C7.13505 7.73826 9.48657 8 12 8Z" fill={color} />
</Svg>
)
}
export function ImageIcon({ width, height, color }: TIconProps) {
return (
<Svg width={width || 24} height={height || 24} viewBox="0 0 24 24" fill="none">
<Path d="M20 15.2929V5.5C20 4.67157 19.3284 4 18.5 4H5.5C4.67157 4 4 4.67157 4 5.5V12.2929L7.14645 9.14645C7.34171 8.95118 7.65829 8.95118 7.85355 9.14645L13.5 14.7929L16.1464 12.1464C16.3417 11.9512 16.6583 11.9512 16.8536 12.1464L20 15.2929ZM20 16.7071L16.5 13.2071L13.8536 15.8536C13.6583 16.0488 13.3417 16.0488 13.1464 15.8536L7.5 10.2071L4 13.7071V18.5C4 19.3284 4.67157 20 5.5 20H18.5C19.3284 20 20 19.3284 20 18.5V16.7071ZM3 5.5C3 4.11929 4.11929 3 5.5 3H18.5C19.8807 3 21 4.11929 21 5.5V18.5C21 19.8807 19.8807 21 18.5 21H5.5C4.11929 21 3 19.8807 3 18.5V5.5ZM15 6H17C17.5523 6 18 6.44772 18 7V9C18 9.55228 17.5523 10 17 10H15C14.4477 10 14 9.55228 14 9V7C14 6.44772 14.4477 6 15 6ZM15 7V9H17V7H15Z" fill={color} />
</Svg>
)
}
const styles = StyleSheet.create({
nostrIcon: {
marginLeft: -5
Expand Down
28 changes: 24 additions & 4 deletions src/components/modal/Prompt.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Button from '@comps/Button'
import { ExclamationIcon } from '@comps/Icons'
import { useThemeContext } from '@src/context/Theme'
import { NS } from '@src/i18n'
import { globals } from '@styles'
import { useTranslation } from 'react-i18next'
import { StyleSheet, Text, View } from 'react-native'

import MyModal from '.'
Expand All @@ -10,11 +12,22 @@ interface IPromptModalProps {
header: string
txt?: string
hideIcon?: boolean
visible: boolean
visible?: boolean
submitTxt: string
submit: () => void
close: () => void
}

export function PromptModal({ header, txt, hideIcon, visible, close }: IPromptModalProps) {
export function PromptModal({
header,
txt,
hideIcon,
visible,
submitTxt,
submit,
close,
}: IPromptModalProps) {
const { t } = useTranslation([NS.common])
const { color } = useThemeContext()
return (
<MyModal type='error' animation='fade' visible={visible}>
Expand All @@ -29,8 +42,15 @@ export function PromptModal({ header, txt, hideIcon, visible, close }: IPromptMo
{txt &&
<Text style={globals(color).modalTxt}>
{txt}
</Text>}
<Button txt='OK' onPress={close} />
</Text>
}
<Button txt={submitTxt} onPress={submit} />
<View style={{ marginVertical: 10 }} />
<Button
txt={t('cancel')}
onPress={close}
outlined
/>
</MyModal>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context'
interface IMyModalProps {
type: 'bottom' | 'question' | 'success' | 'error' | 'invoiceAmount'
animation?: 'slide' | 'fade' | 'none'
visible: boolean
visible?: boolean
success?: boolean
hasNoPadding?: boolean
close?: () => void
Expand Down
2 changes: 1 addition & 1 deletion src/components/nav/BottomNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function BottomNav({ navigation, route }: TBottomNavProps) {
route.name === 'Security settings' ||
route.name === 'BackupPage' ||
route.name === 'Privacy settings' ||
route.name === 'Nostr settings'
route.name === 'Contacts settings'

return (
<View style={[styles.bottomNav, { backgroundColor: color.BACKGROUND, paddingBottom: isIOS ? 40 : 10 }]}>
Expand Down
4 changes: 2 additions & 2 deletions src/components/nav/Navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ import ScanSuccessScreen from '@screens/QRScan/ScanSuccess'
import Settings from '@screens/Settings'
import AboutSettings from '@screens/Settings/About'
import BackupPage from '@screens/Settings/Backup'
import ContactsSettings from '@screens/Settings/Contacts'
import GeneralSettings from '@screens/Settings/General'
import AdvancedFunctionScreen from '@screens/Settings/General/Advanced'
import DisplaySettings from '@screens/Settings/General/Display'
import LanguageSettings from '@screens/Settings/General/Language'
import NostrSettings from '@screens/Settings/Nostr'
import PrivacySettings from '@screens/Settings/Privacy'
import SecuritySettings from '@screens/Settings/Security'
import { useThemeContext } from '@src/context/Theme'
Expand Down Expand Up @@ -173,7 +173,7 @@ export default function Navigator({
<Stack.Screen name='Display settings' component={DisplaySettings} />
<Stack.Screen name='Security settings' component={SecuritySettings} />
<Stack.Screen name='Privacy settings' component={PrivacySettings} />
<Stack.Screen name='Nostr settings' component={NostrSettings} />
<Stack.Screen name='Contacts settings' component={ContactsSettings} />
<Stack.Screen name='Language settings' component={LanguageSettings} />
<Stack.Screen name='Advanced settings' component={AdvancedFunctionScreen} />
<Stack.Screen name='About settings' component={AboutSettings} />
Expand Down
2 changes: 1 addition & 1 deletion src/context/Nostr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const useNostr = () => {
store.delete(STORE_KEYS.nostrDms),
store.delete(STORE_KEYS.favs),
store.delete(STORE_KEYS.relays),
store.delete(STORE_KEYS.lud16)
store.delete(STORE_KEYS.lud16),
])
}

Expand Down
4 changes: 2 additions & 2 deletions src/model/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type RootStackParamList = {
'Display settings': undefined
'Language settings': undefined
'Advanced settings': undefined
'Nostr settings': undefined
'Contacts settings': undefined
'About settings': undefined
auth: {
pinHash: string
Expand Down Expand Up @@ -243,7 +243,7 @@ export type TGeneralSettingsPageProps = NativeStackScreenProps<RootStackParamLis
export type TDisplaySettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Display settings'>
export type TSecuritySettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Security settings'>
export type TPrivacySettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Privacy settings'>
export type TNostrSettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Nostr settings'>
export type TNostrSettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Contacts settings'>
export type TLanguageSettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Language settings'>
export type TAdvancedSettingsPageProps = NativeStackScreenProps<RootStackParamList, 'Advanced settings'>
export type TAboutSettingsPageProps = NativeStackScreenProps<RootStackParamList, 'About settings'>
Expand Down
4 changes: 2 additions & 2 deletions src/screens/Addressbook/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { SECRET, STORE_KEYS } from '@store/consts'
import { getCustomMintNames } from '@store/mintStore'
import { globals } from '@styles'
import { highlight as hi } from '@styles/colors'
import { debounce, isNum, uniqByIContacts } from '@util'
import { debounce, isNum, uniq, uniqByIContacts } from '@util'
import { Image } from 'expo-image'
import { generatePrivateKey, getPublicKey, nip19 } from 'nostr-tools'
import { createRef, useCallback, useEffect, useMemo, useRef, useState } from 'react'
Expand Down Expand Up @@ -114,7 +114,7 @@ export default function AddressbookPage({ navigation, route }: TAddressBookPageP
onContactsChanged: allContacts => {
if (!allContacts?.length) { return }
// we simply overwrite the previous state with the new one
const c = allContacts.map(x => ({ hex: x })).sort(sortFavs)
const c = uniq(allContacts).map(hex => ({ hex })).sort(sortFavs)
contactsRef.current = c
setContacts(c)
// first render of contacts metadata happens in flashlist event onViewableItemsChanged
Expand Down
Loading

0 comments on commit 9679a39

Please sign in to comment.