Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade deps and fix breaking changes #309

Merged
merged 7 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions packages/mobile/__tests__/ChatProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -235,7 +235,6 @@ describe('ChatProvider', () => {
doNotIndex: false,
allowDistribution: false,
},
priority: 1,
};

const recipients = ['frodo', 'sam'];
Expand Down Expand Up @@ -296,7 +295,6 @@ describe('ChatProvider', () => {
doNotIndex: false,
allowDistribution: false,
},
priority: 1,
};

(deleteFile as jest.Mock).mockResolvedValue(true);
Expand Down Expand Up @@ -355,7 +353,6 @@ describe('ChatProvider', () => {
doNotIndex: false,
allowDistribution: false,
},
priority: 1,
};
const recipients = ['recipient1', 'recipient2'];

Expand Down
4 changes: 1 addition & 3 deletions packages/mobile/__tests__/ConversationProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -202,7 +202,6 @@ describe('ConversationProvider', () => {
fileId: 'file-id',
fileState: 'active',
fileSystemType: 'Standard',
priority: 0,
sharedSecretEncryptedKeyHeader: {
encryptedAesKey: new Uint8Array(32),
encryptionVersion: 1,
Expand Down Expand Up @@ -278,7 +277,6 @@ describe('ConversationProvider', () => {
isEncrypted: true,
senderOdinId: 'frodo',
},
priority: 2,
sharedSecretEncryptedKeyHeader: {
encryptedAesKey: new Uint8Array(32),
encryptionVersion: 1,
Expand Down
6 changes: 3 additions & 3 deletions packages/mobile/__tests__/RNPostReactionProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ describe('RNPostReactionProvider', () => {
let context: ReactionContext;
let comment: NewHomebaseFile<RawReactionContent> | HomebaseFile<RawReactionContent>;
const dotYouClient = new DotYouClient({
identity: 'frodobaggins.me',
loggedInIdentity: 'frodobaggins.me',
api: ApiType.App,
headers: {},
sharedSecret: new Uint8Array(32),
});
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 = {
Expand Down Expand Up @@ -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();
});
Expand Down
9 changes: 3 additions & 6 deletions packages/mobile/__tests__/RNPostUploadProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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 = {
Expand All @@ -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',
Expand Down Expand Up @@ -164,7 +164,6 @@ describe('RNPostUploadProvider', () => {

const fileHeader: HomebaseFile<string> = {
fileId: 'existing-file-id',
priority: 0,
sharedSecretEncryptedKeyHeader: {
encryptedAesKey: new Uint8Array(32),
iv: new Uint8Array(16),
Expand Down Expand Up @@ -222,7 +221,6 @@ describe('RNPostUploadProvider', () => {

const fileHeader: HomebaseFile<string> = {
fileId: 'existing-file-id',
priority: 0,
sharedSecretEncryptedKeyHeader: {
encryptedAesKey: new Uint8Array(32),
iv: new Uint8Array(16),
Expand Down Expand Up @@ -321,7 +319,6 @@ describe('RNPostUploadProvider', () => {

const fileHeader: HomebaseFile<string> = {
fileId: 'existing-file-id',
priority: 0,
sharedSecretEncryptedKeyHeader: {
encryptedAesKey: new Uint8Array(32),
iv: new Uint8Array(16),
Expand Down
4 changes: 2 additions & 2 deletions packages/mobile/src/components/Chat/Chat-Connected-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import TextButton from '../ui/Text/Text-Button';

export const ChatConnectedState = (conversation: HomebaseFile<UnifiedConversation> | undefined) => {
const { isDarkMode } = useDarkMode();
const identity = useDotYouClientContext().getIdentity();
const identity = useDotYouClientContext().getLoggedInIdentity();
const [expanded, setExpanded] = useState(false);
const validRecipientsState = useSharedValue<string[]>([]);
const sharedExpanded = useSharedValue<boolean>(false);
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/src/components/Chat/Chat-Forward.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/src/components/Chat/Chat-Reaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) || [],
Expand Down
2 changes: 2 additions & 0 deletions packages/mobile/src/components/Chat/ChatDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -1255,6 +1256,7 @@ const RenderReplyMessageView = memo(
)}
</View>
{replyMessage &&
replyMessage.fileMetadata.payloads &&
replyMessage.fileMetadata.payloads?.length > 0 &&
replyMessage.fileMetadata.payloads[0].contentType.startsWith('image') && (
<OdinImage
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/src/components/Chat/Conversation-tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type ConversationTileProps = {
};

const ConversationTile = memo((props: ConversationTileProps) => {
const identity = useDotYouClientContext().getIdentity();
const identity = useDotYouClientContext().getLoggedInIdentity();
const { data: chatMessages } = useChatMessages({
conversationId: props.conversationId,
}).all;
Expand Down
10 changes: 6 additions & 4 deletions packages/mobile/src/components/Chat/MediaMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
({
Expand Down Expand Up @@ -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
) {
Expand Down Expand Up @@ -91,6 +92,7 @@ const InnerMediaMessage = memo(

const onClick = useCallback(
(currIndex?: number) => {
if (!payloads) return;
navigation.navigate('PreviewMedia', {
fileId: currentMessage.fileId,
payloads: payloads,
Expand All @@ -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(
Expand All @@ -122,7 +124,7 @@ const InnerMediaMessage = memo(
[previewThumbnail, width, height]
);

if (payloads.length === 1) {
if (payloads?.length === 1) {
return (
<MediaItem
key={`${currentMessage.fileMetadata.appData.content}_${payloads[0].key}`}
Expand Down Expand Up @@ -152,7 +154,7 @@ const InnerMediaMessage = memo(
return (
<MediaGallery
fileId={currentMessage.fileId}
payloads={payloads}
payloads={payloads as PayloadDescriptor[]}
targetDrive={ChatDrive}
previewThumbnail={currentMessage.fileMetadata.appData.previewThumbnail}
onLongPress={(e) => onLongPress(e, currentMessage)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () =>
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/src/components/Chat/Reply-Message-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/src/components/Contact/NoContacts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<View style={{ padding: 16, flexDirection: 'row', flexWrap: 'wrap', gap: 8 }}>
<Text style={{ color: Colors.gray[400], fontStyle: 'italic' }}>
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/src/components/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const AppLink = (props: {
icon: FC<BrandIconProps>;
}) => {
const { isDarkMode } = useDarkMode();
const identity = useDotYouClientContext().getIdentity();
const identity = useDotYouClientContext().getLoggedInIdentity();
const { data: unreadCount } = useUnreadPushNotificationsCount({ appId: props.appId });

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<NavigationProp<ChatStackParamList>>();
const tabNavigator = useNavigation<NavigationProp<TabStackParamList>>();

Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const ArticleComposer = ({
},
[setChannel]
);
const identity = useDotYouClientContext().getIdentity();
const identity = useDotYouClientContext().getLoggedInIdentity();
const [isEditTeaser, setIsEditTeaser] = useState(true);

const editor = useEditorBridge({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const PostDetailCard = memo(
}) => {
const { isDarkMode } = useDarkMode();
const doubleTapRef = useRef<GestureType>();
const identity = useDotYouClientContext().getIdentity();
const identity = useDotYouClientContext().getLoggedInIdentity();

if (!postFile) return <ActivityIndicator />;
const post = postFile.fileMetadata.appData.content;
Expand Down
Loading
Loading