diff --git a/config/config.gen.json b/config/config.gen.json
index 80e4253708..3373b1a64c 100644
--- a/config/config.gen.json
+++ b/config/config.gen.json
@@ -5,42 +5,49 @@
"link": "https://berty.tech/id#contact/oZBLFkhRFWg9NXmy8wtjzZKeeUwfaWQVkUXfNY6h9z4QnGXuXSox8zs2yXeFHzt9DKJ8B4WHy7Zjy1g8tSat6ee2Jh7vp4J/name=BetaBot",
"name": "BetaBot",
"description": "Official BetaBot",
- "kind": "Bot"
+ "kind": "Bot",
+ "suggestion": true
},
"betabot-dev": {
"link": "https://berty.tech/id#contact/oZBLFQQTqmZ25yvcRRUVgzzZCpDY7YAVXDEz3g8kmwcSPCmnQrqiMbLrfSp1GRLaNBX6ZRarid8jkSUX4yQYL4oBZcLDtFY/name=BetaBot-Dev",
"name": "BetaBot Dev",
"description": "BetaBot-Dev",
- "kind": "Bot"
+ "kind": "Bot",
+ "suggestion": true
},
"testbot": {
"link": "https://berty.tech/id#contact/oZBLG8gg1RTwCW2u1AxA44dT1Lum2PAr2nBra6WdmTpozq7vdDkae9FjyCW3QZ86AE9pMAudh4GKTfNj1jELcdvtJy44Rbp/name=TestBot",
"name": "TestBot",
"description": "Official TestBot",
- "kind": "Bot"
+ "kind": "Bot",
+ "suggestion": false
},
"testbot-dev": {
"link": "https://berty.tech/id#contact/oZBLFG6fwy21Dn4o511HC6ghxEghB5apq2QhjFepXCkbhfCWjzvRzhetVCGYwWhCtrWVL1TmExtHvdgGBvx1WK1RnXTdato/name=TestBot-Dev",
"name": "TestBot Dev",
"description": "TestBot-Dev",
- "kind": "Bot"
+ "kind": "Bot",
+ "suggestion": false
}
},
"conversations": {
"dev-test": {
"link": "https://berty.tech/id#group/5QdUv6Fn3uvi3AchNcqFECaZvngDzWGUJV4wntYCWuYyjXrNi4ykvnP2ZCeWA1YLTmCSFbZaimXzp8rZtkKqby8nGv7S2AXyJPggo3aMghJS3rpeuDx6pbbNqEoNXJK67pWVpcLB6VrXM54zRNbi4zhEsLdATGzguWoruShcRHzFpuP75nyvRnXnfRaHPjdbyC/name=Dev+Test",
"name": "Dev Test",
- "description": "Simple Conversation with Replication"
+ "description": "Simple Conversation with Replication",
+ "suggestion": false
},
"dev-test-2": {
"link": "https://berty.tech/id#group/5QdUv6Fn3uwSPQZpLUXcNpQ24bR9y1TUK6xJfE9khJo4jrP8jF4QfdgpTT73Us58y6XZhtvJHLDCouXfgsKDxXqZAsfLDhUZLb48PDcBYYVUk7nzxh1MKh5a6Ug1bP4KpdrVDYQx1gCZA4HZavEUgUBbC1pYBZ2DaY27sCMfqxpt79RjZCBwmVqW1DbbuYCUoc/name=Dev+Test+2",
"name": "Dev Test 2",
- "description": "Simple Conversation with Replication"
+ "description": "Simple Conversation with Replication",
+ "suggestion": false
},
"group-with-passphrase": {
"link": "https://berty.tech/id#enc/3KE388cyt693i3Y8FUK1HMwr6BQGuckRx8ypxdtmrFrmMvgb8JNeu8L8BSkL6MbNjyFR4jSgEDmerbmGSXPsoVrbmrprcKX3PG3a2EY4jF2D7BUUdg1kDpxewAcHMyVRW66yMTe29G6sjuJ8C2MjEUWMWT7oX3jv94aCvWQbomePYL6ff9Bm8Msbe3UXBgqN6Wff9QqEScsMG9WnKUQQLtKxSqwN59etjrz/name=group-with-passphrase",
"name": "Group with passphrase (test)",
- "description": "A demo group with a passphrase"
+ "description": "A demo group with a passphrase",
+ "suggestion": false
}
}
},
diff --git a/config/config.yml b/config/config.yml
index c9f40752c0..81f627fe6a 100644
--- a/config/config.yml
+++ b/config/config.yml
@@ -5,24 +5,28 @@ berty:
link: "https://berty.tech/id#contact/oZBLFkhRFWg9NXmy8wtjzZKeeUwfaWQVkUXfNY6h9z4QnGXuXSox8zs2yXeFHzt9DKJ8B4WHy7Zjy1g8tSat6ee2Jh7vp4J/name=BetaBot"
description: "Official BetaBot"
kind: "Bot"
+ suggestion: true
#icon:
testbot:
name: "TestBot"
link: "https://berty.tech/id#contact/oZBLG8gg1RTwCW2u1AxA44dT1Lum2PAr2nBra6WdmTpozq7vdDkae9FjyCW3QZ86AE9pMAudh4GKTfNj1jELcdvtJy44Rbp/name=TestBot"
description: "Official TestBot"
kind: "Bot"
+ suggestion: false
#icon:
betabot-dev:
name: "BetaBot Dev"
link: "https://berty.tech/id#contact/oZBLFQQTqmZ25yvcRRUVgzzZCpDY7YAVXDEz3g8kmwcSPCmnQrqiMbLrfSp1GRLaNBX6ZRarid8jkSUX4yQYL4oBZcLDtFY/name=BetaBot-Dev"
description: "BetaBot-Dev"
kind: "Bot"
+ suggestion: true
#icon:
testbot-dev:
name: "TestBot Dev"
link: "https://berty.tech/id#contact/oZBLFG6fwy21Dn4o511HC6ghxEghB5apq2QhjFepXCkbhfCWjzvRzhetVCGYwWhCtrWVL1TmExtHvdgGBvx1WK1RnXTdato/name=TestBot-Dev"
description: "TestBot-Dev"
kind: "Bot"
+ suggestion: false
#icon:
#support:
#staff:
@@ -32,14 +36,17 @@ berty:
link: "https://berty.tech/id#group/5QdUv6Fn3uvi3AchNcqFECaZvngDzWGUJV4wntYCWuYyjXrNi4ykvnP2ZCeWA1YLTmCSFbZaimXzp8rZtkKqby8nGv7S2AXyJPggo3aMghJS3rpeuDx6pbbNqEoNXJK67pWVpcLB6VrXM54zRNbi4zhEsLdATGzguWoruShcRHzFpuP75nyvRnXnfRaHPjdbyC/name=Dev+Test"
name: "Dev Test"
description: "Simple Conversation with Replication"
+ suggestion: false
dev-test-2:
link: "https://berty.tech/id#group/5QdUv6Fn3uwSPQZpLUXcNpQ24bR9y1TUK6xJfE9khJo4jrP8jF4QfdgpTT73Us58y6XZhtvJHLDCouXfgsKDxXqZAsfLDhUZLb48PDcBYYVUk7nzxh1MKh5a6Ug1bP4KpdrVDYQx1gCZA4HZavEUgUBbC1pYBZ2DaY27sCMfqxpt79RjZCBwmVqW1DbbuYCUoc/name=Dev+Test+2"
name: "Dev Test 2"
description: "Simple Conversation with Replication"
+ suggestion: false
group-with-passphrase:
link: "https://berty.tech/id#enc/3KE388cyt693i3Y8FUK1HMwr6BQGuckRx8ypxdtmrFrmMvgb8JNeu8L8BSkL6MbNjyFR4jSgEDmerbmGSXPsoVrbmrprcKX3PG3a2EY4jF2D7BUUdg1kDpxewAcHMyVRW66yMTe29G6sjuJ8C2MjEUWMWT7oX3jv94aCvWQbomePYL6ff9Bm8Msbe3UXBgqN6Wff9QqEScsMG9WnKUQQLtKxSqwN59etjrz/name=group-with-passphrase"
name: "Group with passphrase (test)"
description: "A demo group with a passphrase"
+ suggestion: false
p2p:
rdvp:
# svc fr
diff --git a/go/internal/config/config.gen.go b/go/internal/config/config.gen.go
index 3dc9c5ac39..078e72f98e 100644
--- a/go/internal/config/config.gen.go
+++ b/go/internal/config/config.gen.go
@@ -19,42 +19,49 @@ func init() {
"link": "https://berty.tech/id#contact/oZBLFkhRFWg9NXmy8wtjzZKeeUwfaWQVkUXfNY6h9z4QnGXuXSox8zs2yXeFHzt9DKJ8B4WHy7Zjy1g8tSat6ee2Jh7vp4J/name=BetaBot",
"name": "BetaBot",
"description": "Official BetaBot",
- "kind": "Bot"
+ "kind": "Bot",
+ "suggestion": true
},
"betabot-dev": {
"link": "https://berty.tech/id#contact/oZBLFQQTqmZ25yvcRRUVgzzZCpDY7YAVXDEz3g8kmwcSPCmnQrqiMbLrfSp1GRLaNBX6ZRarid8jkSUX4yQYL4oBZcLDtFY/name=BetaBot-Dev",
"name": "BetaBot Dev",
"description": "BetaBot-Dev",
- "kind": "Bot"
+ "kind": "Bot",
+ "suggestion": true
},
"testbot": {
"link": "https://berty.tech/id#contact/oZBLG8gg1RTwCW2u1AxA44dT1Lum2PAr2nBra6WdmTpozq7vdDkae9FjyCW3QZ86AE9pMAudh4GKTfNj1jELcdvtJy44Rbp/name=TestBot",
"name": "TestBot",
"description": "Official TestBot",
- "kind": "Bot"
+ "kind": "Bot",
+ "suggestion": false
},
"testbot-dev": {
"link": "https://berty.tech/id#contact/oZBLFG6fwy21Dn4o511HC6ghxEghB5apq2QhjFepXCkbhfCWjzvRzhetVCGYwWhCtrWVL1TmExtHvdgGBvx1WK1RnXTdato/name=TestBot-Dev",
"name": "TestBot Dev",
"description": "TestBot-Dev",
- "kind": "Bot"
+ "kind": "Bot",
+ "suggestion": false
}
},
"conversations": {
"dev-test": {
"link": "https://berty.tech/id#group/5QdUv6Fn3uvi3AchNcqFECaZvngDzWGUJV4wntYCWuYyjXrNi4ykvnP2ZCeWA1YLTmCSFbZaimXzp8rZtkKqby8nGv7S2AXyJPggo3aMghJS3rpeuDx6pbbNqEoNXJK67pWVpcLB6VrXM54zRNbi4zhEsLdATGzguWoruShcRHzFpuP75nyvRnXnfRaHPjdbyC/name=Dev+Test",
"name": "Dev Test",
- "description": "Simple Conversation with Replication"
+ "description": "Simple Conversation with Replication",
+ "suggestion": false
},
"dev-test-2": {
"link": "https://berty.tech/id#group/5QdUv6Fn3uwSPQZpLUXcNpQ24bR9y1TUK6xJfE9khJo4jrP8jF4QfdgpTT73Us58y6XZhtvJHLDCouXfgsKDxXqZAsfLDhUZLb48PDcBYYVUk7nzxh1MKh5a6Ug1bP4KpdrVDYQx1gCZA4HZavEUgUBbC1pYBZ2DaY27sCMfqxpt79RjZCBwmVqW1DbbuYCUoc/name=Dev+Test+2",
"name": "Dev Test 2",
- "description": "Simple Conversation with Replication"
+ "description": "Simple Conversation with Replication",
+ "suggestion": false
},
"group-with-passphrase": {
"link": "https://berty.tech/id#enc/3KE388cyt693i3Y8FUK1HMwr6BQGuckRx8ypxdtmrFrmMvgb8JNeu8L8BSkL6MbNjyFR4jSgEDmerbmGSXPsoVrbmrprcKX3PG3a2EY4jF2D7BUUdg1kDpxewAcHMyVRW66yMTe29G6sjuJ8C2MjEUWMWT7oX3jv94aCvWQbomePYL6ff9Bm8Msbe3UXBgqN6Wff9QqEScsMG9WnKUQQLtKxSqwN59etjrz/name=group-with-passphrase",
"name": "Group with passphrase (test)",
- "description": "A demo group with a passphrase"
+ "description": "A demo group with a passphrase",
+ "suggestion": false
}
}
},
diff --git a/go/pkg/protocoltypes/config.go b/go/pkg/protocoltypes/config.go
index ed8d340616..c7933424d1 100644
--- a/go/pkg/protocoltypes/config.go
+++ b/go/pkg/protocoltypes/config.go
@@ -8,11 +8,13 @@ type Config struct {
Name string `json:"name"`
Description string `json:"description"`
Kind string `json:"kind"`
+ Suggestion bool `json:"suggestion"`
} `json:"contacts"`
Conversations map[string]struct {
Link string `json:"link"`
Name string `json:"name"`
Description string `json:"description"`
+ Suggestion bool `json:"suggestion"`
} `json:"conversations"`
} `json:"berty"`
P2P struct {
diff --git a/js/packages/components/avatars.tsx b/js/packages/components/avatars.tsx
index 4f03166aee..b8c0cbf6ba 100644
--- a/js/packages/components/avatars.tsx
+++ b/js/packages/components/avatars.tsx
@@ -3,14 +3,7 @@ import Jdenticon from 'react-native-jdenticon'
import { Image, View, ViewStyle } from 'react-native'
import { useStyles } from '@berty-tech/styles'
-import {
- useAccount,
- useContact,
- useMember,
- useConversation,
- Maybe,
- usePersistentOptions,
-} from '@berty-tech/store/hooks'
+import { useAccount, useContact, useMember, useConversation, Maybe } from '@berty-tech/store/hooks'
import beapi from '@berty-tech/api'
import AttachmentImage from './AttachmentImage'
@@ -70,9 +63,17 @@ const GenericAvatar: React.FC<{
)
}
-const BetabotAvatar: React.FC<{ size: number; style?: AvatarStyle }> = ({ size, style }) => {
+export const BotAvatar: React.FC<{ size: number; style?: AvatarStyle }> = ({ size, style }) => {
const [{ border, flex, background }] = useStyles()
-
+ const padding = Math.round(size / 15)
+ let innerSize = Math.round(size - 2 * padding)
+ if (innerSize % 2) {
+ innerSize--
+ }
+ let iconSize = Math.round(innerSize - innerSize / 8)
+ if (iconSize % 2) {
+ iconSize--
+ }
return (
= ({ size,
},
]}
>
-
+
)
}
@@ -111,15 +112,6 @@ export const ContactAvatar: React.FC<{
style?: AvatarStyle
}> = ({ publicKey, size, style }) => {
const contact = useContact(publicKey)
- const persistOpts = usePersistentOptions()
-
- if (
- persistOpts.betabot.convPk &&
- publicKey?.toString() === persistOpts.betabot.convPk.toString()
- ) {
- return
- }
-
return (
{
const [{ margin }] = useStyles()
@@ -34,6 +34,10 @@ const SelectedContent: React.FC<{ contentName: string; publicKey: string }> = ({
const ContactSettingsHeader: React.FC<{ contact: any }> = ({ contact }) => {
const [{ border, background, padding, row, absolute, text }] = useStyles()
const [selectedContent, setSelectedContent] = useState('Fingerprint')
+ const ctx = useMsgrContext()
+ const isSuggestion = Object.values(ctx.persistentOptions?.suggestions).find(
+ (v: any) => v.pk === contact?.publicKey,
+ )
const { t } = useTranslation()
return (
@@ -47,7 +51,11 @@ const ContactSettingsHeader: React.FC<{ contact: any }> = ({ contact }) => {
]}
>
-
+ {isSuggestion ? (
+
+ ) : (
+
+ )}
diff --git a/js/packages/components/chat/OneToOne.tsx b/js/packages/components/chat/OneToOne.tsx
index effd74a147..a943a1989e 100644
--- a/js/packages/components/chat/OneToOne.tsx
+++ b/js/packages/components/chat/OneToOne.tsx
@@ -20,14 +20,12 @@ import { groupBy } from 'lodash'
import { useStyles } from '@berty-tech/styles'
import { Routes, ScreenProps, useNavigation } from '@berty-tech/navigation'
import beapi from '@berty-tech/api'
-import { PersistentOptionsKeys } from '@berty-tech/store/context'
import {
useContact,
useConversation,
useMsgrContext,
useReadEffect,
useSortedConvInteractions,
- usePersistentOptions,
useClient,
useNotificationsInhibitor,
} from '@berty-tech/store/hooks'
@@ -36,47 +34,17 @@ import { Message } from './message'
import { MessageInvitationButton } from './message/MessageInvitation'
import { MessageSystemWrapper } from './message/MessageSystemWrapper'
import BlurView from '../shared-components/BlurView'
-import { ContactAvatar } from '../avatars'
+import { ContactAvatar, BotAvatar } from '../avatars'
import { pbDateToNum, timeFormat } from '../helpers'
import { useLayout } from '../hooks'
import { playSound } from '../sounds'
import { ChatDate, ChatFooter } from './common'
import { SwipeNavRecognizer } from '../shared-components/SwipeNavRecognizer'
-import Logo from '../main/1_berty_picto.svg'
-import Avatar from '../modals/Buck_Berty_Icon_Card.svg'
//
// Chat
//
-const useStylesAddBetabot = () => {
- const [{ width, border, padding, margin }] = useStyles()
- return {
- skipButton: [
- border.color.light.grey,
- border.scale(2),
- border.radius.small,
- margin.top.scale(15),
- padding.left.small,
- padding.right.medium,
- padding.top.small,
- padding.bottom.small,
- width(120),
- ],
- addButton: [
- border.color.light.blue,
- border.scale(2),
- border.radius.small,
- margin.top.scale(15),
- padding.left.small,
- padding.right.medium,
- padding.top.small,
- padding.bottom.small,
- width(120),
- ],
- }
-}
-
const useStylesOneToOne = () => {
const [{ text }] = useStyles()
return {
@@ -93,21 +61,15 @@ const CenteredActivityIndicator: React.FC = (props: ActivityIndicator['props'])
)
}
-export const ChatHeader: React.FC = ({ convPk, stickyDate, showStickyDate }) => {
+export const ChatHeader: React.FC = ({ convPk, stickyDate, showStickyDate, isSuggestion }) => {
const { navigate, goBack } = useNavigation()
const conv = useConversation(convPk)
const contact = useContact(conv?.contactPublicKey || null)
- const [
- { row, padding, column, margin, text, flex, opacity, color, border, background },
- ] = useStyles()
+ const [{ row, padding, column, margin, text, flex, opacity, color }] = useStyles()
const [layoutHeader, onLayoutHeader] = useLayout() // to position date under blur
- const persistOpts = usePersistentOptions()
- const isBetabot =
- persistOpts && conv?.contactPublicKey?.toString() === persistOpts?.betabot?.convPk?.toString()
-
if (!conv || !contact) {
goBack()
console.warn('OneToOne: no conv', conv, contact)
@@ -176,27 +138,10 @@ export const ChatHeader: React.FC = ({ convPk, stickyDate, showStickyDate }
style={[flex.tiny, row.item.justify, !contact ? opacity(0.5) : null]}
onPress={() => navigate.chat.oneToOneSettings({ convId: convPk })}
>
- {!isBetabot ? (
-
+ {isSuggestion ? (
+
) : (
-
-
-
+
)}
@@ -332,156 +277,10 @@ const ContactRequestBox: React.FC<{ contact: any; isAccepted: boolean }> = ({
)
}
-export const AddBetabotBox = () => {
- const [
- { row, text, margin, color, padding, background, border, opacity },
- { scaleHeight },
- ] = useStyles()
- const _styles = useStylesAddBetabot()
- const { setPersistentOption, persistentOptions } = useMsgrContext()
-
- return (
-
- {(t: any): React.ReactNode => (
-
-
-
-
-
-
-
-
- {t('chat.one-to-one.betabot-box.title')}
-
-
-
- {t('chat.one-to-one.betabot-box.desc')}
-
-
-
-
-
-
-
- {t('chat.one-to-one.betabot-box.skip-button')}
-
-
- {
- await setPersistentOption({
- type: PersistentOptionsKeys.BetaBot,
- payload: {
- added: true,
- convPk: persistentOptions.betabot.convPk,
- },
- })
- }}
- >
-
-
- {t('chat.one-to-one.betabot-box.add-button')}
-
-
-
-
-
- )}
-
- )
-}
-
-const InfosChat: React.FC<
- beapi.messenger.IConversation & { isBetabot: boolean; isBetabotAdded: boolean }
-> = ({ createdDate: createdDateStr, publicKey, isBetabot, isBetabotAdded }) => {
+const InfosChat: React.FC = ({
+ createdDate: createdDateStr,
+ publicKey,
+}) => {
const [{ flex, text, padding, margin }] = useStyles()
const { dateMessage } = useStylesOneToOne()
const createdDate = pbDateToNum(createdDateStr) || Date.now()
@@ -499,19 +298,13 @@ const InfosChat: React.FC<
{!isIncoming ? (
- <>
- {isBetabot && !isBetabotAdded ? (
-
- ) : (
-
-
- {isAccepted
- ? t('chat.one-to-one.infos-chat.connection-confirmed')
- : t('chat.one-to-one.infos-chat.request-sent')}
-
-
- )}
- >
+
+
+ {isAccepted
+ ? t('chat.one-to-one.infos-chat.connection-confirmed')
+ : t('chat.one-to-one.infos-chat.request-sent')}
+
+
) : (
@@ -588,11 +381,6 @@ const MessageList: React.FC<{
}
}, [messages, scrollToMessage])
- const persistOpts = usePersistentOptions()
- const isBetabot =
- persistOpts && conv?.contactPublicKey?.toString() === persistOpts?.betabot?.convPk?.toString()
- const isBetabotAdded = persistOpts.betabot.added
-
const items: any = React.useMemo(() => {
return messages?.reverse() || []
}, [messages])
@@ -611,7 +399,7 @@ const MessageList: React.FC<{
)
}
const renderItem: SectionListRenderItem = ({ item, index }) => {
- return isBetabot && !isBetabotAdded ? null : (
+ return (
item?.cid || `${index}`}
- ListFooterComponent={
-
- }
+ ListFooterComponent={}
renderSectionFooter={renderDateFooter}
renderItem={renderItem}
onViewableItemsChanged={updateStickyDate}
@@ -685,20 +471,17 @@ export const OneToOne: React.FC = ({ route: { params
Object.values(ctx.contacts).find((c: any) => c.conversationPublicKey === conv?.publicKey) ||
null
const isIncoming = contact?.state === beapi.messenger.Contact.State.IncomingRequest
- const persistOpts = usePersistentOptions()
- const isBetabot =
- persistOpts && conv?.contactPublicKey?.toString() === persistOpts?.betabot?.convPk?.toString()
- const isBetabotAdded = persistOpts && persistOpts?.betabot?.added
- const isFooterDisable = isIncoming || (isBetabot && !isBetabotAdded)
+ const isFooterDisable = isIncoming
const placeholder = isFooterDisable
- ? isBetabot
- ? t('chat.one-to-one.betabot-input-placeholder')
- : t('chat.one-to-one.incoming-input-placeholder')
+ ? t('chat.one-to-one.incoming-input-placeholder')
: t('chat.one-to-one.input-placeholder')
const [stickyDate, setStickyDate] = useState(conv?.lastUpdate || null)
const [showStickyDate, setShowStickyDate] = useState(false)
const [isSwipe, setSwipe] = useState(true)
+ const isSuggestion = Object.values(ctx.persistentOptions?.suggestions).find(
+ (v: any) => v.pk === contact?.publicKey,
+ )
return (
@@ -730,7 +513,11 @@ export const OneToOne: React.FC = ({ route: { params
placeholder={placeholder}
setSwipe={setSwipe}
/>
-
+
diff --git a/js/packages/components/chat/OneToOneSettings.tsx b/js/packages/components/chat/OneToOneSettings.tsx
index d7eda70e01..de09e2684c 100644
--- a/js/packages/components/chat/OneToOneSettings.tsx
+++ b/js/packages/components/chat/OneToOneSettings.tsx
@@ -5,13 +5,13 @@ import { useTranslation } from 'react-i18next'
import beapi from '@berty-tech/api'
import { ScreenProps, useNavigation } from '@berty-tech/navigation'
-import { useContact, useConversation } from '@berty-tech/store/hooks'
+import { useContact, useConversation, useMsgrContext } from '@berty-tech/store/hooks'
import { useStyles } from '@berty-tech/styles'
import HeaderSettings from '../shared-components/Header'
import { ButtonSetting, ButtonSettingRow } from '../shared-components/SettingsButtons'
import { SwipeNavRecognizer } from '../shared-components/SwipeNavRecognizer'
-import { ContactAvatar } from '../avatars'
+import { BotAvatar, ContactAvatar } from '../avatars'
//
// OneToOneSettings
@@ -30,11 +30,18 @@ const useStylesOneToOne = () => {
const OneToOneHeader: React.FC<{ contact: any }> = ({ contact }) => {
const _styles = useStylesOneToOne()
+ const ctx = useMsgrContext()
const [{ text, padding }] = useStyles()
-
+ const isSuggestion = Object.values(ctx.persistentOptions?.suggestions).find(
+ (v: any) => v.pk === contact?.publicKey,
+ )
return (
-
+ {isSuggestion ? (
+
+ ) : (
+
+ )}
+ suggestions: Array
+ addBot: any
}
type ConversationsItemProps = any
@@ -352,7 +354,6 @@ const ConversationsItem: React.FC = (props) => {
fake = false,
type = beapi.messenger.Conversation.Type.ContactType,
unreadCount,
- contactPublicKey,
createdDate,
lastUpdate,
} = props
@@ -370,25 +371,18 @@ const ConversationsItem: React.FC = (props) => {
const [{ color, row, border, flex, padding, text, opacity, margin }] = useStyles()
const { dispatch } = useNavigation()
+ const isSuggestion = Object.values(ctx.persistentOptions?.suggestions).find(
+ (v: any) => v.pk === contact?.publicKey,
+ )
- const persistOpts = usePersistentOptions()
- const isBetabot =
- persistOpts.betabot.convPk &&
- type !== beapi.messenger.Conversation.Type.MultiMemberType &&
- contactPublicKey.toString() === persistOpts.betabot.convPk.toString()
- const isBetabotAdded = persistOpts.betabot.added
let description
- if (isBetabot && !isBetabotAdded) {
- description = 'Click here to add the Beta Bot!'
+ if (lastInte?.type === beapi.messenger.AppMessage.Type.TypeUserMessage) {
+ description = (lastInte.payload as any)?.body
} else {
- if (lastInte?.type === beapi.messenger.AppMessage.Type.TypeUserMessage) {
- description = (lastInte.payload as any)?.body
+ if (contact?.state === beapi.messenger.Contact.State.OutgoingRequestSent) {
+ description = 'Request is sent. Pending...'
} else {
- if (contact?.state === beapi.messenger.Contact.State.OutgoingRequestSent) {
- description = 'Request is sent. Pending...'
- } else {
- description = ''
- }
+ description = ''
}
}
@@ -463,7 +457,11 @@ const ConversationsItem: React.FC = (props) => {
},
]}
>
-
+ {isSuggestion ? (
+
+ ) : (
+
+ )}
= (props) => {
{ marginLeft: 'auto' },
]}
>
- {isBetabot && !isBetabotAdded ? null : (
- <>
-
- {displayDate && (
-
- {timeFormat.fmtTimestamp1(displayDate)}
-
- )}
- >
- )}
+ <>
+
+ {displayDate && (
+
+ {timeFormat.fmtTimestamp1(displayDate)}
+
+ )}
+ >
= (props) => {
style={[
{ flexGrow: 2, flexShrink: 1 },
text.size.small,
- unreadCount
- ? isBetabot && !isBetabotAdded
- ? text.color.grey
- : [text.bold.medium, text.color.black]
- : text.color.grey,
+ unreadCount ? [text.bold.medium, text.color.black] : text.color.grey,
]}
>
{description}
@@ -570,19 +562,119 @@ const ConversationsItem: React.FC = (props) => {
- {isBetabot && !isBetabotAdded && (
-
-
-
- )}
) : null
}
-const Conversations: React.FC = ({ items, style, onLayout }) => {
+const SuggestionsItem: React.FC<{ displayName: string; link: string; addBot: any }> = ({
+ displayName,
+ link,
+ addBot,
+}) => {
+ const [{ color, row, border, flex, padding, text, margin }] = useStyles()
+ return (
+ <>
+ addBot({ displayName, link, isVisible: true })}
+ >
+
+
+
+
+
+ {/* Conversation title, unread count, and time */}
+
+ {/* Title */}
+
+
+ {displayName}
+
+
+
+
+
+ {`Click here to add ${displayName}`}
+
+ {/* Message status */}
+
+
+
+
+
+
+
+ >
+ )
+}
+
+const Conversations: React.FC = ({
+ items,
+ suggestions,
+ style,
+ onLayout,
+ addBot,
+}) => {
const [{ background }] = useStyles()
- return items?.length ? (
+ return items.length || suggestions.length ? (
{(insets) => (
= ({ items, style, onLayout })
{ paddingBottom: 100 - (insets?.bottom || 0) + (insets?.bottom || 0) },
]}
>
- {items &&
- items.length &&
- items.map((i) => )}
+ {items.map((i) => (
+
+ ))}
+ {suggestions.map((i: any) => (
+
+ ))}
)}
@@ -942,6 +1037,11 @@ export const Home: React.FC = () => {
const [searchText, setSearchText] = useState('')
const [refresh, setRefresh] = useState(false)
const [isModalVisible, setModalVisibility] = useState(false)
+ const [isAddBot, setIsAddBot] = useState({
+ link: '',
+ displayName: '',
+ isVisible: false,
+ })
const { navigate } = useNativeNavigation()
@@ -960,6 +1060,10 @@ export const Home: React.FC = () => {
)
const ctx = useMsgrContext()
+ const suggestions = Object.values(ctx.persistentOptions?.suggestions).filter(
+ (i: any) => i.state === 'unread',
+ )
+ const isSuggestion: number = suggestions.length
const searchConversations = React.useMemo(
() =>
@@ -1057,9 +1161,13 @@ export const Home: React.FC = () => {
/>
) : (
<>
- {isConversation ? (
-
- ) : (
+
+ {!isConversation && !isSuggestion && (
= () => {
setModalVisibility(false)} />
>
)}
+
{!searchText?.length && (