diff --git a/frontend/Components/GroupShare/index.tsx b/frontend/Components/GroupShare/index.tsx index 4e39279..effaa5e 100644 --- a/frontend/Components/GroupShare/index.tsx +++ b/frontend/Components/GroupShare/index.tsx @@ -75,6 +75,7 @@ export const GroupShare: React.FC = ({ group }) => { const styles = StyleSheet.create({ snackbar: { marginBottom: 85, + width: '100%', }, mainLayout: { flexDirection: 'row', diff --git a/frontend/Components/LnPreview/index.tsx b/frontend/Components/LnPreview/index.tsx index 0376a0e..7b40c0d 100644 --- a/frontend/Components/LnPreview/index.tsx +++ b/frontend/Components/LnPreview/index.tsx @@ -9,12 +9,16 @@ import { AppContext } from '../../Contexts/AppContext' import { decode, PaymentRequestObject, TagsObject } from 'bolt11' interface LnPreviewProps { - setOpen: (open: boolean) => void + setOpen?: (open: boolean) => void invoice?: string setInvoice: (invoice: string | undefined) => void } -export const LnPreview: React.FC = ({ invoice, setInvoice, setOpen }) => { +export const LnPreview: React.FC = ({ + invoice, + setInvoice, + setOpen = () => {}, +}) => { const theme = useTheme() const { t } = useTranslation('common') const { getSatoshiSymbol } = React.useContext(AppContext) diff --git a/frontend/Components/NoteCard/index.tsx b/frontend/Components/NoteCard/index.tsx index e510a35..0baf632 100644 --- a/frontend/Components/NoteCard/index.tsx +++ b/frontend/Components/NoteCard/index.tsx @@ -46,16 +46,20 @@ interface NoteCardProps { note?: Note showAvatarImage?: boolean showAnswerData?: boolean + showRelayColors?: boolean showAction?: boolean showActionCount?: boolean showPreview?: boolean showRepostPreview?: boolean numberOfLines?: number + copyOnPress?: boolean mode?: 'elevated' | 'outlined' | 'contained' } export const NoteCard: React.FC = ({ note, + copyOnPress = true, + showRelayColors = true, showAvatarImage = true, showAnswerData = true, showAction = true, @@ -177,44 +181,40 @@ export const NoteCard: React.FC = ({ onPressUser={(user) => setDisplayUserDrawer(user.id)} showPreview={showPreview} numberOfLines={numberOfLines} + copyOnPress={copyOnPress} /> )} {note?.repost_id && ( - <> + navigate('Note', { noteId: note.repost_id })}> {repost && showRepostPreview ? ( ) : ( - ( + + )} style={{ - marginTop: note.content.length > 5 ? 16 : -16, + backgroundColor: theme.colors.secondaryContainer, + color: theme.colors.onTertiaryContainer, }} - onPress={() => navigate('Note', { noteId: note.repost_id })} > - ( - - )} - style={{ - backgroundColor: theme.colors.secondaryContainer, - color: theme.colors.onTertiaryContainer, - }} - > - - {t('noteCard.reposted')} - - - + + {t('noteCard.reposted')} + + )} - + )} @@ -437,6 +437,7 @@ export const NoteCard: React.FC = ({ )} {relayColouring && + showRelayColors && relays.map((relay, index) => ( setDisplayrelayDrawer(relay.relay_url)} diff --git a/frontend/Components/ProfileActions/index.tsx b/frontend/Components/ProfileActions/index.tsx index 552956f..d867896 100644 --- a/frontend/Components/ProfileActions/index.tsx +++ b/frontend/Components/ProfileActions/index.tsx @@ -272,7 +272,12 @@ export const ProfileActions: React.FC = ({ - + {t('profileCard.relaysTitle')} @@ -286,13 +291,11 @@ export const ProfileActions: React.FC = ({ )} /> - - - + + + + + {showNotificationRelay && ( = ({ const theme = useTheme() const nPub = React.useMemo(() => (publicKey ? getNpub(publicKey) : ''), [publicKey]) const date = React.useMemo( - () => - timestamp ? formatDistance(fromUnixTime(timestamp), new Date(), { addSuffix: true }) : null, + () => (timestamp ? formatDistance(fromUnixTime(timestamp), new Date()) : null), [timestamp], ) diff --git a/frontend/Components/ProfileShare/index.tsx b/frontend/Components/ProfileShare/index.tsx index 689a965..4fd5356 100644 --- a/frontend/Components/ProfileShare/index.tsx +++ b/frontend/Components/ProfileShare/index.tsx @@ -1,6 +1,6 @@ import { t } from 'i18next' import * as React from 'react' -import { StyleSheet, View } from 'react-native' +import { Dimensions, StyleSheet, View } from 'react-native' import Clipboard from '@react-native-clipboard/clipboard' import { IconButton, Snackbar, Text, TouchableRipple } from 'react-native-paper' import { User } from '../../Functions/DatabaseFunctions/Users' @@ -37,7 +37,7 @@ export const ProfileShare: React.FC = ({ user }) => { = ({ user }) => { const styles = StyleSheet.create({ snackbar: { marginBottom: 85, + width: '100%', }, mainLayout: { flexDirection: 'row', diff --git a/frontend/Components/RelayCard/index.tsx b/frontend/Components/RelayCard/index.tsx index 2c1d33c..ad7e672 100644 --- a/frontend/Components/RelayCard/index.tsx +++ b/frontend/Components/RelayCard/index.tsx @@ -30,6 +30,7 @@ import { Event } from '../../lib/nostr/Events' import { getUnixTime } from 'date-fns' import { Kind } from 'nostr-tools' import { usersToTags } from '../../Functions/RelayFunctions/Users' +import { getRawUserGroupMessages, getRawUserGroups } from '../../Functions/DatabaseFunctions/Groups' interface RelayCardProps { url?: string @@ -39,7 +40,8 @@ interface RelayCardProps { export const RelayCard: React.FC = ({ url, bottomSheetRef }) => { const theme = useTheme() const { publicKey } = React.useContext(UserContext) - const { updateRelayItem, relayPool, removeRelayItem } = React.useContext(RelayPoolContext) + const { updateRelayItem, relayPool, removeRelayItem, sendRelays, relays } = + React.useContext(RelayPoolContext) const { database } = React.useContext(AppContext) const [relay, setRelay] = React.useState() const [uri, setUri] = React.useState() @@ -59,11 +61,14 @@ export const RelayCard: React.FC = ({ url, bottomSheetRef }) => React.useEffect(() => { if (pushUserHistoric && url && database && publicKey && relayPool) { + bottomSheetPushRelayRef.current?.forceUpdate() getRawUserNotes(database, publicKey).then((resultNotes) => { resultNotes.forEach((note) => { note.content = note.content.replace("''", "'") relayPool.sendEvent(note, url) }) + setPushDone(true) + setShowNotification('pushCompleted') }) getRawUserReactions(database, publicKey).then((resultReactions) => { resultReactions.forEach((reaction) => { @@ -87,8 +92,18 @@ export const RelayCard: React.FC = ({ url, bottomSheetRef }) => } relayPool?.sendEvent(event, url) } - setPushDone(true) }) + getRawUserGroupMessages(database, publicKey).then((resultGroupMessages) => { + resultGroupMessages.forEach((groupMessage) => { + relayPool.sendEvent(groupMessage, url) + }) + }) + getRawUserGroups(database, publicKey).then((resultGroups) => { + resultGroups.forEach((group) => { + relayPool.sendEvent(group, url) + }) + }) + sendRelays(relays, url) } }, [pushUserHistoric]) @@ -337,8 +352,13 @@ export const RelayCard: React.FC = ({ url, bottomSheetRef }) => {}} + onClose={() => { + setPushDone(false) + setPushUserHistoric(false) + setCheckedPush('unchecked') + }} > {t('relayCard.pushHistoricTitle')} {t('relayCard.pushHistoricDescription')} @@ -362,11 +382,7 @@ export const RelayCard: React.FC = ({ url, bottomSheetRef }) => disabled={pushUserHistoric || checkedPush !== 'checked'} loading={pushUserHistoric && !pushDone} > - {pushDone - ? t('relayCard.pushDone') - : pushUserHistoric - ? t('relayCard.pushingEvent') - : t('relayCard.pushHistoricTitle')} + {pushDone ? t('relayCard.pushDone') : t('relayCard.pushHistoricTitle')} + {showNotification && ( + setShowNotification(undefined)} + onDismiss={() => setShowNotification(undefined)} + > + {t(`relayCard.notifications.${showNotification}`)} + + )} ) : ( @@ -408,6 +435,7 @@ const styles = StyleSheet.create({ }, snackbar: { marginBottom: 85, + width: '100%', }, moreInfo: { paddingTop: 16, diff --git a/frontend/Components/TextContent/index.tsx b/frontend/Components/TextContent/index.tsx index e7ac2e6..f6bf4a0 100644 --- a/frontend/Components/TextContent/index.tsx +++ b/frontend/Components/TextContent/index.tsx @@ -22,6 +22,7 @@ interface TextContentProps { showPreview?: boolean onPressUser?: (user: User) => void numberOfLines?: number + copyOnPress?: boolean } export const TextContent: React.FC = ({ @@ -30,6 +31,7 @@ export const TextContent: React.FC = ({ showPreview = true, onPressUser = () => {}, numberOfLines, + copyOnPress = true, }) => { const theme = useTheme() const { t } = useTranslation('common') @@ -265,7 +267,7 @@ export const TextContent: React.FC = ({ }, ]} childrenProps={{ allowFontScaling: false }} - onLongPress={() => Clipboard.setString(text)} + onLongPress={copyOnPress ? () => Clipboard.setString(text) : undefined} numberOfLines={numberOfLines} > {text} diff --git a/frontend/Components/UploadImage/index.tsx b/frontend/Components/UploadImage/index.tsx index c0b02bf..7477ad7 100644 --- a/frontend/Components/UploadImage/index.tsx +++ b/frontend/Components/UploadImage/index.tsx @@ -156,6 +156,7 @@ const styles = StyleSheet.create({ snackbar: { margin: 16, bottom: 100, + width: '100%', }, warning: { borderRadius: 4, diff --git a/frontend/Contexts/RelayPoolContext.tsx b/frontend/Contexts/RelayPoolContext.tsx index 75c301b..df4e174 100644 --- a/frontend/Contexts/RelayPoolContext.tsx +++ b/frontend/Contexts/RelayPoolContext.tsx @@ -21,6 +21,7 @@ export interface RelayPoolContextProps { addRelayItem: (relay: Relay) => Promise removeRelayItem: (relay: Relay) => Promise updateRelayItem: (relay: Relay) => Promise + sendRelays: (relays: Relay[], url?: string) => Promise } export interface WebsocketEvent { @@ -40,6 +41,7 @@ export const initialRelayPoolContext: RelayPoolContextProps = { updateRelayItem: async () => await new Promise(() => {}), relays: [], setDisplayrelayDrawer: () => {}, + sendRelays: () => {}, } export const RelayPoolContextProvider = ({ @@ -56,7 +58,7 @@ export const RelayPoolContextProvider = ({ const [relays, setRelays] = React.useState([]) const [displayRelayDrawer, setDisplayrelayDrawer] = React.useState() - const sendRelays: (relayList: Relay[]) => void = (relayList) => { + const sendRelays: (relayList: Relay[], url?: string) => void = (relayList, url) => { if (publicKey && relayList.length > 0) { const event: Event = { content: '', @@ -65,7 +67,7 @@ export const RelayPoolContextProvider = ({ pubkey: publicKey, tags: relayList.map((relay) => ['r', relay.url, relay.mode ?? '']), } - relayPool?.sendEvent(event) + url ? relayPool?.sendEvent(event, url) : relayPool?.sendEvent(event) } } @@ -200,6 +202,7 @@ export const RelayPoolContextProvider = ({ addRelayItem, removeRelayItem, updateRelayItem, + sendRelays, }} > {children} diff --git a/frontend/Functions/DatabaseFunctions/Groups/index.ts b/frontend/Functions/DatabaseFunctions/Groups/index.ts index 3ad00ec..d64617d 100644 --- a/frontend/Functions/DatabaseFunctions/Groups/index.ts +++ b/frontend/Functions/DatabaseFunctions/Groups/index.ts @@ -223,3 +223,33 @@ export const getGroupMessagesMentionsCount: ( return item['COUNT(*)'] ?? 0 } + +export const getRawUserGroupMessages: ( + db: QuickSQLiteConnection, + pubKey: string, +) => Promise = async (db, pubKey) => { + const notesQuery = `SELECT * FROM nostros_group_messages + WHERE pubkey = ? + ORDER BY created_at DESC + ` + const resultSet = await db.execute(notesQuery, [pubKey]) + const items: object[] = getItems(resultSet) + const groupMessages: Event[] = items.map((object) => databaseToGroupMessage(object)) + + return groupMessages +} + +export const getRawUserGroups: ( + db: QuickSQLiteConnection, + pubKey: string, +) => Promise = async (db, pubKey) => { + const notesQuery = `SELECT * FROM nostros_groups + WHERE pubkey = ? + ORDER BY created_at DESC + ` + const resultSet = await db.execute(notesQuery, [pubKey]) + const items: object[] = getItems(resultSet) + const groups: Event[] = items.map((object) => databaseToGroup(object)) + + return groups +} diff --git a/frontend/Locales/de.json b/frontend/Locales/de.json index 84a2502..4f19b46 100644 --- a/frontend/Locales/de.json +++ b/frontend/Locales/de.json @@ -256,7 +256,8 @@ "globalFeedActiveUnactive": "Globaler Feed inaktiv.", "pubkeyCopied": "Öffentlichen Schlüssel kopiert.", "contactCopied": "Kontakt kopiert.", - "urlCopied": "URL kopiert." + "urlCopied": "URL kopiert.", + "pushCompleted": "All your data has been pushed." } }, diff --git a/frontend/Locales/en.json b/frontend/Locales/en.json index 5ed18cc..1f66254 100644 --- a/frontend/Locales/en.json +++ b/frontend/Locales/en.json @@ -255,7 +255,8 @@ "globalFeedActiveUnactive": "Global feed disabled.", "pubkeyCopied": "Public key copied.", "contactCopied": "Contact copied.", - "urlCopied": "URL copied." + "urlCopied": "URL copied.", + "pushCompleted": "All your data has been pushed." } }, "profileConfigPage": { @@ -316,8 +317,7 @@ }, "groupPage": { "typeMessage": "Type message", - "replyText": "Message", - "admin": "ADMIN" + "replyText": "Message" }, "groupHeaderIcon": { "delete": "Leave group", diff --git a/frontend/Locales/es.json b/frontend/Locales/es.json index 77d2eee..f4b3a3b 100644 --- a/frontend/Locales/es.json +++ b/frontend/Locales/es.json @@ -235,7 +235,8 @@ "globalFeedActiveUnactive": "Feed Global desactivado.", "pubkeyCopied": "Clave pública copiada.", "contactCopied": "Contactp copiado.", - "urlCopied": "URL copiada." + "urlCopied": "URL copiada.", + "pushCompleted": "Todos tus datos se han subido." } }, "relaysPage": { diff --git a/frontend/Locales/fr.json b/frontend/Locales/fr.json index 05cc4e3..e29949f 100644 --- a/frontend/Locales/fr.json +++ b/frontend/Locales/fr.json @@ -233,7 +233,8 @@ "globalFeedActiveUnactive": "Flux global désactivé.", "pubkeyCopied": "Clé publique copiée.", "contactCopied": "Contact copié.", - "urlCopied": "URL copié." + "urlCopied": "URL copié.", + "pushCompleted": "All your data has been pushed." } }, "relaysPage": { diff --git a/frontend/Locales/ru.json b/frontend/Locales/ru.json index 122f5fe..5ca8088 100644 --- a/frontend/Locales/ru.json +++ b/frontend/Locales/ru.json @@ -227,7 +227,8 @@ "globalFeedActiveUnactive": "Global feed disabled", "pubkeyCopied": "Публичный ключ скопирован", "contactCopied": "Контакт скопирован", - "urlCopied": "URL скопирован" + "urlCopied": "URL скопирован", + "pushCompleted": "All your data has been pushed." } }, "relaysPage": { diff --git a/frontend/Locales/zhCn.json b/frontend/Locales/zhCn.json index a6d4f00..429c977 100644 --- a/frontend/Locales/zhCn.json +++ b/frontend/Locales/zhCn.json @@ -266,7 +266,8 @@ "globalFeedActiveUnactive": "已为发现页禁用", "pubkeyCopied": "已复制私钥", "contactCopied": "已复制联系人", - "urlCopied": "已复制链接" + "urlCopied": "已复制链接", + "pushCompleted": "All your data has been pushed." } }, "profileConfigPage": { diff --git a/frontend/Pages/ContactsPage/index.tsx b/frontend/Pages/ContactsPage/index.tsx index 3507541..01d2476 100644 --- a/frontend/Pages/ContactsPage/index.tsx +++ b/frontend/Pages/ContactsPage/index.tsx @@ -291,6 +291,7 @@ export const ContactsPage: React.FC = () => { ItemSeparatorComponent={Divider} ListEmptyComponent={ListEmptyComponentFollowing} horizontal={false} + style={styles.list} /> ) @@ -365,6 +366,7 @@ export const ContactsPage: React.FC = () => { ItemSeparatorComponent={Divider} ListEmptyComponent={ListEmptyComponentBlocked} horizontal={false} + style={styles.list} /> ) @@ -531,6 +533,7 @@ const styles = StyleSheet.create({ snackbar: { margin: 16, marginBottom: 95, + width: '100%', }, contactRow: { padding: 16, @@ -548,7 +551,7 @@ const styles = StyleSheet.create({ justifyContent: 'space-between', }, fab: { - bottom: 65, + bottom: 16, right: 16, position: 'absolute', }, diff --git a/frontend/Pages/ConversationPage/index.tsx b/frontend/Pages/ConversationPage/index.tsx index b735f39..d4ab5d1 100644 --- a/frontend/Pages/ConversationPage/index.tsx +++ b/frontend/Pages/ConversationPage/index.tsx @@ -247,8 +247,7 @@ export const ConversationPage: React.FC = ({ route }) => )} - {message?.created_at && - formatDistance(fromUnixTime(message.created_at), new Date(), { addSuffix: true })} + {message?.created_at && formatDistance(fromUnixTime(message.created_at), new Date())} @@ -542,6 +541,7 @@ const styles = StyleSheet.create({ snackbar: { margin: 16, bottom: 70, + width: '100%', }, verifyIcon: { paddingTop: 4, diff --git a/frontend/Pages/ConversationsFeed/index.tsx b/frontend/Pages/ConversationsFeed/index.tsx index 2c5ef39..f965d75 100644 --- a/frontend/Pages/ConversationsFeed/index.tsx +++ b/frontend/Pages/ConversationsFeed/index.tsx @@ -148,9 +148,7 @@ export const ConversationsFeed: React.FC = () => { - - {formatDistance(fromUnixTime(item.created_at), new Date(), { addSuffix: true })} - + {formatDistance(fromUnixTime(item.created_at), new Date())} {item.pubkey !== publicKey && !item.read && } @@ -280,7 +278,7 @@ export const ConversationsFeed: React.FC = () => { )} bottomSheetCreateRef.current?.open()} diff --git a/frontend/Pages/GroupPage/index.tsx b/frontend/Pages/GroupPage/index.tsx index 977b296..730b6a0 100644 --- a/frontend/Pages/GroupPage/index.tsx +++ b/frontend/Pages/GroupPage/index.tsx @@ -32,9 +32,7 @@ import { handleInfinityScroll } from '../../Functions/NativeFunctions' import NostrosAvatar from '../../Components/NostrosAvatar' import UploadImage from '../../Components/UploadImage' import { - getGroup, getGroupMessages, - Group, GroupMessage, updateGroupRead, } from '../../Functions/DatabaseFunctions/Groups' @@ -55,7 +53,6 @@ export const GroupPage: React.FC = ({ route }) => { const { relayPool, lastEventId } = useContext(RelayPoolContext) const { publicKey, privateKey, name, picture, validNip05 } = useContext(UserContext) const [pageSize, setPageSize] = useState(initialPageSize) - const [group, setGroup] = useState() const [groupMessages, setGroupMessages] = useState([]) const [sendingMessages, setSendingMessages] = useState([]) const [reply, setReply] = useState() @@ -86,7 +83,6 @@ export const GroupPage: React.FC = ({ route }) => { const loadGroupMessages: (subscribe: boolean) => void = (subscribe) => { if (database && publicKey && route.params.groupId) { updateGroupRead(database, route.params.groupId) - getGroup(database, route.params.groupId).then(setGroup) getGroupMessages(database, route.params.groupId, { order: 'DESC', limit: pageSize, @@ -299,11 +295,6 @@ export const GroupPage: React.FC = ({ route }) => { )} - {item.pubkey === group?.pubkey && ( - - {t('groupPage.admin')} - - )} {message?.pending && ( = ({ route }) => { )} {message?.created_at && - formatDistance(fromUnixTime(message.created_at), new Date(), { addSuffix: true })} + formatDistance(fromUnixTime(message.created_at), new Date())} @@ -617,6 +608,7 @@ const styles = StyleSheet.create({ snackbar: { margin: 16, bottom: 70, + width: '100%', }, verifyIcon: { paddingTop: 4, diff --git a/frontend/Pages/GroupsFeed/index.tsx b/frontend/Pages/GroupsFeed/index.tsx index b8140b4..f590c76 100644 --- a/frontend/Pages/GroupsFeed/index.tsx +++ b/frontend/Pages/GroupsFeed/index.tsx @@ -71,6 +71,8 @@ export const GroupsFeed: React.FC = () => { loadGroups() }, [lastEventId, lastConfirmationtId]) + useEffect(() => {}, [newMessages, newMentions]) + const pastePicture: () => void = () => { Clipboard.getString().then((value) => { setNewGroupPicture(value ?? '') @@ -272,7 +274,7 @@ export const GroupsFeed: React.FC = () => { estimatedItemSize={76} /> bottomSheetFabActionRef.current?.open()} @@ -433,6 +435,7 @@ const styles = StyleSheet.create({ snackbar: { marginLeft: 16, bottom: 16, + width: '100%', }, containerAvatar: { marginTop: 10, diff --git a/frontend/Pages/HomeFeed/index.tsx b/frontend/Pages/HomeFeed/index.tsx index d74da49..74513c6 100644 --- a/frontend/Pages/HomeFeed/index.tsx +++ b/frontend/Pages/HomeFeed/index.tsx @@ -134,7 +134,7 @@ export const HomeFeed: React.FC = ({ navigation }) => { {renderScene[tabKey]} {privateKey && ( navigate('Send')} diff --git a/frontend/Pages/NotePage/index.tsx b/frontend/Pages/NotePage/index.tsx index 7f62006..d201fe8 100644 --- a/frontend/Pages/NotePage/index.tsx +++ b/frontend/Pages/NotePage/index.tsx @@ -129,7 +129,7 @@ export const NotePage: React.FC = ({ route }) => { {privateKey && ( { @@ -141,7 +141,7 @@ export const NotePage: React.FC = ({ route }) => { /> )} { @@ -156,7 +156,7 @@ export const NotePage: React.FC = ({ route }) => { { diff --git a/frontend/Pages/ProfilePage/index.tsx b/frontend/Pages/ProfilePage/index.tsx index 76689ce..66aac1a 100644 --- a/frontend/Pages/ProfilePage/index.tsx +++ b/frontend/Pages/ProfilePage/index.tsx @@ -222,6 +222,7 @@ const styles = StyleSheet.create({ snackbar: { margin: 16, bottom: 70, + width: '100%', }, profilePicture: { width: '80%', diff --git a/frontend/Pages/RelaysPage/index.tsx b/frontend/Pages/RelaysPage/index.tsx index 773d470..16e47ce 100644 --- a/frontend/Pages/RelaysPage/index.tsx +++ b/frontend/Pages/RelaysPage/index.tsx @@ -255,7 +255,12 @@ export const RelaysPage: React.FC = () => { )} /> - +