From 4549e09a2c4c7d6e855ff9e3f6cd03138c802aab Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Mon, 16 Dec 2024 16:18:19 +0530 Subject: [PATCH 1/7] upgrade deps and fix breaking changes --- package-lock.json | 8 +- package.json | 2 +- .../hooks/permissions/useSecurityContext.ts | 2 +- .../__tests__/RNPostReactionProvider.test.ts | 4 +- .../__tests__/RNPostUploadProvider.test.ts | 9 +-- .../components/Chat/Chat-Connected-state.tsx | 4 +- .../Chat/Chat-Delivery-Indicator.tsx | 2 +- .../src/components/Chat/Chat-Reaction.tsx | 2 +- .../mobile/src/components/Chat/ChatDetail.tsx | 2 + .../src/components/Chat/Conversation-tile.tsx | 2 +- .../Chat/SearchConversationsResults.tsx | 4 +- .../src/components/Contact/NoContacts.tsx | 2 +- .../src/components/Dashboard/Dashboard.tsx | 2 +- .../Dashboard/NotificationsOverview.tsx | 4 +- .../Feed/Article/ArticleComposer.tsx | 2 +- .../components/Feed/Detail/PostDetailCard.tsx | 2 +- .../Interacts/Comments/CommentComposer.tsx | 2 +- .../Feed/Interacts/Comments/CommentHead.tsx | 2 +- .../Feed/Interacts/Comments/CommentMeta.tsx | 2 +- .../Feed/Interacts/PostInteracts.tsx | 4 +- .../Reactions/PostEmojiPickerModal.tsx | 2 +- .../Interacts/Reactions/PostReactionBar.tsx | 2 +- .../MainContent/PostDetailMainContent.tsx | 2 +- .../src/components/Feed/Meta/Actions.tsx | 4 +- .../mobile/src/components/Feed/Meta/Meta.tsx | 8 +- .../src/components/Feed/PostTeaserCard.tsx | 2 +- .../ui/Alert/NotificationToaster.tsx | 2 +- .../src/components/ui/DoubleTapHeart.tsx | 2 +- packages/mobile/src/components/ui/Name.tsx | 2 +- .../ui/OdinImage/hooks/useImage.tsx | 2 +- packages/mobile/src/hooks/auth/useAuth.ts | 6 +- .../mobile/src/hooks/chat/useChatMessage.ts | 80 +++++++++---------- .../mobile/src/hooks/chat/useChatMessages.ts | 18 ++--- .../mobile/src/hooks/chat/useChatReaction.ts | 6 +- .../mobile/src/hooks/chat/useConversation.ts | 2 +- .../src/hooks/chat/useLiveChatProcessor.ts | 12 +-- .../src/hooks/chat/useMarkMessagesAsRead.ts | 4 +- .../src/hooks/feed/channels/useChannel.ts | 2 +- .../mobile/src/hooks/feed/post/usePost.ts | 2 +- .../src/hooks/feed/post/usePostsInfinite.ts | 32 ++++---- .../mobile/src/hooks/image/useRawImage.ts | 2 +- .../mobile/src/hooks/links/useLinkPreview.ts | 2 +- .../mobile/src/hooks/profile/useProfile.ts | 2 +- .../useInitialPushNotification.ts | 2 +- .../reactions/comments/useCommentMedia.tsx | 2 +- .../reactions/emojis/useMyEmojiReactions.tsx | 2 +- .../src/hooks/reactions/useCanReact.tsx | 4 +- .../securityContext/useSecurityContext.ts | 24 ------ .../mobile/src/hooks/video/useHlsManifest.ts | 4 +- packages/mobile/src/hooks/video/useVideo.ts | 2 +- .../src/hooks/video/useVideoMetadata.ts | 12 +-- .../mobile/src/pages/chat/archived-page.tsx | 2 +- .../src/pages/chat/message-info-page.tsx | 4 +- .../mobile/src/pages/conversations-page.tsx | 2 +- .../mobile/src/pages/feed/post-composer.tsx | 2 +- .../src/pages/feed/post-detail-page.tsx | 2 +- .../mobile/src/pages/media-preview-page.tsx | 2 +- .../src/pages/profile/connect-qr-page.tsx | 2 +- .../profile/connection-requests-page.tsx | 2 +- .../src/pages/profile/connections-page.tsx | 2 +- .../src/pages/profile/followers-page.tsx | 2 +- .../src/pages/profile/following-page.tsx | 2 +- .../provider/auth/AuthenticationProvider.ts | 3 +- .../mobile/src/provider/chat/ChatProvider.ts | 58 +++++++------- .../src/provider/chat/ConversationProvider.ts | 75 +++++++++-------- .../provider/feed/RNPostReactionProvider.ts | 2 +- .../src/provider/feed/RNPostUploadProvider.ts | 34 ++++---- 67 files changed, 241 insertions(+), 268 deletions(-) delete mode 100644 packages/mobile/src/hooks/securityContext/useSecurityContext.ts diff --git a/package-lock.json b/package-lock.json index 329626f8..f47202f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.1", "hasInstallScript": true, "dependencies": { - "@homebase-id/js-lib": "0.0.6-alpha.2", + "@homebase-id/js-lib": "0.0.6-alpha.23", "axios": "1.7.5", "patch-package": "8.0.0", "react": "18.3.1", @@ -2677,9 +2677,9 @@ } }, "node_modules/@homebase-id/js-lib": { - "version": "0.0.6-alpha.2", - "resolved": "https://npm.pkg.github.com/download/@homebase-id/js-lib/0.0.6-alpha.2/305161c8c9ec8d62dece20c307547bce3ed777f1", - "integrity": "sha512-V3+jStGRwMpQViAndNU3yaebwgmgmyrIy3gI8N913NILxuADgBqvRYWewB4weBN+WDkaOMGL9NDTLUbcXPIj2Q==", + "version": "0.0.6-alpha.23", + "resolved": "https://npm.pkg.github.com/download/@homebase-id/js-lib/0.0.6-alpha.23/4a1b94226fd2fd4f58224d06d07625daf09b00cd", + "integrity": "sha512-78sW3Zw0vEhx84V2fxsJSWyEh6a+P7cO5ZnegqdWAxY6T2nPxJ61KsXbvAlwS7xR4HeACfXLThXNKJkk1Vp7iA==", "dependencies": { "guid-typescript": "^1.0.9" }, diff --git a/package.json b/package.json index 829a3a86..ac84a0f7 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "lint": "npm run lint -workspaces --if-present" }, "dependencies": { - "@homebase-id/js-lib": "0.0.6-alpha.2", + "@homebase-id/js-lib": "0.0.6-alpha.23", "axios": "1.7.5", "patch-package": "8.0.0", "react": "18.3.1", diff --git a/packages/common/src/hooks/permissions/useSecurityContext.ts b/packages/common/src/hooks/permissions/useSecurityContext.ts index e983942c..a339c44e 100644 --- a/packages/common/src/hooks/permissions/useSecurityContext.ts +++ b/packages/common/src/hooks/permissions/useSecurityContext.ts @@ -8,7 +8,7 @@ export const useSecurityContext = (odinId?: string, isEnabled?: boolean) => { const fetch = async (odinId?: string) => { if ( !odinId || - (dotYouClient.getType() === ApiType.App && odinId === dotYouClient.getIdentity()) + (dotYouClient.getType() === ApiType.App && odinId === dotYouClient.getLoggedInIdentity()) ) { return await getSecurityContext(dotYouClient); } else return await getSecurityContextOverPeer(dotYouClient, odinId); diff --git a/packages/mobile/__tests__/RNPostReactionProvider.test.ts b/packages/mobile/__tests__/RNPostReactionProvider.test.ts index 46ec9932..f0c88612 100644 --- a/packages/mobile/__tests__/RNPostReactionProvider.test.ts +++ b/packages/mobile/__tests__/RNPostReactionProvider.test.ts @@ -101,7 +101,7 @@ describe('RNPostReactionProvider', () => { beforeEach(() => { const mockGetRandom16Bytes = jest.fn().mockReturnValue(new Uint8Array(16)); (getRandom16ByteArray as jest.Mock) = mockGetRandom16Bytes; - dotYouClient.getIdentity = jest.fn().mockReturnValue('frodobaggins.me'); + dotYouClient.getLoggedInIdentity(); = jest.fn().mockReturnValue('frodobaggins.me'); dotYouClient.getSharedSecret = jest.fn().mockReturnValue(new Uint8Array(32)); context = { @@ -217,7 +217,7 @@ describe('RNPostReactionProvider', () => { }); it('should handle local comments correctly', async () => { - context.odinId = dotYouClient.getIdentity(); + context.odinId = dotYouClient.getLoggedInIdentity(); const result = await saveComment(dotYouClient, context, comment); expect(result).toBeDefined(); }); diff --git a/packages/mobile/__tests__/RNPostUploadProvider.test.ts b/packages/mobile/__tests__/RNPostUploadProvider.test.ts index a8ec8dea..7a2caef4 100644 --- a/packages/mobile/__tests__/RNPostUploadProvider.test.ts +++ b/packages/mobile/__tests__/RNPostUploadProvider.test.ts @@ -60,7 +60,7 @@ describe('RNPostUploadProvider', () => { let onVersionConflict: jest.Mock; let onUpdate: jest.Mock; const dotYouClient = new DotYouClient({ - identity: 'frodobaggins.me', + loggedInIdentity: 'frodobaggins.me', api: ApiType.App, headers: {}, sharedSecret: new Uint8Array(32), @@ -69,7 +69,7 @@ describe('RNPostUploadProvider', () => { beforeEach(() => { const mockGetRandom16Bytes = jest.fn().mockReturnValue(new Uint8Array(16)); (getRandom16ByteArray as jest.Mock) = mockGetRandom16Bytes; - dotYouClient.getIdentity = jest.fn().mockReturnValue('frodobaggins.me'); + dotYouClient.getLoggedInIdentity = jest.fn().mockReturnValue('frodobaggins.me'); dotYouClient.getSharedSecret = jest.fn().mockReturnValue(new Uint8Array(32)); (getFileHeader as jest.Mock).mockClear(); file = { @@ -78,7 +78,7 @@ describe('RNPostUploadProvider', () => { versionTag: 'old-version-tag', appData: { content: { - authorOdinId: dotYouClient.getIdentity(), + authorOdinId: dotYouClient.getLoggedInIdentity(), type: 'Tweet', caption: 'Here is a demo caption', id: 'random-guid-id', @@ -164,7 +164,6 @@ describe('RNPostUploadProvider', () => { const fileHeader: HomebaseFile = { fileId: 'existing-file-id', - priority: 0, sharedSecretEncryptedKeyHeader: { encryptedAesKey: new Uint8Array(32), iv: new Uint8Array(16), @@ -222,7 +221,6 @@ describe('RNPostUploadProvider', () => { const fileHeader: HomebaseFile = { fileId: 'existing-file-id', - priority: 0, sharedSecretEncryptedKeyHeader: { encryptedAesKey: new Uint8Array(32), iv: new Uint8Array(16), @@ -321,7 +319,6 @@ describe('RNPostUploadProvider', () => { const fileHeader: HomebaseFile = { fileId: 'existing-file-id', - priority: 0, sharedSecretEncryptedKeyHeader: { encryptedAesKey: new Uint8Array(32), iv: new Uint8Array(16), diff --git a/packages/mobile/src/components/Chat/Chat-Connected-state.tsx b/packages/mobile/src/components/Chat/Chat-Connected-state.tsx index 92aa4eb3..d3f539e7 100644 --- a/packages/mobile/src/components/Chat/Chat-Connected-state.tsx +++ b/packages/mobile/src/components/Chat/Chat-Connected-state.tsx @@ -20,7 +20,7 @@ import TextButton from '../ui/Text/Text-Button'; export const ChatConnectedState = (conversation: HomebaseFile | undefined) => { const { isDarkMode } = useDarkMode(); - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const [expanded, setExpanded] = useState(false); const validRecipientsState = useSharedValue([]); const sharedExpanded = useSharedValue(false); @@ -172,7 +172,7 @@ const RecipientConnectedState = ({ }) => { const { data: isConnected, isFetched: isFetchedConnected } = useIsConnected(recipient); - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); useEffect(() => { if (!isConnected && isFetchedConnected) { diff --git a/packages/mobile/src/components/Chat/Chat-Delivery-Indicator.tsx b/packages/mobile/src/components/Chat/Chat-Delivery-Indicator.tsx index dc6a282b..26d92982 100644 --- a/packages/mobile/src/components/Chat/Chat-Delivery-Indicator.tsx +++ b/packages/mobile/src/components/Chat/Chat-Delivery-Indicator.tsx @@ -16,7 +16,7 @@ export const ChatDeliveryIndicator = ({ showDefaultColor?: boolean; onPress?: () => void; }) => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const content = msg.fileMetadata.appData.content; const authorOdinId = msg.fileMetadata.senderOdinId || identity; const messageFromMe = !authorOdinId || authorOdinId === identity; diff --git a/packages/mobile/src/components/Chat/Chat-Reaction.tsx b/packages/mobile/src/components/Chat/Chat-Reaction.tsx index 3102df8b..6c81d54d 100644 --- a/packages/mobile/src/components/Chat/Chat-Reaction.tsx +++ b/packages/mobile/src/components/Chat/Chat-Reaction.tsx @@ -93,7 +93,7 @@ const ChatReaction = memo( messageGlobalTransitId: selectedMessage?.selectedMessage?.fileMetadata.globalTransitId, }); - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const { data: reactions } = get; const myReactions = useMemo( () => reactions?.filter((reaction) => reaction?.authorOdinId === identity) || [], diff --git a/packages/mobile/src/components/Chat/ChatDetail.tsx b/packages/mobile/src/components/Chat/ChatDetail.tsx index e326b11a..286aa093 100644 --- a/packages/mobile/src/components/Chat/ChatDetail.tsx +++ b/packages/mobile/src/components/Chat/ChatDetail.tsx @@ -999,6 +999,7 @@ const RenderBubble = memo( // has pauload and no text but no audio payload const hasPayloadandNoText = + message?.fileMetadata.payloads && message?.fileMetadata.payloads?.length > 0 && !content?.message && !message?.fileMetadata?.payloads?.some( @@ -1255,6 +1256,7 @@ const RenderReplyMessageView = memo( )} {replyMessage && + replyMessage.fileMetadata.payloads && replyMessage.fileMetadata.payloads?.length > 0 && replyMessage.fileMetadata.payloads[0].contentType.startsWith('image') && ( { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const { data: chatMessages } = useChatMessages({ conversationId: props.conversationId, }).all; diff --git a/packages/mobile/src/components/Chat/SearchConversationsResults.tsx b/packages/mobile/src/components/Chat/SearchConversationsResults.tsx index 60f4e827..90648047 100644 --- a/packages/mobile/src/components/Chat/SearchConversationsResults.tsx +++ b/packages/mobile/src/components/Chat/SearchConversationsResults.tsx @@ -27,7 +27,7 @@ export const SearchConversationResults = memo( const isActive = useMemo(() => !!(query && query.length >= 1), [query]); const { data: contacts } = useAllContacts(isActive); query = query?.trim().toLowerCase(); - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const conversationResults = useMemo( () => query && conversations @@ -173,7 +173,7 @@ export const SearchConversationWithSelectionResults = memo( const isActive = useMemo(() => !!(query && query.length >= 1), [query]); const { data: contacts } = useAllContacts(isActive); query = query?.trim().toLowerCase(); - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const conversationResults = useMemo( () => query && conversations diff --git a/packages/mobile/src/components/Contact/NoContacts.tsx b/packages/mobile/src/components/Contact/NoContacts.tsx index cb18c240..cbf69821 100644 --- a/packages/mobile/src/components/Contact/NoContacts.tsx +++ b/packages/mobile/src/components/Contact/NoContacts.tsx @@ -7,7 +7,7 @@ import { People } from '../ui/Icons/icons'; import { Colors } from '../../app/Colors'; export const NoContacts = () => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); return ( diff --git a/packages/mobile/src/components/Dashboard/Dashboard.tsx b/packages/mobile/src/components/Dashboard/Dashboard.tsx index acc26b26..58992fda 100644 --- a/packages/mobile/src/components/Dashboard/Dashboard.tsx +++ b/packages/mobile/src/components/Dashboard/Dashboard.tsx @@ -33,7 +33,7 @@ const AppLink = (props: { icon: FC; }) => { const { isDarkMode } = useDarkMode(); - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const { data: unreadCount } = useUnreadPushNotificationsCount({ appId: props.appId }); return ( diff --git a/packages/mobile/src/components/Dashboard/NotificationsOverview.tsx b/packages/mobile/src/components/Dashboard/NotificationsOverview.tsx index 173f5f6e..0357b500 100644 --- a/packages/mobile/src/components/Dashboard/NotificationsOverview.tsx +++ b/packages/mobile/src/components/Dashboard/NotificationsOverview.tsx @@ -114,7 +114,7 @@ const NotificationGroup = ({ const groupCount = typeGroup.length - 1; const visibleLength = isExpanded ? 10 : 3; - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const chatNavigator = useNavigation>(); const tabNavigator = useNavigation>(); @@ -190,7 +190,7 @@ const NotificationItem = ({ appName: string; }) => { const { isDarkMode } = useDarkMode(); - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const isLocalNotification = notification.senderId === identity; const { data: contactFile } = useContact( diff --git a/packages/mobile/src/components/Feed/Article/ArticleComposer.tsx b/packages/mobile/src/components/Feed/Article/ArticleComposer.tsx index a4ac52d7..adaf10c6 100644 --- a/packages/mobile/src/components/Feed/Article/ArticleComposer.tsx +++ b/packages/mobile/src/components/Feed/Article/ArticleComposer.tsx @@ -99,7 +99,7 @@ export const ArticleComposer = ({ }, [setChannel] ); - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const [isEditTeaser, setIsEditTeaser] = useState(true); const editor = useEditorBridge({ diff --git a/packages/mobile/src/components/Feed/Detail/PostDetailCard.tsx b/packages/mobile/src/components/Feed/Detail/PostDetailCard.tsx index 7226f9fa..8a08f302 100644 --- a/packages/mobile/src/components/Feed/Detail/PostDetailCard.tsx +++ b/packages/mobile/src/components/Feed/Detail/PostDetailCard.tsx @@ -40,7 +40,7 @@ export const PostDetailCard = memo( }) => { const { isDarkMode } = useDarkMode(); const doubleTapRef = useRef(); - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); if (!postFile) return ; const post = postFile.fileMetadata.appData.content; diff --git a/packages/mobile/src/components/Feed/Interacts/Comments/CommentComposer.tsx b/packages/mobile/src/components/Feed/Interacts/Comments/CommentComposer.tsx index 0e4dc2f3..9781ac45 100644 --- a/packages/mobile/src/components/Feed/Interacts/Comments/CommentComposer.tsx +++ b/packages/mobile/src/components/Feed/Interacts/Comments/CommentComposer.tsx @@ -45,7 +45,7 @@ export const CommentComposer = memo( const { isDarkMode } = useDarkMode(); const [comment, setComment] = useState(''); - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const [assets, setAssets] = useState([]); const disabled = postState === 'pending' || (comment.length === 0 && assets.length === 0); diff --git a/packages/mobile/src/components/Feed/Interacts/Comments/CommentHead.tsx b/packages/mobile/src/components/Feed/Interacts/Comments/CommentHead.tsx index 5a927178..3cb5dc7a 100644 --- a/packages/mobile/src/components/Feed/Interacts/Comments/CommentHead.tsx +++ b/packages/mobile/src/components/Feed/Interacts/Comments/CommentHead.tsx @@ -18,7 +18,7 @@ export const CommentHead = memo( setIsEdit?: (isEdit: boolean) => void; onRemove?: () => void; }) => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const isAuthor = authorOdinId === identity; const actionOptions = []; diff --git a/packages/mobile/src/components/Feed/Interacts/Comments/CommentMeta.tsx b/packages/mobile/src/components/Feed/Interacts/Comments/CommentMeta.tsx index 6e85349e..abcec72e 100644 --- a/packages/mobile/src/components/Feed/Interacts/Comments/CommentMeta.tsx +++ b/packages/mobile/src/components/Feed/Interacts/Comments/CommentMeta.tsx @@ -25,7 +25,7 @@ export const CommentMeta = memo( }) => { const isEdited = updated && updated !== 0 && updated !== created; const { mutateAsync: postReaction, error: postReactionError } = useReaction().saveEmoji; - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const doLike = () => { postReaction({ emojiData: { diff --git a/packages/mobile/src/components/Feed/Interacts/PostInteracts.tsx b/packages/mobile/src/components/Feed/Interacts/PostInteracts.tsx index f8aab249..1176fc5e 100644 --- a/packages/mobile/src/components/Feed/Interacts/PostInteracts.tsx +++ b/packages/mobile/src/components/Feed/Interacts/PostInteracts.tsx @@ -48,7 +48,7 @@ export const PostInteracts = memo( showSummary?: boolean; }) => { const postContent = postFile.fileMetadata.appData.content; - const owner = useDotYouClientContext().getIdentity(); + const owner = useDotYouClientContext().getLoggedInIdentity(); const odinId = postFile.fileMetadata.senderOdinId || owner; const postDisabledEmoji = postContent.reactAccess !== undefined && @@ -193,7 +193,7 @@ export const LikeButton = memo( canReact?: CanReactInfo; onEmojiModalOpen?: () => void; }) => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const { saveEmoji: { mutate: postEmoji, error: postEmojiError }, removeEmoji: { mutate: removeEmoji, error: removeEmojiError }, diff --git a/packages/mobile/src/components/Feed/Interacts/Reactions/PostEmojiPickerModal.tsx b/packages/mobile/src/components/Feed/Interacts/Reactions/PostEmojiPickerModal.tsx index 8f65bca7..ffc70e8e 100644 --- a/packages/mobile/src/components/Feed/Interacts/Reactions/PostEmojiPickerModal.tsx +++ b/packages/mobile/src/components/Feed/Interacts/Reactions/PostEmojiPickerModal.tsx @@ -45,7 +45,7 @@ export const PostEmojiPickerModal = forwardRef( removeEmoji: { mutate: removeEmoji, error: removeEmojiError }, } = useReaction(); const { data: myEmojis } = useMyEmojiReactions(context).fetch; - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const onSelectEmoji = useCallback( (emoji: Emoji) => { diff --git a/packages/mobile/src/components/Feed/Interacts/Reactions/PostReactionBar.tsx b/packages/mobile/src/components/Feed/Interacts/Reactions/PostReactionBar.tsx index ab09f1ad..8a56a1bf 100644 --- a/packages/mobile/src/components/Feed/Interacts/Reactions/PostReactionBar.tsx +++ b/packages/mobile/src/components/Feed/Interacts/Reactions/PostReactionBar.tsx @@ -36,7 +36,7 @@ export const PostReactionBar = memo( onClose: () => void; onEmojiModalOpen?: () => void; }) => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const { saveEmoji: { mutate: postEmoji, error: postEmojiError }, removeEmoji: { mutate: removeEmoji, error: removeEmojiError }, diff --git a/packages/mobile/src/components/Feed/MainContent/PostDetailMainContent.tsx b/packages/mobile/src/components/Feed/MainContent/PostDetailMainContent.tsx index 4bb0a6b1..82217653 100644 --- a/packages/mobile/src/components/Feed/MainContent/PostDetailMainContent.tsx +++ b/packages/mobile/src/components/Feed/MainContent/PostDetailMainContent.tsx @@ -44,7 +44,7 @@ export const PostDetailMainContent = ({ } | undefined >(); - const owner = useDotYouClientContext().getIdentity(); + const owner = useDotYouClientContext().getLoggedInIdentity(); const authorOdinId = postFile.fileMetadata.senderOdinId || owner; const postContent = postFile.fileMetadata.appData.content; diff --git a/packages/mobile/src/components/Feed/Meta/Actions.tsx b/packages/mobile/src/components/Feed/Meta/Actions.tsx index f658e3ea..9cbfbcfd 100644 --- a/packages/mobile/src/components/Feed/Meta/Actions.tsx +++ b/packages/mobile/src/components/Feed/Meta/Actions.tsx @@ -36,7 +36,7 @@ export const ExternalActions = memo( postFile: HomebaseFile; onClose?: () => void; }) => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const { removeFromFeed: { mutateAsync: removeFromMyFeed }, getReportContentUrl, @@ -108,7 +108,7 @@ export const GroupChannelActions = memo( postFile: HomebaseFile; onClose?: () => void; }) => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const isAuthor = postFile.fileMetadata.appData.content.authorOdinId === identity; const { diff --git a/packages/mobile/src/components/Feed/Meta/Meta.tsx b/packages/mobile/src/components/Feed/Meta/Meta.tsx index 6328d520..51c97fbf 100644 --- a/packages/mobile/src/components/Feed/Meta/Meta.tsx +++ b/packages/mobile/src/components/Feed/Meta/Meta.tsx @@ -56,7 +56,7 @@ export const PostMeta = memo( minute: 'numeric', }; - const identity = dotYouClient.getIdentity(); + const identity = dotYouClient.getLoggedInIdentity(); const isAuthor = authorOdinId === identity; const isConnected = useIsConnected(odinId).data; @@ -64,7 +64,7 @@ export const PostMeta = memo( const channelLink = useMemo( () => channel - ? `${odinId ? new DotYouClient({ identity: odinId, api: ApiType.Guest }).getRoot() : dotYouClient.getRoot()}/posts/${ + ? `${odinId ? new DotYouClient({ loggedInIdentity: odinId, api: ApiType.Guest }).getRoot() : dotYouClient.getRoot()}/posts/${ channel.fileMetadata.appData.content.slug }${isConnected && identity ? '?youauth-logon=' + identity : ''}` : undefined, @@ -124,7 +124,7 @@ export const ToGroupBlock = memo( | NewHomebaseFile; }) => { const dotYouClient = useDotYouClientContext(); - const identity = dotYouClient.getIdentity(); + const identity = dotYouClient.getLoggedInIdentity(); const groupPost = channel?.fileMetadata.appData.content.isCollaborative || (authorOdinId !== (odinId || identity) && (odinId || identity) && authorOdinId); @@ -133,7 +133,7 @@ export const ToGroupBlock = memo( const channelLink = useMemo( () => channel - ? `${odinId ? new DotYouClient({ identity: odinId, api: ApiType.Guest }).getRoot() : dotYouClient.getRoot()}/posts/${ + ? `${odinId ? new DotYouClient({ loggedInIdentity: odinId, api: ApiType.Guest }).getRoot() : dotYouClient.getRoot()}/posts/${ channel.fileMetadata.appData.content.slug }${isConnected && identity ? '?youauth-logon=' + identity : ''}` : undefined, diff --git a/packages/mobile/src/components/Feed/PostTeaserCard.tsx b/packages/mobile/src/components/Feed/PostTeaserCard.tsx index dac654fb..17aa350f 100644 --- a/packages/mobile/src/components/Feed/PostTeaserCard.tsx +++ b/packages/mobile/src/components/Feed/PostTeaserCard.tsx @@ -42,7 +42,7 @@ export const PostTeaserCard = memo( onMorePress?: (context: PostActionProps) => void; onEmojiModalOpen?: (context: ReactionContext) => void; }) => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const post = postFile.fileMetadata.appData.content; const odinId = postFile.fileMetadata.senderOdinId; const authorOdinId = postFile.fileMetadata.originalAuthor || odinId; diff --git a/packages/mobile/src/components/ui/Alert/NotificationToaster.tsx b/packages/mobile/src/components/ui/Alert/NotificationToaster.tsx index d4a8ba22..34854661 100644 --- a/packages/mobile/src/components/ui/Alert/NotificationToaster.tsx +++ b/packages/mobile/src/components/ui/Alert/NotificationToaster.tsx @@ -21,7 +21,7 @@ import { TabStackParamList } from '../../../app/App'; export const NotificationToaster = () => { const { route } = useRouteContext(); const dotYouClient = useDotYouClientContext(); - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const chatNavigator = useNavigation>(); const tabNavigator = useNavigation>(); const isConversationScreen = route?.name === 'Conversation' && !route.params; diff --git a/packages/mobile/src/components/ui/DoubleTapHeart.tsx b/packages/mobile/src/components/ui/DoubleTapHeart.tsx index 1d92f4dc..4ab33a21 100644 --- a/packages/mobile/src/components/ui/DoubleTapHeart.tsx +++ b/packages/mobile/src/components/ui/DoubleTapHeart.tsx @@ -29,7 +29,7 @@ export const DoubleTapHeart = memo( const opacity = useSharedValue(0); const scale = useSharedValue(1); const { mutateAsync: postEmoji, error: postEmojiError } = useReaction().saveEmoji; - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const postContent = postFile.fileMetadata.appData.content; const reactionContext: ReactionContext = useMemo(() => { return { diff --git a/packages/mobile/src/components/ui/Name.tsx b/packages/mobile/src/components/ui/Name.tsx index 00e148ec..74cda399 100644 --- a/packages/mobile/src/components/ui/Name.tsx +++ b/packages/mobile/src/components/ui/Name.tsx @@ -32,7 +32,7 @@ export const AuthorName = memo( showYou?: boolean; showFirstNameOnly?: boolean; }) => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); if (!odinId || odinId === identity) { return ( diff --git a/packages/mobile/src/components/ui/OdinImage/hooks/useImage.tsx b/packages/mobile/src/components/ui/OdinImage/hooks/useImage.tsx index 1a1075fe..3d1a2e83 100644 --- a/packages/mobile/src/components/ui/OdinImage/hooks/useImage.tsx +++ b/packages/mobile/src/components/ui/OdinImage/hooks/useImage.tsx @@ -73,7 +73,7 @@ const useImage = (props?: { const dotYouClient = useDotYouClientContext(); const queryClient = useQueryClient(); - const localHost = dotYouClient.getIdentity(); // This is the identity of the user + const localHost = dotYouClient.getLoggedInIdentity(); // This is the identity of the user const getCachedImages = ( odinId: string | undefined, diff --git a/packages/mobile/src/hooks/auth/useAuth.ts b/packages/mobile/src/hooks/auth/useAuth.ts index ff6bc203..f6a42b5d 100644 --- a/packages/mobile/src/hooks/auth/useAuth.ts +++ b/packages/mobile/src/hooks/auth/useAuth.ts @@ -172,7 +172,8 @@ export const useAuth = () => { return new DotYouClient({ sharedSecret: base64ToUint8Array(sharedSecret), api: ApiType.App, - identity: identity, + loggedInIdentity: identity, + hostIdentity: identity, headers: headers, }); }, [authToken, identity, sharedSecret]); @@ -241,8 +242,7 @@ export const useYouAuthAuthorization = () => { [CONFIRMED_CONNECTIONS_CIRCLE_ID, AUTO_CONNECTIONS_CIRCLE_ID], uint8ArrayToBase64(stringToUint8Array(JSON.stringify(publicKeyJwk))), corsHost, - `${Platform.OS === 'ios' ? 'iOS' : Platform.OS === 'android' ? 'Android' : Platform.OS} | ${ - Platform.Version + `${Platform.OS === 'ios' ? 'iOS' : Platform.OS === 'android' ? 'Android' : Platform.OS} | ${Platform.Version }` ); }, [setPrivateKey]); diff --git a/packages/mobile/src/hooks/chat/useChatMessage.ts b/packages/mobile/src/hooks/chat/useChatMessage.ts index de8c3086..4fbbe608 100644 --- a/packages/mobile/src/hooks/chat/useChatMessage.ts +++ b/packages/mobile/src/hooks/chat/useChatMessage.ts @@ -64,7 +64,7 @@ const sendMessage = async ({ const conversationId = conversation.fileMetadata.appData.uniqueId as string; const conversationContent = conversation.fileMetadata.appData.content; - const identity = dotYouClient.getIdentity(); + const identity = dotYouClient.getLoggedInIdentity(); const recipients = conversationContent.recipients.filter((recipient) => recipient !== identity); const newChatId = chatId || getNewId(); @@ -112,15 +112,15 @@ const sendMessage = async ({ newChat.fileMetadata.appData.uniqueId ) ? ({ - ...msg, - fileMetadata: { - ...msg?.fileMetadata, - payloads: (msg?.fileMetadata.payloads?.map((payload) => ({ - ...payload, - uploadProgress: { phase, progress }, - })) || []) as NewPayloadDescriptor, - }, - } as HomebaseFile) + ...msg, + fileMetadata: { + ...msg?.fileMetadata, + payloads: (msg?.fileMetadata.payloads?.map((payload) => ({ + ...payload, + uploadProgress: { phase, progress }, + })) || []) as NewPayloadDescriptor, + }, + } as HomebaseFile) : msg ), })), @@ -210,7 +210,7 @@ const sendMessage = async ({ } ); } - } catch {} + } catch { } return { key, @@ -218,8 +218,8 @@ const sendMessage = async ({ pendingFile: file.filepath || file.uri ? (new OdinBlob((file.uri || file.filepath) as string, { - type: file.type || undefined, - }) as unknown as Blob) + type: file.type || undefined, + }) as unknown as Blob) : undefined, }; }) @@ -230,7 +230,7 @@ const sendMessage = async ({ (files || [])?.map(async (file) => { try { await unlink(file.uri || file.filepath || ''); - } catch {} + } catch { } }) ); @@ -262,7 +262,7 @@ export const getSendChatMessageMutationOptions: (queryClient: QueryClient) => Us mutationKey: ['send-chat-message'], mutationFn: async (params) => sendMessage({ ...params, queryClient }), onMutate: async ({ conversation, replyId, files, message, chatId, userDate }) => { - const identity = (await getSynchronousDotYouClient()).getIdentity(); + const identity = (await getSynchronousDotYouClient()).getLoggedInIdentity(); const newMessageDsr: NewHomebaseFile = { fileMetadata: { @@ -279,11 +279,11 @@ export const getSendChatMessageMutationOptions: (queryClient: QueryClient) => Us previewThumbnail: files && files.length === 1 ? { - contentType: files[0].type as string, - content: files[0].uri || files[0].filepath || '', - pixelWidth: files[0].width, - pixelHeight: files[0].height, - } + contentType: files[0].type as string, + content: files[0].uri || files[0].filepath || '', + pixelWidth: files[0].width, + pixelHeight: files[0].height, + } : undefined, }, payloads: files?.map((file, index) => ({ @@ -292,8 +292,8 @@ export const getSendChatMessageMutationOptions: (queryClient: QueryClient) => Us pendingFile: file.filepath || file.uri ? (new OdinBlob((file.uri || file.filepath) as string, { - type: file.type || undefined, - }) as unknown as Blob) + type: file.type || undefined, + }) as unknown as Blob) : undefined, })), senderOdinId: identity, @@ -335,7 +335,7 @@ const updateMessage = async ({ }) => { const dotYouClient = await getSynchronousDotYouClient(); const conversationContent = conversation.fileMetadata.appData.content; - const identity = dotYouClient.getIdentity(); + const identity = dotYouClient.getLoggedInIdentity(); const recipients = conversationContent.recipients.filter((recipient) => recipient !== identity); await updateChatMessage(dotYouClient, updatedChatMessage, recipients); @@ -350,16 +350,16 @@ export const getUpdateChatMessageMutationOptions: (queryClient: QueryClient) => }, { extistingMessages: - | InfiniteData< - { - searchResults: (HomebaseFile | null)[]; - cursorState: string; - queryTime: number; - includeMetadataHeader: boolean; - }, - unknown - > - | undefined; + | InfiniteData< + { + searchResults: (HomebaseFile | null)[]; + cursorState: string; + queryTime: number; + includeMetadataHeader: boolean; + }, + unknown + > + | undefined; existingMessage: HomebaseFile | undefined; } > = (queryClient) => ({ @@ -434,13 +434,13 @@ export const useChatMessage = (props?: { const getMessageByUniqueId = async (conversationId: string | undefined, messageId: string) => { const extistingMessages = conversationId ? queryClient.getQueryData< - InfiniteData<{ - searchResults: (HomebaseFile | null)[]; - cursorState: string; - queryTime: number; - includeMetadataHeader: boolean; - }> - >(['chat-messages', conversationId]) + InfiniteData<{ + searchResults: (HomebaseFile | null)[]; + cursorState: string; + queryTime: number; + includeMetadataHeader: boolean; + }> + >(['chat-messages', conversationId]) : undefined; if (extistingMessages) { diff --git a/packages/mobile/src/hooks/chat/useChatMessages.ts b/packages/mobile/src/hooks/chat/useChatMessages.ts index 9680734f..49fc0aab 100644 --- a/packages/mobile/src/hooks/chat/useChatMessages.ts +++ b/packages/mobile/src/hooks/chat/useChatMessages.ts @@ -66,7 +66,7 @@ export const useChatMessages = (props?: { conversationId: string | undefined }) deleteForEveryone?: boolean; }) => { const conversationContent = conversation.fileMetadata.appData.content; - const identity = dotYouClient.getIdentity(); + const identity = dotYouClient.getLoggedInIdentity(); const recipients = conversationContent.recipients.filter((recipient) => recipient !== identity); const hardDelete = stringGuidsEqual( @@ -79,11 +79,11 @@ export const useChatMessages = (props?: { conversationId: string | undefined }) return hardDelete ? await hardDeleteChatMessage(dotYouClient, msg) : await softDeleteChatMessage( - dotYouClient, - msg, - recipients.filter(Boolean), - deleteForEveryone - ); + dotYouClient, + msg, + recipients.filter(Boolean), + deleteForEveryone + ); }) ); }; @@ -143,7 +143,7 @@ export const getChatMessageInfiniteQueryOptions: ( ), getNextPageParam: (lastPage, pages) => lastPage && - lastPage.searchResults?.length >= (lastPage === pages[0] ? FIRST_PAGE_SIZE : PAGE_SIZE) + lastPage.searchResults?.length >= (lastPage === pages[0] ? FIRST_PAGE_SIZE : PAGE_SIZE) ? lastPage.cursorState : undefined, enabled: !!conversationId, @@ -285,8 +285,8 @@ export const internalInsertNewMessage = ( searchResults: index === 0 ? [newMessage, ...filteredSearchResults].sort( - (a, b) => (b.fileMetadata.created || 0) - (a.fileMetadata.created || 0) - ) // Re-sort the first page, as the new message might be older than the first message in the page; + (a, b) => (b.fileMetadata.created || 0) - (a.fileMetadata.created || 0) + ) // Re-sort the first page, as the new message might be older than the first message in the page; : filteredSearchResults, }; } diff --git a/packages/mobile/src/hooks/chat/useChatReaction.ts b/packages/mobile/src/hooks/chat/useChatReaction.ts index 19608560..8521943f 100644 --- a/packages/mobile/src/hooks/chat/useChatReaction.ts +++ b/packages/mobile/src/hooks/chat/useChatReaction.ts @@ -33,7 +33,7 @@ const addReaction = async ({ }) => { const dotYouClient = await getSynchronousDotYouClient(); const conversationContent = conversation.fileMetadata.appData.content; - const identity = dotYouClient.getIdentity(); + const identity = dotYouClient.getLoggedInIdentity(); const recipients = conversationContent.recipients.filter((recipient) => recipient !== identity); if (!message.fileMetadata.globalTransitId) { @@ -66,7 +66,7 @@ export const getAddReactionMutationOptions: (queryClient: QueryClient) => UseMut queryClient.getQueryData(['chat-reaction', message.fileId]) || []; const newReaction: EmojiReaction = { - authorOdinId: (await getSynchronousDotYouClient()).getIdentity(), + authorOdinId: (await getSynchronousDotYouClient()).getLoggedInIdentity(), body: reaction, }; @@ -118,7 +118,7 @@ const removeReactionOnServer = async ({ }) => { const dotYouClient = await getSynchronousDotYouClient(); const conversationContent = conversation.fileMetadata.appData.content; - const identity = dotYouClient.getIdentity(); + const identity = dotYouClient.getLoggedInIdentity(); const recipients = conversationContent.recipients.filter((recipient) => recipient !== identity); if (!message.fileMetadata.globalTransitId) { diff --git a/packages/mobile/src/hooks/chat/useConversation.ts b/packages/mobile/src/hooks/chat/useConversation.ts index 268251dd..8c0dbde9 100644 --- a/packages/mobile/src/hooks/chat/useConversation.ts +++ b/packages/mobile/src/hooks/chat/useConversation.ts @@ -39,7 +39,7 @@ export const useConversation = (props?: { conversationId?: string | undefined }) const { conversationId } = props || {}; const dotYouClient = useDotYouClientContext(); const queryClient = useQueryClient(); - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const addErrors = useErrors().add; const createConversation = async ({ diff --git a/packages/mobile/src/hooks/chat/useLiveChatProcessor.ts b/packages/mobile/src/hooks/chat/useLiveChatProcessor.ts index 37b28961..44bcfd19 100644 --- a/packages/mobile/src/hooks/chat/useLiveChatProcessor.ts +++ b/packages/mobile/src/hooks/chat/useLiveChatProcessor.ts @@ -160,7 +160,7 @@ const useInboxProcessor = (connected?: boolean) => { const useChatWebsocket = (isEnabled: boolean) => { const dotYouClient = useDotYouClientContext(); - const identity = dotYouClient.getIdentity(); + const identity = dotYouClient.getLoggedInIdentity(); // Added to ensure we have the conversation query available const { @@ -433,11 +433,11 @@ const processChatMessagesBatch = async ( uniqueMessagesPerConversation[conversationId].map(async (newMessage) => typeof newMessage.fileMetadata.appData.content === 'string' ? await dsrToMessage( - dotYouClient, - newMessage as HomebaseFile, - ChatDrive, - true - ) + dotYouClient, + newMessage as HomebaseFile, + ChatDrive, + true + ) : (newMessage as HomebaseFile) ) ) diff --git a/packages/mobile/src/hooks/chat/useMarkMessagesAsRead.ts b/packages/mobile/src/hooks/chat/useMarkMessagesAsRead.ts index c1904f18..49eb440a 100644 --- a/packages/mobile/src/hooks/chat/useMarkMessagesAsRead.ts +++ b/packages/mobile/src/hooks/chat/useMarkMessagesAsRead.ts @@ -15,7 +15,7 @@ export const useMarkMessagesAsRead = ({ conversation: HomebaseFile | undefined; messages: HomebaseFile[] | undefined; }) => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const { mutateAsync: markAsRead } = useChatMessages({ conversationId: conversation?.fileMetadata.appData.uniqueId, }).markAsRead; @@ -35,7 +35,7 @@ export const useMarkMessagesAsRead = ({ const unreadMessages = messages.filter( (msg) => (msg?.fileMetadata.transitCreated || msg?.fileMetadata.created) > - (conversationMetadata.fileMetadata.appData.content.lastReadTime || 0) && + (conversationMetadata.fileMetadata.appData.content.lastReadTime || 0) && msg.fileMetadata.senderOdinId && msg.fileMetadata.senderOdinId !== identity ); diff --git a/packages/mobile/src/hooks/feed/channels/useChannel.ts b/packages/mobile/src/hooks/feed/channels/useChannel.ts index c7e0ecf7..f8b89fee 100644 --- a/packages/mobile/src/hooks/feed/channels/useChannel.ts +++ b/packages/mobile/src/hooks/feed/channels/useChannel.ts @@ -72,7 +72,7 @@ export const useChannel = ({ odinId, channelKey }: useChannelsProps) => { return { fetch: useQuery({ - queryKey: ['channel', odinId || dotYouClient.getIdentity(), channelKey], + queryKey: ['channel', odinId || dotYouClient.getLoggedInIdentity(), channelKey], queryFn: () => fetchChannelData({ channelKey }), refetchOnMount: false, refetchOnWindowFocus: false, diff --git a/packages/mobile/src/hooks/feed/post/usePost.ts b/packages/mobile/src/hooks/feed/post/usePost.ts index eb53458d..fa3f7948 100644 --- a/packages/mobile/src/hooks/feed/post/usePost.ts +++ b/packages/mobile/src/hooks/feed/post/usePost.ts @@ -151,7 +151,7 @@ export const getPostQueryOptions: ( ) => ({ queryKey: [ 'post', - odinId || dotYouClient.getIdentity(), + odinId || dotYouClient.getLoggedInIdentity(), channel?.fileMetadata.appData.uniqueId, postKey, ], diff --git a/packages/mobile/src/hooks/feed/post/usePostsInfinite.ts b/packages/mobile/src/hooks/feed/post/usePostsInfinite.ts index a1f1cb49..b47d8972 100644 --- a/packages/mobile/src/hooks/feed/post/usePostsInfinite.ts +++ b/packages/mobile/src/hooks/feed/post/usePostsInfinite.ts @@ -34,7 +34,7 @@ export const usePostsInfinite = ({ }: usePostsInfiniteProps) => { const dotYouClient = useDotYouClientContext(); const isOwner = !!useAuth().getIdentity(); - const isAuthenticated = isOwner || !!dotYouClient.getIdentity(); + const isAuthenticated = isOwner || !!dotYouClient.getLoggedInIdentity(); (); const { data: channels } = useChannels({ isAuthenticated, isOwner }); const fetchBlogData = async ({ @@ -55,22 +55,22 @@ export const usePostsInfinite = ({ cachedData || (channelId ? await getPosts( - dotYouClient, - channelId, - postType, - false, - typeof pageParam === 'string' ? pageParam : undefined, - BLOG_POST_INFIITE_PAGE_SIZE - ) + dotYouClient, + channelId, + postType, + false, + typeof pageParam === 'string' ? pageParam : undefined, + BLOG_POST_INFIITE_PAGE_SIZE + ) : await getRecentPosts( - dotYouClient, - postType, - false, - typeof pageParam === 'object' ? pageParam : undefined, - BLOG_POST_INFIITE_PAGE_SIZE, - channels, - includeHidden - )); + dotYouClient, + postType, + false, + typeof pageParam === 'object' ? pageParam : undefined, + BLOG_POST_INFIITE_PAGE_SIZE, + channels, + includeHidden + )); return { results: response.results.filter( diff --git a/packages/mobile/src/hooks/image/useRawImage.ts b/packages/mobile/src/hooks/image/useRawImage.ts index b6f06901..52e23a1f 100644 --- a/packages/mobile/src/hooks/image/useRawImage.ts +++ b/packages/mobile/src/hooks/image/useRawImage.ts @@ -30,7 +30,7 @@ export const useRawImage = ({ lastModified?: number; }) => { const dotYouClient = useDotYouClientContext(); - const localHost = dotYouClient.getIdentity(); + const localHost = dotYouClient.getLoggedInIdentity(); const fetchImageData = async ( odinId: string, imageFileId: string | undefined, diff --git a/packages/mobile/src/hooks/links/useLinkPreview.ts b/packages/mobile/src/hooks/links/useLinkPreview.ts index a11e46c4..75ef7dcb 100644 --- a/packages/mobile/src/hooks/links/useLinkPreview.ts +++ b/packages/mobile/src/hooks/links/useLinkPreview.ts @@ -50,7 +50,7 @@ export const useLinkMetadata = ({ payloadKey: string; }) => { const dotYouClient = useDotYouClientContext(); - const identity = dotYouClient.getIdentity(); + const identity = dotYouClient.getLoggedInIdentity(); const fetchLinkData = async () => { if (!fileId || !payloadKey || !targetDrive) { return null; diff --git a/packages/mobile/src/hooks/profile/useProfile.ts b/packages/mobile/src/hooks/profile/useProfile.ts index ade81fea..32088fb0 100644 --- a/packages/mobile/src/hooks/profile/useProfile.ts +++ b/packages/mobile/src/hooks/profile/useProfile.ts @@ -29,7 +29,7 @@ export const useProfile = () => { const photoAttr = photoDsr?.fileMetadata.appData.content; return { - displayName: nameAttr?.data?.displayName || dotYouClient.getIdentity(), + displayName: nameAttr?.data?.displayName || dotYouClient.getLoggedInIdentity(), firstName: nameAttr?.data?.givenName, surName: nameAttr?.data?.surname, diff --git a/packages/mobile/src/hooks/push-notification/useInitialPushNotification.ts b/packages/mobile/src/hooks/push-notification/useInitialPushNotification.ts index 3ecef130..f94b2a1f 100644 --- a/packages/mobile/src/hooks/push-notification/useInitialPushNotification.ts +++ b/packages/mobile/src/hooks/push-notification/useInitialPushNotification.ts @@ -12,7 +12,7 @@ import { TabStackParamList } from '../../app/App'; const handledNotifications: unknown[] = []; export const useInitialPushNotification = () => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const chatNavigator = useNavigation>(); const tabNavigator = useNavigation>(); diff --git a/packages/mobile/src/hooks/reactions/comments/useCommentMedia.tsx b/packages/mobile/src/hooks/reactions/comments/useCommentMedia.tsx index 4d5dda05..2166f401 100644 --- a/packages/mobile/src/hooks/reactions/comments/useCommentMedia.tsx +++ b/packages/mobile/src/hooks/reactions/comments/useCommentMedia.tsx @@ -32,7 +32,7 @@ export const useCommentMedia = ({ }) => { if (!odinId || !targetDrive || !fileId || !fileKey) return null; - const isLocal = odinId === dotYouClient.getIdentity(); + const isLocal = odinId === dotYouClient.getLoggedInIdentity(); return isLocal ? getDecryptedImageUrl(dotYouClient, targetDrive, fileId, fileKey, undefined, undefined, { diff --git a/packages/mobile/src/hooks/reactions/emojis/useMyEmojiReactions.tsx b/packages/mobile/src/hooks/reactions/emojis/useMyEmojiReactions.tsx index 85f9bfb0..b518c02e 100644 --- a/packages/mobile/src/hooks/reactions/emojis/useMyEmojiReactions.tsx +++ b/packages/mobile/src/hooks/reactions/emojis/useMyEmojiReactions.tsx @@ -24,7 +24,7 @@ export const useMyEmojiReactions = (context?: ReactionContext) => { return ( (await getMyReactions( dotYouClient, - dotYouClient.getIdentity() || undefined, + dotYouClient.getLoggedInIdentity() || undefined, context, PAGE_SIZE, pageParam diff --git a/packages/mobile/src/hooks/reactions/useCanReact.tsx b/packages/mobile/src/hooks/reactions/useCanReact.tsx index c0cb5f9f..8900c9be 100644 --- a/packages/mobile/src/hooks/reactions/useCanReact.tsx +++ b/packages/mobile/src/hooks/reactions/useCanReact.tsx @@ -4,9 +4,9 @@ import { stringGuidsEqual } from '@homebase-id/js-lib/helpers'; import { useQuery } from '@tanstack/react-query'; import { t, useDotYouClientContext } from 'homebase-id-app-common'; -import { useSecurityContext } from '../securityContext/useSecurityContext'; import { addLogs } from '../../provider/log/logger'; import { generateClientError } from '../errors/useErrors'; +import { useSecurityContext } from 'homebase-id-app-common/src/hooks/permissions/useSecurityContext'; interface UseCanReactProps { odinId: string; @@ -45,7 +45,7 @@ export const useCanReact = ({ isAuthenticated, }: UseCanReactProps) => { const dotYouClient = useDotYouClientContext(); - const isAuthor = odinId === dotYouClient.getIdentity(); + const isAuthor = odinId === dotYouClient.getLoggedInIdentity(); const { data: securityContext, isFetched: securityFetched } = useSecurityContext( odinId, isEnabled diff --git a/packages/mobile/src/hooks/securityContext/useSecurityContext.ts b/packages/mobile/src/hooks/securityContext/useSecurityContext.ts deleted file mode 100644 index 0ed22ead..00000000 --- a/packages/mobile/src/hooks/securityContext/useSecurityContext.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { useQuery } from '@tanstack/react-query'; -import { getSecurityContext, getSecurityContextOverPeer } from '@homebase-id/js-lib/core'; -import { useDotYouClientContext } from 'homebase-id-app-common'; - -export const useSecurityContext = (odinId?: string, isEnabled?: boolean) => { - const dotYouClient = useDotYouClientContext(); - - const fetch = async (odinId?: string) => { - if (!odinId || odinId === dotYouClient.getIdentity()) { - return await getSecurityContext(dotYouClient); - } else return await getSecurityContextOverPeer(dotYouClient, odinId); - }; - - return { - fetch: useQuery({ - queryKey: ['security-context', odinId], - queryFn: () => fetch(odinId), - refetchOnMount: false, - refetchOnWindowFocus: false, - staleTime: Infinity, - enabled: isEnabled || true, - }), - }; -}; diff --git a/packages/mobile/src/hooks/video/useHlsManifest.ts b/packages/mobile/src/hooks/video/useHlsManifest.ts index 89582bbf..d16945d7 100644 --- a/packages/mobile/src/hooks/video/useHlsManifest.ts +++ b/packages/mobile/src/hooks/video/useHlsManifest.ts @@ -27,7 +27,7 @@ export const useHlsManifest = ( useLocalWebServer(Platform.OS === 'ios'); const dotYouClient = useDotYouClientContext(); - const identity = dotYouClient.getIdentity(); + const identity = dotYouClient.getLoggedInIdentity(); const { data: videoFileData, isFetched: videoFileDataFetched } = useVideoMetadata( odinId, videoFileId, @@ -167,7 +167,7 @@ const getSegmentUrl = async ( isEncrypted: boolean, systemFileType?: SystemFileType ) => { - const identity = dotYouClient.getIdentity(); + const identity = dotYouClient.getLoggedInIdentity(); if (!isEncrypted) { return await getAnonymousDirectImageUrl( odinId || identity, diff --git a/packages/mobile/src/hooks/video/useVideo.ts b/packages/mobile/src/hooks/video/useVideo.ts index ce754083..15ad28f3 100644 --- a/packages/mobile/src/hooks/video/useVideo.ts +++ b/packages/mobile/src/hooks/video/useVideo.ts @@ -33,7 +33,7 @@ export const useVideo = ({ }) => { const queryClient = useQueryClient(); const dotyouClient = useDotYouClientContext(); - const localHost = dotyouClient.getIdentity(); // This is the identity of the user + const localHost = dotyouClient.getLoggedInIdentity(); // This is the identity of the user const fetchVideo = async ({ payloadKey }: { payloadKey?: string }) => { if (!fileId || !targetDrive || !payloadKey) return null; diff --git a/packages/mobile/src/hooks/video/useVideoMetadata.ts b/packages/mobile/src/hooks/video/useVideoMetadata.ts index d4a0edbe..ae2dbb7d 100644 --- a/packages/mobile/src/hooks/video/useVideoMetadata.ts +++ b/packages/mobile/src/hooks/video/useVideoMetadata.ts @@ -30,7 +30,7 @@ export const useVideoMetadata = ( >; } => { const dotYouClient = useDotYouClientContext(); - const identity = dotYouClient.getIdentity(); + const identity = dotYouClient.getLoggedInIdentity(); const fetchVideoData = async ( odinId: string, @@ -56,11 +56,11 @@ export const useVideoMetadata = ( odinId !== identity ? videoGlobalTransitId ? await getFileHeaderBytesOverPeerByGlobalTransitId( - dotYouClient, - odinId, - videoDrive, - videoGlobalTransitId - ) + dotYouClient, + odinId, + videoDrive, + videoGlobalTransitId + ) : await getFileHeaderOverPeer(dotYouClient, odinId, videoDrive, videoFileId) : await getFileHeader(dotYouClient, videoDrive, videoFileId); diff --git a/packages/mobile/src/pages/chat/archived-page.tsx b/packages/mobile/src/pages/chat/archived-page.tsx index 17ab3948..3bd9c84e 100644 --- a/packages/mobile/src/pages/chat/archived-page.tsx +++ b/packages/mobile/src/pages/chat/archived-page.tsx @@ -16,7 +16,7 @@ import { Text } from '../../components/ui/Text/Text'; type ArchivedPageProp = NativeStackScreenProps; export const ArchivedPage = ({ navigation }: ArchivedPageProp) => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const { data: conversations } = useConversationsWithRecentMessage().all; const filteredConversations = useMemo( diff --git a/packages/mobile/src/pages/chat/message-info-page.tsx b/packages/mobile/src/pages/chat/message-info-page.tsx index e422c947..cda3b4dc 100644 --- a/packages/mobile/src/pages/chat/message-info-page.tsx +++ b/packages/mobile/src/pages/chat/message-info-page.tsx @@ -29,7 +29,7 @@ export const MessageInfoPage = ({ route }: MessageInfoProp) => { const { message, conversation } = route.params; const messageContent = message.fileMetadata.appData.content; - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const conversationContent = conversation.fileMetadata.appData.content; const recipients = conversationContent.recipients.filter( (recipient) => recipient && recipient !== (message.fileMetadata.senderOdinId || identity) @@ -186,7 +186,7 @@ const Header = ({ title }: { title: string }) => { }; const AuthorImage = ({ odinId }: { odinId?: string }) => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const isSelf = !odinId || identity === odinId; if (isSelf) return ; diff --git a/packages/mobile/src/pages/conversations-page.tsx b/packages/mobile/src/pages/conversations-page.tsx index 1d02a29b..53ac9adf 100644 --- a/packages/mobile/src/pages/conversations-page.tsx +++ b/packages/mobile/src/pages/conversations-page.tsx @@ -67,7 +67,7 @@ export const ConversationsPage = memo(({ navigation }: ConversationProp) => { const [query, setQuery] = useState(undefined); const { isDarkMode } = useDarkMode(); const queryClient = useQueryClient(); - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const scrollRef = useRef>(null); useScrollToTop(scrollRef); diff --git a/packages/mobile/src/pages/feed/post-composer.tsx b/packages/mobile/src/pages/feed/post-composer.tsx index b8bb0479..207356ce 100644 --- a/packages/mobile/src/pages/feed/post-composer.tsx +++ b/packages/mobile/src/pages/feed/post-composer.tsx @@ -57,7 +57,7 @@ export const PostComposer = memo( }) => { const { isDarkMode } = useDarkMode(); const insets = useSafeAreaInsets(); - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const { savePost, processingProgress, error } = usePostComposer(); diff --git a/packages/mobile/src/pages/feed/post-detail-page.tsx b/packages/mobile/src/pages/feed/post-detail-page.tsx index 1ce55a6a..b8ce5f63 100644 --- a/packages/mobile/src/pages/feed/post-detail-page.tsx +++ b/packages/mobile/src/pages/feed/post-detail-page.tsx @@ -46,7 +46,7 @@ export const PostDetailPage = ({ route: { params } }: PostDetailPageProps) => { }); const referencedPost = useReferencedPost(!postFile ? postKey : undefined); - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const post = referencedPost || postFile; const postOdinId = odinId || post?.fileMetadata.senderOdinId; diff --git a/packages/mobile/src/pages/media-preview-page.tsx b/packages/mobile/src/pages/media-preview-page.tsx index 222d65b4..dd8a5aae 100644 --- a/packages/mobile/src/pages/media-preview-page.tsx +++ b/packages/mobile/src/pages/media-preview-page.tsx @@ -34,7 +34,7 @@ export type MediaProp = NativeStackScreenProps< >; export const PreviewMedia = memo(({ route, navigation }: MediaProp) => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const { fileId, globalTransitId, diff --git a/packages/mobile/src/pages/profile/connect-qr-page.tsx b/packages/mobile/src/pages/profile/connect-qr-page.tsx index dcc38d35..6ecb37d8 100644 --- a/packages/mobile/src/pages/profile/connect-qr-page.tsx +++ b/packages/mobile/src/pages/profile/connect-qr-page.tsx @@ -9,7 +9,7 @@ import { Text } from '../../components/ui/Text/Text'; type ConnectQrProps = NativeStackScreenProps; export const ConnectQrPage = (_props: ConnectQrProps) => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); return ( ; export const ConnectionRequestsPage = (_props: ConnectionRequestProps) => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const { data: identities, refetch: refetchIdentities, diff --git a/packages/mobile/src/pages/profile/connections-page.tsx b/packages/mobile/src/pages/profile/connections-page.tsx index c5b261cb..c7e0decc 100644 --- a/packages/mobile/src/pages/profile/connections-page.tsx +++ b/packages/mobile/src/pages/profile/connections-page.tsx @@ -13,7 +13,7 @@ import { SafeAreaView } from '../../components/ui/SafeAreaView/SafeAreaView'; type ConnectionsProps = NativeStackScreenProps; export const ConnectionsPage = (_props: ConnectionsProps) => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const { data: identities, diff --git a/packages/mobile/src/pages/profile/followers-page.tsx b/packages/mobile/src/pages/profile/followers-page.tsx index 444044ca..d990005d 100644 --- a/packages/mobile/src/pages/profile/followers-page.tsx +++ b/packages/mobile/src/pages/profile/followers-page.tsx @@ -12,7 +12,7 @@ import { SafeAreaView } from '../../components/ui/SafeAreaView/SafeAreaView'; type FollowersProps = NativeStackScreenProps; export const FollowersPage = (_props: FollowersProps) => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const { data: identities, diff --git a/packages/mobile/src/pages/profile/following-page.tsx b/packages/mobile/src/pages/profile/following-page.tsx index c9277945..2ddb4e28 100644 --- a/packages/mobile/src/pages/profile/following-page.tsx +++ b/packages/mobile/src/pages/profile/following-page.tsx @@ -13,7 +13,7 @@ import { SafeAreaView } from '../../components/ui/SafeAreaView/SafeAreaView'; type FollowingProps = NativeStackScreenProps; export const FollowingPage = (_props: FollowingProps) => { - const identity = useDotYouClientContext().getIdentity(); + const identity = useDotYouClientContext().getLoggedInIdentity(); const { data: identities, diff --git a/packages/mobile/src/provider/auth/AuthenticationProvider.ts b/packages/mobile/src/provider/auth/AuthenticationProvider.ts index 55bd8344..8bebe8b3 100644 --- a/packages/mobile/src/provider/auth/AuthenticationProvider.ts +++ b/packages/mobile/src/provider/auth/AuthenticationProvider.ts @@ -115,7 +115,8 @@ export const finalizeAuthentication = async ( console.log({ base64ExchangedSecretDigest }); const dotYouClient = new DotYouClient({ api: ApiType.App, - identity: identity, + loggedInIdentity: identity, + hostIdentity: identity, }); const token = await exchangeDigestForToken(dotYouClient, base64ExchangedSecretDigest); diff --git a/packages/mobile/src/provider/chat/ChatProvider.ts b/packages/mobile/src/provider/chat/ChatProvider.ts index 393e8143..33433887 100644 --- a/packages/mobile/src/provider/chat/ChatProvider.ts +++ b/packages/mobile/src/provider/chat/ChatProvider.ts @@ -271,19 +271,19 @@ export const uploadChatMessage = async ( }, transitOptions: distribute ? { - recipients: [...recipients], - schedule: ScheduleOptions.SendLater, - priority: PriorityOptions.High, - sendContents: SendContents.All, - useAppNotification: true, - appNotificationOptions: { - appId: CHAT_APP_ID, - typeId: message.fileMetadata.appData.groupId || getNewId(), - tagId: message.fileMetadata.appData.uniqueId || getNewId(), - silent: false, - unEncryptedMessage: notificationBody, - }, - } + recipients: [...recipients], + schedule: ScheduleOptions.SendLater, + priority: PriorityOptions.High, + sendContents: SendContents.All, + useAppNotification: true, + appNotificationOptions: { + appId: CHAT_APP_ID, + typeId: message.fileMetadata.appData.groupId || getNewId(), + tagId: message.fileMetadata.appData.uniqueId || getNewId(), + silent: false, + unEncryptedMessage: notificationBody, + }, + } : undefined, }; @@ -300,11 +300,11 @@ export const uploadChatMessage = async ( const content = shouldEmbedContent ? jsonContent : jsonStringify64({ - message: ellipsisAtMaxChar(getPlainTextFromRichText(messageContent.message), 400), - replyId: messageContent.replyId, - deliveryDetails: messageContent.deliveryDetails, - deliveryStatus: messageContent.deliveryStatus, - }); // We only embed the content if it's less than 3kb + message: ellipsisAtMaxChar(getPlainTextFromRichText(messageContent.message), 400), + replyId: messageContent.replyId, + deliveryDetails: messageContent.deliveryDetails, + deliveryStatus: messageContent.deliveryStatus, + }); // We only embed the content if it's less than 3kb if (!shouldEmbedContent) { payloads.push({ @@ -346,10 +346,10 @@ export const uploadChatMessage = async ( const imageSource: ImageSource | undefined = linkPreviewWithImage ? { - height: linkPreviewWithImage.imageHeight || 0, - width: linkPreviewWithImage.imageWidth || 0, - uri: linkPreviewWithImage.imageUrl, - } + height: linkPreviewWithImage.imageHeight || 0, + width: linkPreviewWithImage.imageWidth || 0, + uri: linkPreviewWithImage.imageUrl, + } : undefined; const { tinyThumb } = imageSource @@ -474,7 +474,7 @@ export const uploadChatMessage = async ( for (const recipient of recipients) { message.fileMetadata.appData.content.deliveryDetails[recipient] = uploadResult.recipientStatus?.[recipient].toLowerCase() === - TransferUploadStatus.EnqueuedFailed + TransferUploadStatus.EnqueuedFailed ? ChatDeliveryStatus.Failed : ChatDeliveryStatus.Delivered; } @@ -518,11 +518,11 @@ export const updateChatMessage = async ( }, transitOptions: distribute ? { - recipients: [...recipients], - schedule: ScheduleOptions.SendLater, - priority: PriorityOptions.High, - sendContents: SendContents.All, - } + recipients: [...recipients], + schedule: ScheduleOptions.SendLater, + priority: PriorityOptions.High, + sendContents: SendContents.All, + } : undefined, storageIntent: 'header', }; @@ -608,7 +608,7 @@ export const requestMarkAsRead = async ( (msg) => msg.fileMetadata.appData.content.deliveryStatus !== ChatDeliveryStatus.Read && msg.fileMetadata.senderOdinId && - msg.fileMetadata.senderOdinId !== dotYouClient.getIdentity() + msg.fileMetadata.senderOdinId !== dotYouClient.getLoggedInIdentity() ) .map((msg) => msg.fileId) as string[]; diff --git a/packages/mobile/src/provider/chat/ConversationProvider.ts b/packages/mobile/src/provider/chat/ConversationProvider.ts index 66eadb94..bd5f8e5b 100644 --- a/packages/mobile/src/provider/chat/ConversationProvider.ts +++ b/packages/mobile/src/provider/chat/ConversationProvider.ts @@ -57,7 +57,6 @@ export const ConversationWithYourself: HomebaseFile = { payloads: [], }, serverMetadata: undefined, - priority: 0, sharedSecretEncryptedKeyHeader: {} as EncryptedKeyHeader, }; @@ -144,9 +143,9 @@ export const getConversation = async (dotYouClient: DotYouClient, conversationId ...conversationHeader.fileMetadata.appData.content, recipients: (conversationHeader.fileMetadata.appData.content as GroupConversation) .recipients || [ - (conversationHeader.fileMetadata.appData.content as SingleConversation).recipient, - dotYouClient.getIdentity(), - ], + (conversationHeader.fileMetadata.appData.content as SingleConversation).recipient, + dotYouClient.getLoggedInIdentity(), + ], }, }, }, @@ -170,7 +169,7 @@ export const dsrToConversation = async ( ); if (!attrContent) return null; - const identity = dotYouClient.getIdentity(); + const identity = dotYouClient.getLoggedInIdentity(); const conversation: HomebaseFile = { ...dsr, fileMetadata: { @@ -181,11 +180,11 @@ export const dsrToConversation = async ( ...attrContent, recipients: (attrContent as GroupConversation).recipients ? [ - ...(attrContent as GroupConversation).recipients.filter( - (recipient) => recipient !== identity - ), - identity, - ] + ...(attrContent as GroupConversation).recipients.filter( + (recipient) => recipient !== identity + ), + identity, + ] : [(attrContent as SingleConversation).recipient, identity], }, }, @@ -206,7 +205,7 @@ export const uploadConversation = async ( image?: ImageSource, onVersionConflict?: () => void ) => { - const identity = dotYouClient.getIdentity(); + const identity = dotYouClient.getLoggedInIdentity(); const uploadInstructions: UploadInstructionSet = { storageOptions: { drive: ChatDrive, @@ -214,13 +213,13 @@ export const uploadConversation = async ( }, transitOptions: distribute ? { - recipients: conversation.fileMetadata.appData.content.recipients.filter( - (recipient) => recipient !== identity - ), - schedule: ScheduleOptions.SendLater, - priority: PriorityOptions.Medium, - sendContents: SendContents.All, - } + recipients: conversation.fileMetadata.appData.content.recipients.filter( + (recipient) => recipient !== identity + ), + schedule: ScheduleOptions.SendLater, + priority: PriorityOptions.Medium, + sendContents: SendContents.All, + } : undefined, }; @@ -289,7 +288,7 @@ export const updateConversation = async ( distribute = false, ignoreConflict = false ): Promise => { - const identity = dotYouClient.getIdentity(); + const identity = dotYouClient.getLoggedInIdentity(); const uploadInstructions: UpdateHeaderInstructionSet = { storageOptions: { drive: ChatDrive, @@ -297,13 +296,13 @@ export const updateConversation = async ( }, transitOptions: distribute ? { - recipients: conversation.fileMetadata.appData.content.recipients.filter( - (recipient) => recipient !== identity - ), - schedule: ScheduleOptions.SendLater, - priority: PriorityOptions.Medium, - sendContents: SendContents.All, - } + recipients: conversation.fileMetadata.appData.content.recipients.filter( + (recipient) => recipient !== identity + ), + schedule: ScheduleOptions.SendLater, + priority: PriorityOptions.Medium, + sendContents: SendContents.All, + } : undefined, storageIntent: 'header', }; @@ -333,19 +332,19 @@ export const updateConversation = async ( uploadMetadata, !ignoreConflict ? async () => { - const existingConversation = await getConversation( - dotYouClient, - conversation.fileMetadata.appData.uniqueId as string - ); - if (!existingConversation) return; - conversation.fileMetadata.versionTag = existingConversation.fileMetadata.versionTag; - conversation.sharedSecretEncryptedKeyHeader = - existingConversation.sharedSecretEncryptedKeyHeader; - return updateConversation(dotYouClient, conversation, distribute, true); - } + const existingConversation = await getConversation( + dotYouClient, + conversation.fileMetadata.appData.uniqueId as string + ); + if (!existingConversation) return; + conversation.fileMetadata.versionTag = existingConversation.fileMetadata.versionTag; + conversation.sharedSecretEncryptedKeyHeader = + existingConversation.sharedSecretEncryptedKeyHeader; + return updateConversation(dotYouClient, conversation, distribute, true); + } : () => { - // We just supress the warning; As we are ignoring the conflict following @param ignoreConflict - } + // We just supress the warning; As we are ignoring the conflict following @param ignoreConflict + } ); }; diff --git a/packages/mobile/src/provider/feed/RNPostReactionProvider.ts b/packages/mobile/src/provider/feed/RNPostReactionProvider.ts index edd2c7ee..24d52a77 100644 --- a/packages/mobile/src/provider/feed/RNPostReactionProvider.ts +++ b/packages/mobile/src/provider/feed/RNPostReactionProvider.ts @@ -53,7 +53,7 @@ export const saveComment = async ( | HomebaseFile ): Promise => { const encrypt = context.target.isEncrypted; - const isLocal = context.odinId === dotYouClient.getIdentity(); + const isLocal = context.odinId === dotYouClient.getLoggedInIdentity(); const targetDrive = GetTargetDriveFromChannelId(context.channelId); let payloads: PayloadFile[] = []; diff --git a/packages/mobile/src/provider/feed/RNPostUploadProvider.ts b/packages/mobile/src/provider/feed/RNPostUploadProvider.ts index ab96c9f7..2969feb1 100644 --- a/packages/mobile/src/provider/feed/RNPostUploadProvider.ts +++ b/packages/mobile/src/provider/feed/RNPostUploadProvider.ts @@ -94,7 +94,7 @@ export const savePost = async ( const newMediaFiles = toSaveFiles as ImageSource[]; if (!file.fileMetadata.appData.content.authorOdinId) { - file.fileMetadata.appData.content.authorOdinId = dotYouClient.getIdentity(); + file.fileMetadata.appData.content.authorOdinId = dotYouClient.getLoggedInIdentity(); } if (!file.serverMetadata?.accessControlList) throw new Error('ACL is required to save a post'); @@ -106,7 +106,7 @@ export const savePost = async ( const encrypt = !( file.serverMetadata?.accessControlList?.requiredSecurityGroup === SecurityGroupType.Anonymous || file.serverMetadata?.accessControlList?.requiredSecurityGroup === - SecurityGroupType.Authenticated + SecurityGroupType.Authenticated ); const targetDrive = GetTargetDriveFromChannelId(channelId); @@ -133,10 +133,10 @@ export const savePost = async ( const imageSource: ImageSource | undefined = linkPreviewWithImage ? { - height: linkPreviewWithImage.imageHeight || 0, - width: linkPreviewWithImage.imageWidth || 0, - uri: linkPreviewWithImage.imageUrl, - } + height: linkPreviewWithImage.imageHeight || 0, + width: linkPreviewWithImage.imageWidth || 0, + uri: linkPreviewWithImage.imageUrl, + } : undefined; const { tinyThumb } = imageSource @@ -210,10 +210,10 @@ export const savePost = async ( if (file.fileMetadata.appData.content.type !== 'Article') { file.fileMetadata.appData.content.primaryMediaFile = payloads[0] ? { - fileId: undefined, - fileKey: payloads[0].key, - type: payloads[0].payload.type, - } + fileId: undefined, + fileKey: payloads[0].key, + type: payloads[0].payload.type, + } : undefined; } @@ -261,7 +261,7 @@ const uploadPost = async ( const encrypt = !( file.serverMetadata?.accessControlList?.requiredSecurityGroup === SecurityGroupType.Anonymous || file.serverMetadata?.accessControlList?.requiredSecurityGroup === - SecurityGroupType.Authenticated + SecurityGroupType.Authenticated ); const instructionSet: UploadInstructionSet = { @@ -290,9 +290,8 @@ const uploadPost = async ( !stringGuidsEqual(existingPostWithThisSlug?.fileId, file.fileId) ) { // There is clash with an existing slug - file.fileMetadata.appData.content.slug = `${ - file.fileMetadata.appData.content.slug - }-${new Date().getTime()}`; + file.fileMetadata.appData.content.slug = `${file.fileMetadata.appData.content.slug + }-${new Date().getTime()}`; } } const uniqueId = file.fileMetadata.appData.content.slug @@ -431,12 +430,11 @@ const uploadPostHeader = async ( if ( existingPostWithThisSlug && existingPostWithThisSlug?.fileMetadata.appData.content.id !== - file.fileMetadata.appData.content.id + file.fileMetadata.appData.content.id ) { // There is clash with an existing slug - file.fileMetadata.appData.content.slug = `${ - file.fileMetadata.appData.content.slug - }-${new Date().getTime()}`; + file.fileMetadata.appData.content.slug = `${file.fileMetadata.appData.content.slug + }-${new Date().getTime()}`; } const uniqueId = file.fileMetadata.appData.content.slug From 6b37f5bbc30879b24b84b3e2fa632f80bc419e83 Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Mon, 16 Dec 2024 16:20:27 +0530 Subject: [PATCH 2/7] fix fix --- packages/mobile/src/hooks/feed/post/usePostsInfinite.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mobile/src/hooks/feed/post/usePostsInfinite.ts b/packages/mobile/src/hooks/feed/post/usePostsInfinite.ts index b47d8972..ebcb83fb 100644 --- a/packages/mobile/src/hooks/feed/post/usePostsInfinite.ts +++ b/packages/mobile/src/hooks/feed/post/usePostsInfinite.ts @@ -34,7 +34,7 @@ export const usePostsInfinite = ({ }: usePostsInfiniteProps) => { const dotYouClient = useDotYouClientContext(); const isOwner = !!useAuth().getIdentity(); - const isAuthenticated = isOwner || !!dotYouClient.getLoggedInIdentity(); (); + const isAuthenticated = isOwner || !!dotYouClient.getLoggedInIdentity(); const { data: channels } = useChannels({ isAuthenticated, isOwner }); const fetchBlogData = async ({ From 3eff80761763f9740ff8bdd5d058f89cd98303d8 Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Mon, 16 Dec 2024 16:55:36 +0530 Subject: [PATCH 3/7] fix lints and errors and migrations --- .../src/components/Chat/Chat-Forward.tsx | 2 +- .../components/Chat/Chat-Message-Content.ts | 2 +- .../src/components/Chat/MediaMessage.tsx | 10 ++++--- .../Chat/Reactions/Modal/ReportModal.tsx | 3 +- .../src/components/Chat/Reply-Message-bar.tsx | 2 +- .../Feed/EditPost/EditPostModal.tsx | 8 +++-- .../Feed/Interacts/Comments/CommentHead.tsx | 2 +- .../Feed/Interacts/PostInteracts.tsx | 2 +- .../src/components/Feed/Meta/Actions.tsx | 2 +- .../src/components/ui/Avatars/Avatar.tsx | 5 +++- .../hooks/chat/getSynchronousDotYouClient.ts | 3 +- .../mobile/src/hooks/chat/useConversation.ts | 1 - .../src/hooks/feed/useManageSocialFeed.ts | 2 +- .../src/hooks/useNotificationSubscriber.ts | 3 +- .../src/hooks/video/useVideoMetadata.ts | 2 +- .../mobile/src/pages/chat/archived-page.tsx | 3 +- .../mobile/src/pages/chat/chat-info-page.tsx | 3 +- packages/mobile/src/pages/chat/chat-page.tsx | 6 ++-- .../mobile/src/pages/chat/edit-group-page.tsx | 3 +- .../mobile/src/pages/conversations-page.tsx | 4 +-- .../mobile/src/provider/chat/ChatProvider.ts | 29 ++++++++++--------- 21 files changed, 54 insertions(+), 43 deletions(-) diff --git a/packages/mobile/src/components/Chat/Chat-Forward.tsx b/packages/mobile/src/components/Chat/Chat-Forward.tsx index 5a97ef2b..0870dc31 100644 --- a/packages/mobile/src/components/Chat/Chat-Forward.tsx +++ b/packages/mobile/src/components/Chat/Chat-Forward.tsx @@ -108,7 +108,7 @@ export const ChatForwardModal = memo( message: ChatMessageIMessage ) { const messagePayloads: ImageSource[] = []; - if (message.fileMetadata.payloads.length > 0) { + if (message.fileMetadata.payloads && message.fileMetadata.payloads.length > 0) { const payloads = message.fileMetadata.payloads; for (const payload of payloads) { diff --git a/packages/mobile/src/components/Chat/Chat-Message-Content.ts b/packages/mobile/src/components/Chat/Chat-Message-Content.ts index 0a98ff9c..e123d105 100644 --- a/packages/mobile/src/components/Chat/Chat-Message-Content.ts +++ b/packages/mobile/src/components/Chat/Chat-Message-Content.ts @@ -13,7 +13,7 @@ export const ChatMessageContent = memo( } if (textMessage?.length > 0) { return ellipsisAtMaxChar(getPlainTextFromRichText(textMessage), 30); - } else if (payloads?.length > 1) { + } else if (payloads && payloads?.length > 1) { return '📸 Medias'; } else { const payload = payloads?.[0]; diff --git a/packages/mobile/src/components/Chat/MediaMessage.tsx b/packages/mobile/src/components/Chat/MediaMessage.tsx index bbeb4a9a..7f7bcf30 100644 --- a/packages/mobile/src/components/Chat/MediaMessage.tsx +++ b/packages/mobile/src/components/Chat/MediaMessage.tsx @@ -12,7 +12,7 @@ import { MediaGallery, MediaItem } from '../ui/Media/MediaGallery'; import { useDarkMode } from '../../hooks/useDarkMode'; import { Colors } from '../../app/Colors'; import { useAuth } from '../../hooks/auth/useAuth'; -import { DEFAULT_PAYLOAD_KEY } from '@homebase-id/js-lib/core'; +import { DEFAULT_PAYLOAD_KEY, PayloadDescriptor } from '@homebase-id/js-lib/core'; const MediaMessage = memo( ({ @@ -44,6 +44,7 @@ const MediaMessage = memo( ); if ( !props.currentMessage || + !props.currentMessage.fileMetadata.payloads || !props.currentMessage.fileMetadata.payloads?.filter((p) => p.key !== DEFAULT_PAYLOAD_KEY) .length ) { @@ -91,6 +92,7 @@ const InnerMediaMessage = memo( const onClick = useCallback( (currIndex?: number) => { + if (!payloads) return; navigation.navigate('PreviewMedia', { fileId: currentMessage.fileId, payloads: payloads, @@ -104,7 +106,7 @@ const InnerMediaMessage = memo( [currentMessage, navigation, payloads] ); const previewThumbnail = - (payloads.length === 1 ? payloads[0]?.previewThumbnail : undefined) || + (payloads && payloads.length === 1 ? payloads[0]?.previewThumbnail : undefined) || currentMessage.fileMetadata.appData.previewThumbnail; const aspectRatio = useMemo( @@ -122,7 +124,7 @@ const InnerMediaMessage = memo( [previewThumbnail, width, height] ); - if (payloads.length === 1) { + if (payloads?.length === 1) { return ( onLongPress(e, currentMessage)} diff --git a/packages/mobile/src/components/Chat/Reactions/Modal/ReportModal.tsx b/packages/mobile/src/components/Chat/Reactions/Modal/ReportModal.tsx index d3ef045f..57846279 100644 --- a/packages/mobile/src/components/Chat/Reactions/Modal/ReportModal.tsx +++ b/packages/mobile/src/components/Chat/Reactions/Modal/ReportModal.tsx @@ -37,7 +37,8 @@ export const ReportModal = forwardRef( const identity = useAuth().getIdentity(); const host = new DotYouClient({ api: ApiType.Guest, - identity: identity || undefined, + loggedInIdentity: identity || undefined, + hostIdentity: identity || undefined, }).getRoot(); const onBlock = () => diff --git a/packages/mobile/src/components/Chat/Reply-Message-bar.tsx b/packages/mobile/src/components/Chat/Reply-Message-bar.tsx index 924fce94..334b3b4f 100644 --- a/packages/mobile/src/components/Chat/Reply-Message-bar.tsx +++ b/packages/mobile/src/components/Chat/Reply-Message-bar.tsx @@ -83,7 +83,7 @@ const ReplyMessageBar = ({ clearReply, message }: ReplyMessageBarProps) => { fileId={message.fileId} targetDrive={ChatDrive} previewThumbnail={message.fileMetadata.appData.previewThumbnail} - fileKey={message.fileMetadata.payloads[0].key} + fileKey={payloads[0].key} fit="cover" imageSize={{ width: 45, diff --git a/packages/mobile/src/components/Feed/EditPost/EditPostModal.tsx b/packages/mobile/src/components/Feed/EditPost/EditPostModal.tsx index ca39d21a..a9dac9cf 100644 --- a/packages/mobile/src/components/Feed/EditPost/EditPostModal.tsx +++ b/packages/mobile/src/components/Feed/EditPost/EditPostModal.tsx @@ -40,9 +40,11 @@ export const EditPostModal = memo( useEffect(() => { if (incomingPostFile) { setPostFile({ ...incomingPostFile }); - setNewMediaFiles( - incomingPostFile.fileMetadata.payloads?.filter((p) => p.key !== DEFAULT_PAYLOAD_KEY) - ); + if (incomingPostFile.fileMetadata.payloads) { + setNewMediaFiles( + incomingPostFile.fileMetadata.payloads?.filter((p) => p.key !== DEFAULT_PAYLOAD_KEY) + ); + } } }, [incomingPostFile]); diff --git a/packages/mobile/src/components/Feed/Interacts/Comments/CommentHead.tsx b/packages/mobile/src/components/Feed/Interacts/Comments/CommentHead.tsx index 3cb5dc7a..9af0075f 100644 --- a/packages/mobile/src/components/Feed/Interacts/Comments/CommentHead.tsx +++ b/packages/mobile/src/components/Feed/Interacts/Comments/CommentHead.tsx @@ -35,7 +35,7 @@ export const CommentHead = memo( label: `${t('Block this user')}`, onPress: () => openURL( - `${new DotYouClient({ identity, api: ApiType.Guest }).getRoot()}/owner/connections/${authorOdinId}/block` + `${new DotYouClient({ loggedInIdentity: identity, api: ApiType.Guest }).getRoot()}/owner/connections/${authorOdinId}/block` ), }); } diff --git a/packages/mobile/src/components/Feed/Interacts/PostInteracts.tsx b/packages/mobile/src/components/Feed/Interacts/PostInteracts.tsx index 1176fc5e..6371f593 100644 --- a/packages/mobile/src/components/Feed/Interacts/PostInteracts.tsx +++ b/packages/mobile/src/components/Feed/Interacts/PostInteracts.tsx @@ -97,7 +97,7 @@ export const PostInteracts = memo( const permalink = useMemo( () => - `${new DotYouClient({ identity: odinId || undefined, api: ApiType.Guest }).getRoot()}/posts/${postContent.channelId}/${ + `${new DotYouClient({ loggedInIdentity: odinId || undefined, api: ApiType.Guest }).getRoot()}/posts/${postContent.channelId}/${ postContent.slug ?? postContent.id }`, [odinId, postContent] diff --git a/packages/mobile/src/components/Feed/Meta/Actions.tsx b/packages/mobile/src/components/Feed/Meta/Actions.tsx index 9cbfbcfd..68eaa259 100644 --- a/packages/mobile/src/components/Feed/Meta/Actions.tsx +++ b/packages/mobile/src/components/Feed/Meta/Actions.tsx @@ -44,7 +44,7 @@ export const ExternalActions = memo( const host = new DotYouClient({ api: ApiType.Guest, - identity: identity || undefined, + loggedInIdentity: identity || undefined, }).getRoot(); const options: ActionGroupProps[] = [ { diff --git a/packages/mobile/src/components/ui/Avatars/Avatar.tsx b/packages/mobile/src/components/ui/Avatars/Avatar.tsx index bd18f8af..376d65ae 100644 --- a/packages/mobile/src/components/ui/Avatars/Avatar.tsx +++ b/packages/mobile/src/components/ui/Avatars/Avatar.tsx @@ -38,7 +38,10 @@ export const Avatar = memo( ); } - if (contact?.fileMetadata.payloads.some((p) => p.key === CONTACT_PROFILE_IMAGE_KEY)) { + if ( + contact?.fileMetadata.payloads && + contact?.fileMetadata.payloads.some((p) => p.key === CONTACT_PROFILE_IMAGE_KEY) + ) { return ( { return new DotYouClient({ sharedSecret: base64ToUint8Array(sharedSecret), api: ApiType.App, - identity: identity, + loggedInIdentity: identity, + hostIdentity: identity, headers: headers, }); })(); diff --git a/packages/mobile/src/hooks/chat/useConversation.ts b/packages/mobile/src/hooks/chat/useConversation.ts index 8c0dbde9..54aaa5d7 100644 --- a/packages/mobile/src/hooks/chat/useConversation.ts +++ b/packages/mobile/src/hooks/chat/useConversation.ts @@ -113,7 +113,6 @@ export const useConversation = (props?: { conversationId?: string | undefined }) doNotIndex: false, allowDistribution: false, }, - priority: 0, }; return serverVersion; diff --git a/packages/mobile/src/hooks/feed/useManageSocialFeed.ts b/packages/mobile/src/hooks/feed/useManageSocialFeed.ts index 48d88235..c26ed892 100644 --- a/packages/mobile/src/hooks/feed/useManageSocialFeed.ts +++ b/packages/mobile/src/hooks/feed/useManageSocialFeed.ts @@ -23,7 +23,7 @@ export const useManageSocialFeed = (props?: { odinId: string }) => { }; const getContentReportUrl = () => { - const host = new DotYouClient({ identity: odinId, api: ApiType.Guest }).getRoot(); + const host = new DotYouClient({ loggedInIdentity: odinId, api: ApiType.Guest }).getRoot(); // Fetch the reporting url from the other identities config return fetch(`${host}/config/reporting`) diff --git a/packages/mobile/src/hooks/useNotificationSubscriber.ts b/packages/mobile/src/hooks/useNotificationSubscriber.ts index 88eccced..84eb99a9 100644 --- a/packages/mobile/src/hooks/useNotificationSubscriber.ts +++ b/packages/mobile/src/hooks/useNotificationSubscriber.ts @@ -6,6 +6,7 @@ import { TargetDrive, TypedConnectionNotification, Notify, + DotYouClient, } from '@homebase-id/js-lib/core'; import { useRef, useEffect, useState, useCallback } from 'react'; import { hasDebugFlag } from '@homebase-id/js-lib/helpers'; @@ -30,7 +31,7 @@ export const useNotificationSubscriber = ( if (!authToken) throw new Error('No auth token found'); const wrappedSubscriber = useCallback( - (notification: TypedConnectionNotification) => { + (dotYouClient: DotYouClient, notification: TypedConnectionNotification) => { if (notification.notificationType === 'inboxItemReceived') { isDebug && console.debug( diff --git a/packages/mobile/src/hooks/video/useVideoMetadata.ts b/packages/mobile/src/hooks/video/useVideoMetadata.ts index ae2dbb7d..7cf7d852 100644 --- a/packages/mobile/src/hooks/video/useVideoMetadata.ts +++ b/packages/mobile/src/hooks/video/useVideoMetadata.ts @@ -65,7 +65,7 @@ export const useVideoMetadata = ( : await getFileHeader(dotYouClient, videoDrive, videoFileId); if (!fileHeader) return undefined; - const payloadData = fileHeader.fileMetadata.payloads.find((p) => p.key === videoFileKey); + const payloadData = fileHeader.fileMetadata.payloads?.find((p) => p.key === videoFileKey); const descriptor = payloadData?.descriptorContent; if (!descriptor) return undefined; diff --git a/packages/mobile/src/pages/chat/archived-page.tsx b/packages/mobile/src/pages/chat/archived-page.tsx index 3bd9c84e..c7475da0 100644 --- a/packages/mobile/src/pages/chat/archived-page.tsx +++ b/packages/mobile/src/pages/chat/archived-page.tsx @@ -41,7 +41,6 @@ export const ArchivedPage = ({ navigation }: ArchivedPageProp) => { const renderItem = useCallback( ({ item }: ListRenderItemInfo) => { if (!item) return ; - const hasPayload = item.fileMetadata.payloads?.length > 0; return ( { conversationId={item.fileMetadata.appData.uniqueId} conversationUpdated={item.fileMetadata.updated} fileId={item.fileId} - payloadKey={hasPayload ? item.fileMetadata.payloads[0].key : undefined} + payloadKey={item.fileMetadata.payloads?.[0]?.key} onPress={onPress} odinId={ item.fileMetadata.appData.content.recipients.filter( diff --git a/packages/mobile/src/pages/chat/chat-info-page.tsx b/packages/mobile/src/pages/chat/chat-info-page.tsx index 353cb3ee..f1e70c70 100644 --- a/packages/mobile/src/pages/chat/chat-info-page.tsx +++ b/packages/mobile/src/pages/chat/chat-info-page.tsx @@ -154,7 +154,8 @@ const RenderListHeader = memo( await openURL(`https://${withYourself ? identity : recipient}/`); }, [withYourself, identity, recipient]); if (!conversation) return null; - const hasGroupImage = conversation.fileMetadata.payloads?.length > 0; + const hasGroupImage = + conversation.fileMetadata.payloads && conversation.fileMetadata.payloads?.length > 0; const groupAvatarPayloadKey = conversation.fileMetadata.payloads?.[0]?.key; const conversationContent = conversation?.fileMetadata.appData.content; diff --git a/packages/mobile/src/pages/chat/chat-page.tsx b/packages/mobile/src/pages/chat/chat-page.tsx index 5eba8c20..a73047fa 100644 --- a/packages/mobile/src/pages/chat/chat-page.tsx +++ b/packages/mobile/src/pages/chat/chat-page.tsx @@ -147,7 +147,7 @@ const ChatPage = memo(({ route, navigation }: ChatProp) => { received: value.fileMetadata.appData.content.deliveryStatus === 40, pending: value.fileMetadata.appData.content.deliveryStatus === 15, image: - value.fileMetadata.payloads?.length > 0 + value.fileMetadata.payloads && value.fileMetadata.payloads?.length > 0 ? value.fileMetadata.payloads.length.toString() : undefined, ...value, @@ -497,7 +497,7 @@ const ChatPage = memo(({ route, navigation }: ChatProp) => { const host = new DotYouClient({ api: ApiType.Guest, - identity: identity || undefined, + loggedInIdentity: identity || undefined, }).getRoot(); const chatOptions: { label: string; @@ -655,7 +655,7 @@ const ChatPage = memo(({ route, navigation }: ChatProp) => { isGroupChat ? { fileId: conversation.fileId, - fileKey: conversation.fileMetadata.payloads?.[0]?.key, + fileKey: conversation.fileMetadata.payloads?.[0].key as string, previewThumbnail: conversation.fileMetadata.appData.previewThumbnail, } : undefined diff --git a/packages/mobile/src/pages/chat/edit-group-page.tsx b/packages/mobile/src/pages/chat/edit-group-page.tsx index 9892c22d..36716e01 100644 --- a/packages/mobile/src/pages/chat/edit-group-page.tsx +++ b/packages/mobile/src/pages/chat/edit-group-page.tsx @@ -137,7 +137,8 @@ export function EditGroupPage(props: EditGroupProp) { const [visible, setVisible] = useState(false); if (!conversation) return null; - const hasGroupImage = conversation.fileMetadata.payloads?.length > 0; + const hasGroupImage = + conversation.fileMetadata.payloads && conversation.fileMetadata.payloads?.length > 0; const groupAvatarPayloadKey = conversation.fileMetadata.payloads?.[0]?.key; return ( diff --git a/packages/mobile/src/pages/conversations-page.tsx b/packages/mobile/src/pages/conversations-page.tsx index 53ac9adf..91901421 100644 --- a/packages/mobile/src/pages/conversations-page.tsx +++ b/packages/mobile/src/pages/conversations-page.tsx @@ -107,7 +107,7 @@ export const ConversationsPage = memo(({ navigation }: ConversationProp) => { const renderItem = useCallback( ({ item }: ListRenderItemInfo) => { if (!item) return ; - const hasPayload = item.fileMetadata.payloads?.length > 0; + return ( { conversationId={item.fileMetadata.appData.uniqueId} conversationUpdated={item.fileMetadata.updated} fileId={item.fileId} - payloadKey={hasPayload ? item.fileMetadata.payloads[0].key : undefined} + payloadKey={item.fileMetadata.payloads?.[0]?.key} onPress={onPress} odinId={ item.fileMetadata.appData.content.recipients.filter( diff --git a/packages/mobile/src/provider/chat/ChatProvider.ts b/packages/mobile/src/provider/chat/ChatProvider.ts index 33433887..2f766444 100644 --- a/packages/mobile/src/provider/chat/ChatProvider.ts +++ b/packages/mobile/src/provider/chat/ChatProvider.ts @@ -577,20 +577,21 @@ export const softDeleteChatMessage = async ( ) => { message.fileMetadata.appData.archivalStatus = ChatDeletedArchivalStaus; let runningVersionTag = message.fileMetadata.versionTag; - - for (let i = 0; i < message.fileMetadata.payloads.length; i++) { - const payload = message.fileMetadata.payloads[i]; - // TODO: Should the payload be deleted for everyone? With "TransitOptions" - const deleteResult = await deletePayload( - dotYouClient, - ChatDrive, - message.fileId, - payload.key, - runningVersionTag - ); - - if (!deleteResult) throw new Error('Failed to delete payload'); - runningVersionTag = deleteResult.newVersionTag; + const { payloads } = message.fileMetadata; + if (payloads) { + await Promise.all(payloads.map(async (payload) => { + // TODO: Should the payload be deleted for everyone? With "TransitOptions" + const deleteResult = await deletePayload( + dotYouClient, + ChatDrive, + message.fileId, + payload.key, + runningVersionTag + ); + if (!deleteResult) throw new Error('Failed to delete payload'); + runningVersionTag = deleteResult.newVersionTag; + } + )); } message.fileMetadata.versionTag = runningVersionTag; From 3525cfc6b0546b4aa983c5f1bd8cc5cf8396f667 Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Mon, 16 Dec 2024 16:56:55 +0530 Subject: [PATCH 4/7] final fix --- packages/mobile/src/pages/chat/chat-page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mobile/src/pages/chat/chat-page.tsx b/packages/mobile/src/pages/chat/chat-page.tsx index a73047fa..a882125a 100644 --- a/packages/mobile/src/pages/chat/chat-page.tsx +++ b/packages/mobile/src/pages/chat/chat-page.tsx @@ -655,7 +655,7 @@ const ChatPage = memo(({ route, navigation }: ChatProp) => { isGroupChat ? { fileId: conversation.fileId, - fileKey: conversation.fileMetadata.payloads?.[0].key as string, + fileKey: conversation.fileMetadata.payloads?.[0]?.key as string, previewThumbnail: conversation.fileMetadata.appData.previewThumbnail, } : undefined From 88128a64982fbe6516f9a3a81cc28e77c3b128a8 Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Mon, 16 Dec 2024 16:57:58 +0530 Subject: [PATCH 5/7] test lint --- packages/mobile/__tests__/RNPostReactionProvider.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/mobile/__tests__/RNPostReactionProvider.test.ts b/packages/mobile/__tests__/RNPostReactionProvider.test.ts index f0c88612..e838b7ad 100644 --- a/packages/mobile/__tests__/RNPostReactionProvider.test.ts +++ b/packages/mobile/__tests__/RNPostReactionProvider.test.ts @@ -93,7 +93,7 @@ describe('RNPostReactionProvider', () => { let context: ReactionContext; let comment: NewHomebaseFile | HomebaseFile; const dotYouClient = new DotYouClient({ - identity: 'frodobaggins.me', + loggedInIdentity: 'frodobaggins.me', api: ApiType.App, headers: {}, sharedSecret: new Uint8Array(32), @@ -101,7 +101,7 @@ describe('RNPostReactionProvider', () => { beforeEach(() => { const mockGetRandom16Bytes = jest.fn().mockReturnValue(new Uint8Array(16)); (getRandom16ByteArray as jest.Mock) = mockGetRandom16Bytes; - dotYouClient.getLoggedInIdentity(); = jest.fn().mockReturnValue('frodobaggins.me'); + dotYouClient.getLoggedInIdentity = jest.fn().mockReturnValue('frodobaggins.me'); dotYouClient.getSharedSecret = jest.fn().mockReturnValue(new Uint8Array(32)); context = { @@ -217,7 +217,7 @@ describe('RNPostReactionProvider', () => { }); it('should handle local comments correctly', async () => { - context.odinId = dotYouClient.getLoggedInIdentity(); + context.odinId = dotYouClient.getLoggedInIdentity(); const result = await saveComment(dotYouClient, context, comment); expect(result).toBeDefined(); }); From c9d0bf501324431a9a45f83690e208a9d0324422 Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Mon, 16 Dec 2024 17:03:20 +0530 Subject: [PATCH 6/7] fix test lints --- packages/mobile/__tests__/ChatProvider.test.ts | 5 +---- packages/mobile/__tests__/ConversationProvider.test.ts | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/mobile/__tests__/ChatProvider.test.ts b/packages/mobile/__tests__/ChatProvider.test.ts index 97460fd6..38d55848 100644 --- a/packages/mobile/__tests__/ChatProvider.test.ts +++ b/packages/mobile/__tests__/ChatProvider.test.ts @@ -102,7 +102,7 @@ describe('ChatProvider', () => { (getRandom16ByteArray as jest.Mock) = mockGetRandom16Bytes; beforeEach(() => { dotYouClient = new DotYouClient({ - identity: 'frodobaggins.me', + loggedInIdentity: 'frodobaggins.me', api: ApiType.App, headers: {}, sharedSecret: new Uint8Array(32), @@ -235,7 +235,6 @@ describe('ChatProvider', () => { doNotIndex: false, allowDistribution: false, }, - priority: 1, }; const recipients = ['frodo', 'sam']; @@ -296,7 +295,6 @@ describe('ChatProvider', () => { doNotIndex: false, allowDistribution: false, }, - priority: 1, }; (deleteFile as jest.Mock).mockResolvedValue(true); @@ -355,7 +353,6 @@ describe('ChatProvider', () => { doNotIndex: false, allowDistribution: false, }, - priority: 1, }; const recipients = ['recipient1', 'recipient2']; diff --git a/packages/mobile/__tests__/ConversationProvider.test.ts b/packages/mobile/__tests__/ConversationProvider.test.ts index ace25833..29c7fe9c 100644 --- a/packages/mobile/__tests__/ConversationProvider.test.ts +++ b/packages/mobile/__tests__/ConversationProvider.test.ts @@ -82,7 +82,7 @@ jest.mock('react-native-fs', () => { describe('ConversationProvider', () => { const dotYouClientMock = new DotYouClient({ - identity: 'frodobaggins.me', + loggedInIdentity: 'frodobaggins.me', api: ApiType.App, headers: {}, sharedSecret: new Uint8Array(16), @@ -202,7 +202,6 @@ describe('ConversationProvider', () => { fileId: 'file-id', fileState: 'active', fileSystemType: 'Standard', - priority: 0, sharedSecretEncryptedKeyHeader: { encryptedAesKey: new Uint8Array(32), encryptionVersion: 1, @@ -278,7 +277,6 @@ describe('ConversationProvider', () => { isEncrypted: true, senderOdinId: 'frodo', }, - priority: 2, sharedSecretEncryptedKeyHeader: { encryptedAesKey: new Uint8Array(32), encryptionVersion: 1, From ea9107fe31104fd7c55aae5b0e8e106302523237 Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Mon, 16 Dec 2024 17:57:30 +0530 Subject: [PATCH 7/7] change to hostIdentity --- .../src/components/Feed/Interacts/Comments/CommentHead.tsx | 2 +- .../mobile/src/components/Feed/Interacts/PostInteracts.tsx | 2 +- packages/mobile/src/components/Feed/Meta/Meta.tsx | 4 ++-- packages/mobile/src/hooks/feed/useManageSocialFeed.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/mobile/src/components/Feed/Interacts/Comments/CommentHead.tsx b/packages/mobile/src/components/Feed/Interacts/Comments/CommentHead.tsx index 9af0075f..205bf6d5 100644 --- a/packages/mobile/src/components/Feed/Interacts/Comments/CommentHead.tsx +++ b/packages/mobile/src/components/Feed/Interacts/Comments/CommentHead.tsx @@ -35,7 +35,7 @@ export const CommentHead = memo( label: `${t('Block this user')}`, onPress: () => openURL( - `${new DotYouClient({ loggedInIdentity: identity, api: ApiType.Guest }).getRoot()}/owner/connections/${authorOdinId}/block` + `${new DotYouClient({ hostIdentity: identity, api: ApiType.Guest }).getRoot()}/owner/connections/${authorOdinId}/block` ), }); } diff --git a/packages/mobile/src/components/Feed/Interacts/PostInteracts.tsx b/packages/mobile/src/components/Feed/Interacts/PostInteracts.tsx index 6371f593..45e8a0d3 100644 --- a/packages/mobile/src/components/Feed/Interacts/PostInteracts.tsx +++ b/packages/mobile/src/components/Feed/Interacts/PostInteracts.tsx @@ -97,7 +97,7 @@ export const PostInteracts = memo( const permalink = useMemo( () => - `${new DotYouClient({ loggedInIdentity: odinId || undefined, api: ApiType.Guest }).getRoot()}/posts/${postContent.channelId}/${ + `${new DotYouClient({ hostIdentity: odinId || undefined, api: ApiType.Guest }).getRoot()}/posts/${postContent.channelId}/${ postContent.slug ?? postContent.id }`, [odinId, postContent] diff --git a/packages/mobile/src/components/Feed/Meta/Meta.tsx b/packages/mobile/src/components/Feed/Meta/Meta.tsx index 51c97fbf..05274494 100644 --- a/packages/mobile/src/components/Feed/Meta/Meta.tsx +++ b/packages/mobile/src/components/Feed/Meta/Meta.tsx @@ -64,7 +64,7 @@ export const PostMeta = memo( const channelLink = useMemo( () => channel - ? `${odinId ? new DotYouClient({ loggedInIdentity: odinId, api: ApiType.Guest }).getRoot() : dotYouClient.getRoot()}/posts/${ + ? `${odinId ? new DotYouClient({ hostIdentity: odinId, api: ApiType.Guest }).getRoot() : dotYouClient.getRoot()}/posts/${ channel.fileMetadata.appData.content.slug }${isConnected && identity ? '?youauth-logon=' + identity : ''}` : undefined, @@ -133,7 +133,7 @@ export const ToGroupBlock = memo( const channelLink = useMemo( () => channel - ? `${odinId ? new DotYouClient({ loggedInIdentity: odinId, api: ApiType.Guest }).getRoot() : dotYouClient.getRoot()}/posts/${ + ? `${odinId ? new DotYouClient({ hostIdentity: odinId, api: ApiType.Guest }).getRoot() : dotYouClient.getRoot()}/posts/${ channel.fileMetadata.appData.content.slug }${isConnected && identity ? '?youauth-logon=' + identity : ''}` : undefined, diff --git a/packages/mobile/src/hooks/feed/useManageSocialFeed.ts b/packages/mobile/src/hooks/feed/useManageSocialFeed.ts index c26ed892..f8dacba7 100644 --- a/packages/mobile/src/hooks/feed/useManageSocialFeed.ts +++ b/packages/mobile/src/hooks/feed/useManageSocialFeed.ts @@ -23,7 +23,7 @@ export const useManageSocialFeed = (props?: { odinId: string }) => { }; const getContentReportUrl = () => { - const host = new DotYouClient({ loggedInIdentity: odinId, api: ApiType.Guest }).getRoot(); + const host = new DotYouClient({ hostIdentity: odinId, api: ApiType.Guest }).getRoot(); // Fetch the reporting url from the other identities config return fetch(`${host}/config/reporting`)