Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/HomeScreenHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ const HomeScreenHeader: React.FC<HomeScreenHeaderProps> = ({
dispatch(uaiActioned({ uaiId: localLatestUnseenUai.id, action: false }));
navigtaion.dispatch(CommonActions.navigate('ChoosePlan', { showDiscounted: true }));
},
[uaiType.CONTACTS]: () => {
dispatch(uaiActioned({ uaiId: localLatestUnseenUai.id, action: false }));
navigtaion.dispatch(CommonActions.navigate('Home', { selectedOption: 'Contacts' }));
},
};

return (
Expand Down
7 changes: 5 additions & 2 deletions src/hooks/useNotificationHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { notificationType } from 'src/models/enums/Notifications';
import { useDispatch } from 'react-redux';
import { addTicketStatusUAI } from 'src/store/sagaActions/concierge';
import { uaiType } from 'src/models/interfaces/Uai';
import { uaiChecks } from 'src/store/sagaActions/uai';
import { addToUaiStack, uaiChecks } from 'src/store/sagaActions/uai';

const NotificationHandler = () => {
const [showRemoteNotificationModel, setShowRemoteNotificationModel] = useState(false);
Expand All @@ -16,7 +16,10 @@ const NotificationHandler = () => {
const dispatch = useDispatch();
useEffect(() => {
const unsubscribe = messaging().onMessage(async (remoteMessage) => {
if (remoteMessage.data?.notificationType === notificationType.REMOTE_KEY_SHARE) {
if (remoteMessage.data?.notificationType === notificationType.CONTACTS) {
dispatch(addToUaiStack({ uaiType: uaiType.CONTACTS }));
dispatch(uaiChecks([uaiType.CONTACTS]));
} else if (remoteMessage.data?.notificationType === notificationType.REMOTE_KEY_SHARE) {
setForegroundNotifcation(remoteMessage);
setShowRemoteNotificationModel(true);
} else if (remoteMessage.data?.notificationType === notificationType.ZENDESK_TICKET) {
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useUaiStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const uaiPriorityMap: UAIPriorityMap = {
[uaiType.POLICY_DELAY]: 90,
[uaiType.INCOMING_TRANSACTION]: 100,
[uaiType.CAMPAIGN]: 101,
[uaiType.CONTACTS]: 101,
};

const useUaiStack = (): { uaiStack: UAI[]; isLoading: boolean } => {
Expand Down
1 change: 1 addition & 0 deletions src/models/enums/Notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export enum notificationType {
REMOTE_KEY_SHARE = 'REMOTE_KEY_SHARE',
ZENDESK_TICKET = 'ZENDESK_TICKET',
CAMPAIGN = 'CAMPAIGN',
CONTACTS = 'CONTACT_MESSAGE',
}
2 changes: 2 additions & 0 deletions src/models/interfaces/Uai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ export enum uaiType {
DEFAULT = 'DEFAULT',
RELEASE_MESSAGE = 'RELEASE_MESSAGE',
CAMPAIGN = 'CAMPAIGN',

CONTACTS = 'CONTACTS',
}
4 changes: 3 additions & 1 deletion src/screens/Home/InititalAppController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ function InititalAppController({ navigation, electrumErrorVisible, setElectrumEr
};

const handleZendeskNotificationRedirection = (data) => {
if (data?.notificationType === notificationType.ZENDESK_TICKET) {
if (data?.notificationType === notificationType.CONTACTS) {
navigation.dispatch(CommonActions.navigate('Home', { selectedOption: 'Contacts' }));
} else if (data?.notificationType === notificationType.ZENDESK_TICKET) {
const { ticketId = null, ticketStatus = null } = data;
if (ticketId && ticketStatus)
navigation.navigate({
Expand Down
25 changes: 25 additions & 0 deletions src/screens/Home/Notifications/NotificationsCenter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { backupAllSignersAndVaults } from 'src/store/sagaActions/bhr';
import { LocalizationContext } from 'src/context/Localization/LocContext';
import ThemedSvg from 'src/components/ThemedSvg.tsx/ThemedSvg';
import Fonts from 'src/constants/Fonts';
import ContactIcon from 'src/assets/images/Contact-footer-dark.svg';

type CardProps = {
uai: any;
Expand Down Expand Up @@ -81,6 +82,7 @@ const SUPPORTED_NOTOFOCATION_TYPES = [
uaiType.INCOMING_TRANSACTION,
uaiType.SERVER_BACKUP_FAILURE,
uaiType.CAMPAIGN,
uaiType.CONTACTS,
];

const Card = memo(({ uai }: CardProps) => {
Expand Down Expand Up @@ -347,6 +349,23 @@ const Card = memo(({ uai }: CardProps) => {
};
}

case uaiType.CONTACTS: {
return {
heading: content.heading,
body: content.body,
icon: content.icon,
btnConfig: {
primary: {
text: 'View',
cta: () => {
dispatch(uaiActioned({ uaiId: uai.id, action: false }));
navigtaion.dispatch(CommonActions.navigate('Home', { selectedOption: 'Contacts' }));
},
},
},
};
}

default:
return null;
}
Expand Down Expand Up @@ -634,6 +653,12 @@ export const getUaiContent = (type: uaiType, details?: any) => {
body: 'Plan your inheritance and improve your security',
icon: <DiscountIcon />,
};
case uaiType.CONTACTS:
return {
heading: 'Contacts',
body: 'You have a new message',
icon: <ContactIcon />,
};

default:
return {
Expand Down
12 changes: 10 additions & 2 deletions src/screens/Home/components/Contact/ChatRoomScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useState } from 'react';
import React, { useContext, useEffect, useState } from 'react';
import { Box, useColorMode } from 'native-base';
import { StyleSheet } from 'react-native';
import { RouteProp, useRoute } from '@react-navigation/native';
Expand All @@ -10,7 +10,8 @@ import { LocalizationContext } from 'src/context/Localization/LocContext';
import { KeeperApp } from 'src/models/interfaces/KeeperApp';
import { RealmSchema } from 'src/storage/realm/enum';
import { useObject, useQuery } from '@realm/react';
import { Community, Contact, Message } from 'src/services/p2p/interface';
import { Community, Message } from 'src/services/p2p/interface';
import { useChatPeer } from 'src/hooks/useChatPeer';

type ChatRoomParams = {
ChatRoomScreen: {
Expand All @@ -30,10 +31,17 @@ const ChatRoomScreen = () => {
const messages = useQuery<Message>(RealmSchema.Message)
.filtered('communityId = $0', communityId)
.sorted('createdAt', true);
const { markCommunityAsRead } = useChatPeer();

const [editUserProfileImage, setEditUserProfileImage] = useState('');
const [editReceiverProfileName, setEditReceiverProfileName] = useState(community.name);

useEffect(() => {
// mark messages are read
const unreadMsgId = messages.filter((msg) => msg.unread).map((msg) => msg.id);
if (unreadMsgId.length) markCommunityAsRead(communityId);
}, []);

return (
<Box style={styles.container} backgroundColor={`${colorMode}.primaryBackground`}>
<ChatRoomHeader
Expand Down
1 change: 1 addition & 0 deletions src/screens/Home/components/Contact/component/Contact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ const Contact = () => {
isSingning: true,
contactShareData: contactShareLink,
isPSBT: true,
placeholder: 'or paste text',
},
})
);
Expand Down
7 changes: 5 additions & 2 deletions src/screens/QRScreens/ScanQR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Instruction from 'src/components/Instruction';
import ThemedSvg from 'src/components/ThemedSvg.tsx/ThemedSvg';
import Buttons from 'src/components/Buttons';
import ShareDark from 'src/assets/images/share-white.svg';
import { useKeyboard } from 'src/hooks/useKeyboard';

const decoder = new URRegistryDecoder();

Expand All @@ -52,6 +53,7 @@ function ScanQR() {
Instructions,
isSingning = false,
contactShareData = null,
placeholder = null,
} = route.params as any;

const { translations } = useContext(LocalizationContext);
Expand All @@ -63,6 +65,7 @@ function ScanQR() {
const isDarkMode = colorMode === 'dark';
const isHealthCheck = mode === InteracationMode.HEALTH_CHECK;
const [infoModal, setInfoModal] = useState(false);
const isKeyboardOpen = useKeyboard();

const onTextSubmit = (data) => {
if (!data.startsWith('UR') && !data.startsWith('ur')) {
Expand Down Expand Up @@ -127,7 +130,7 @@ function ScanQR() {
borderColor={`${colorMode}.greyBorder`}
>
<Input
placeholder="or paste PSBT text"
placeholder={placeholder ?? 'or paste PSBT text'}
placeholderTextColor={`${colorMode}.primaryText`}
style={styles.textInput}
variant="unstyled"
Expand Down Expand Up @@ -165,7 +168,7 @@ function ScanQR() {
<Note title={common.note} subtitle={common.scanQRNote} />
</Box>
)}
{contactShareData && (
{!isKeyboardOpen && contactShareData && (
<Box style={styles.noteWrapper}>
<Buttons
primaryText={contactText.shareContact}
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Recieve/ReceiveAddress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function ReceiveAddress({ address }: Props) {
borderColor={`${colorMode}.dullGreyBorder`}
>
<Box style={styles.textContainer}>
<Text color={`${colorMode}.GreyText`} style={styles.value}>
<Text color={`${colorMode}.GreyText`} style={styles.value} numberOfLines={2}>
{address.length > 50 ? address.slice(0, 50) + '...' : address}
</Text>
</Box>
Expand Down
27 changes: 15 additions & 12 deletions src/services/p2p/ChatPeerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,21 @@ export default class ChatPeerManager {
(community as any).key
);
const messageData = JSON.parse(decryptedMessage);
dbManager.createObject(RealmSchema.Message, {
id: messageData.id,
communityId: messageData.communityId,
type: messageData.type,
text: messageData.text,
createdAt: msg.timestamp,
sender: messageData.sender,
block: msg.blockNumber,
unread: true,
fileUrl: message?.fileUrl,
request: message?.request,
});
const existingMessage = dbManager.getObjectById(RealmSchema.Message, messageData.id);
if (!existingMessage) {
dbManager.createObject(RealmSchema.Message, {
id: messageData.id,
communityId: messageData.communityId,
type: messageData.type,
text: messageData.text,
createdAt: msg.timestamp,
sender: messageData.sender,
block: msg.blockNumber,
unread: true,
fileUrl: message?.fileUrl,
request: message?.request,
});
}
}
}
}
Expand Down
Loading