mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
fix a bug of attachment not loading in one to one chats
This commit is contained in:
parent
fce86989f0
commit
316f37ae3d
|
@ -1,6 +1,6 @@
|
|||
/* global crypto */
|
||||
|
||||
const { isFunction, isNumber } = require('lodash');
|
||||
const { isFunction } = require('lodash');
|
||||
const { createLastMessageUpdate } = require('../../../ts/types/Conversation');
|
||||
const { arrayBufferToBase64 } = require('../crypto');
|
||||
|
||||
|
|
|
@ -210,7 +210,6 @@ const AvatarItem = (props: {
|
|||
};
|
||||
|
||||
const ConversationListItem = (props: Props) => {
|
||||
// console.warn('ConversationListItem', props.id.substr(-1), ': ', props);
|
||||
const {
|
||||
activeAt,
|
||||
unreadCount,
|
||||
|
|
|
@ -62,6 +62,7 @@ export const Image = (props: Props) => {
|
|||
const role = canClick ? 'button' : undefined;
|
||||
|
||||
const { loading, urlToLoad } = useEncryptedFileFetch(url, attachment.contentType);
|
||||
|
||||
// data will be url if loading is finished and '' if not
|
||||
const srcData = !loading ? urlToLoad : '';
|
||||
|
||||
|
|
|
@ -19,12 +19,13 @@ export const useEncryptedFileFetch = (url: string, contentType: string) => {
|
|||
}
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
mountedRef.current = true;
|
||||
void fetchUrl();
|
||||
|
||||
return () => {
|
||||
mountedRef.current = false;
|
||||
};
|
||||
}, [url]);
|
||||
|
||||
return { urlToLoad, loading };
|
||||
};
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
ConfigurationMessageContact,
|
||||
} from '../messages/outgoing/controlMessage/ConfigurationMessage';
|
||||
import { ConversationModel } from '../../models/conversation';
|
||||
import { fromBase64ToArray, fromHexToArray } from './String';
|
||||
import { fromBase64ToArray, fromHexToArray, toHex } from './String';
|
||||
import { SignalService } from '../../protobuf';
|
||||
import _ from 'lodash';
|
||||
import {
|
||||
|
@ -163,10 +163,20 @@ const getValidContacts = (convos: Array<ConversationModel>) => {
|
|||
const profileKey = c.get('profileKey');
|
||||
let profileKeyForContact;
|
||||
if (typeof profileKey === 'string') {
|
||||
profileKeyForContact = fromHexToArray(profileKey);
|
||||
// this will throw if the profileKey is not in hex.
|
||||
try {
|
||||
profileKeyForContact = fromHexToArray(profileKey);
|
||||
} catch (e) {
|
||||
profileKeyForContact = fromBase64ToArray(profileKey);
|
||||
// if the line above does not fail, update the stored profileKey for this convo
|
||||
void c.setProfileKey(profileKeyForContact);
|
||||
}
|
||||
} else if (profileKey) {
|
||||
console.warn('AUDRIC migration todo');
|
||||
debugger;
|
||||
window.log.warn(
|
||||
'Got a profileKey for a contact in another format than string. Contact: ',
|
||||
c.id
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ConfigurationMessageContact({
|
||||
|
|
Loading…
Reference in a new issue