fix a bug of attachment not loading in one to one chats

pull/1794/head
audric 4 years ago
parent fce86989f0
commit 316f37ae3d

@ -1,6 +1,6 @@
/* global crypto */ /* global crypto */
const { isFunction, isNumber } = require('lodash'); const { isFunction } = require('lodash');
const { createLastMessageUpdate } = require('../../../ts/types/Conversation'); const { createLastMessageUpdate } = require('../../../ts/types/Conversation');
const { arrayBufferToBase64 } = require('../crypto'); const { arrayBufferToBase64 } = require('../crypto');

@ -210,7 +210,6 @@ const AvatarItem = (props: {
}; };
const ConversationListItem = (props: Props) => { const ConversationListItem = (props: Props) => {
// console.warn('ConversationListItem', props.id.substr(-1), ': ', props);
const { const {
activeAt, activeAt,
unreadCount, unreadCount,

@ -62,6 +62,7 @@ export const Image = (props: Props) => {
const role = canClick ? 'button' : undefined; const role = canClick ? 'button' : undefined;
const { loading, urlToLoad } = useEncryptedFileFetch(url, attachment.contentType); const { loading, urlToLoad } = useEncryptedFileFetch(url, attachment.contentType);
// data will be url if loading is finished and '' if not // data will be url if loading is finished and '' if not
const srcData = !loading ? urlToLoad : ''; const srcData = !loading ? urlToLoad : '';

@ -19,12 +19,13 @@ export const useEncryptedFileFetch = (url: string, contentType: string) => {
} }
useEffect(() => { useEffect(() => {
setLoading(true);
mountedRef.current = true;
void fetchUrl(); void fetchUrl();
return () => { return () => {
mountedRef.current = false; mountedRef.current = false;
}; };
}, [url]); }, [url]);
return { urlToLoad, loading }; return { urlToLoad, loading };
}; };

@ -14,7 +14,7 @@ import {
ConfigurationMessageContact, ConfigurationMessageContact,
} from '../messages/outgoing/controlMessage/ConfigurationMessage'; } from '../messages/outgoing/controlMessage/ConfigurationMessage';
import { ConversationModel } from '../../models/conversation'; import { ConversationModel } from '../../models/conversation';
import { fromBase64ToArray, fromHexToArray } from './String'; import { fromBase64ToArray, fromHexToArray, toHex } from './String';
import { SignalService } from '../../protobuf'; import { SignalService } from '../../protobuf';
import _ from 'lodash'; import _ from 'lodash';
import { import {
@ -163,10 +163,20 @@ const getValidContacts = (convos: Array<ConversationModel>) => {
const profileKey = c.get('profileKey'); const profileKey = c.get('profileKey');
let profileKeyForContact; let profileKeyForContact;
if (typeof profileKey === 'string') { 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) { } else if (profileKey) {
console.warn('AUDRIC migration todo'); window.log.warn(
debugger; 'Got a profileKey for a contact in another format than string. Contact: ',
c.id
);
return null;
} }
return new ConfigurationMessageContact({ return new ConfigurationMessageContact({

Loading…
Cancel
Save