Merge pull request #3065 from Bilb/fix-regression-tests

Fix regression tests
pull/3067/head
Audric Ackermann 2 months ago committed by GitHub
commit 563e4cc752
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -63,15 +63,12 @@ export const SessionWrapperModal = (props: SessionWrapperModalType) => {
}
};
const fallbackFocusId = 'session-wrapper-modal';
return (
<FocusTrap focusTrapOptions={{ fallbackFocus: `#${fallbackFocusId}`, allowOutsideClick: true }}>
<FocusTrap focusTrapOptions={{ initialFocus: false, allowOutsideClick: true }}>
<div
className={classNames('loki-dialog modal', additionalClassName || null)}
onClick={handleClick}
role="dialog"
id={fallbackFocusId}
>
<div className="session-confirm-wrapper">
<div ref={modalRef} className="session-modal">

@ -69,7 +69,7 @@ export const SelectionOverlay = () => {
const classNameAndId = 'message-selection-overlay';
return (
<FocusTrap focusTrapOptions={{ fallbackFocus: `#${classNameAndId}`, allowOutsideClick: true }}>
<FocusTrap focusTrapOptions={{ initialFocus: false, allowOutsideClick: true }}>
<div className={classNameAndId} id={classNameAndId}>
<div className="close-button">
<SessionIconButton iconType="exit" iconSize="medium" onClick={onCloseOverlay} />

@ -6,7 +6,7 @@ import { useMessageExpirationPropsById } from '../../../../hooks/useParamSelecto
import { useMessageStatus } from '../../../../state/selectors';
import { useIsDetailMessageView } from '../../../../contexts/isDetailViewContext';
import { getMostRecentMessageId } from '../../../../state/selectors/conversations';
import { getMostRecentOutgoingMessageId } from '../../../../state/selectors/conversations';
import { useSelectedIsGroupOrCommunity } from '../../../../state/selectors/selectedConversation';
import { SpacerXS } from '../../../basic/Text';
import { SessionIcon, SessionIconType } from '../../../icon';
@ -122,10 +122,9 @@ function useIsExpiring(messageId: string) {
);
}
function useIsMostRecentMessage(messageId: string) {
const mostRecentMessageId = useSelector(getMostRecentMessageId);
const isMostRecentMessage = mostRecentMessageId === messageId;
return isMostRecentMessage;
function useIsMostRecentOutgoingMessage(messageId: string) {
const mostRecentOutgoingMessageId = useSelector(getMostRecentOutgoingMessageId);
return mostRecentOutgoingMessageId === messageId;
}
function MessageStatusExpireTimer(props: Pick<Props, 'messageId'>) {
@ -180,11 +179,11 @@ function IconForExpiringMessageId({
const MessageStatusSent = ({ dataTestId, messageId }: Omit<Props, 'isDetailView'>) => {
const isExpiring = useIsExpiring(messageId);
const isMostRecentMessage = useIsMostRecentMessage(messageId);
const isMostRecentOutgoingMessage = useIsMostRecentOutgoingMessage(messageId);
const isGroup = useSelectedIsGroupOrCommunity();
// we hide a "sent" message status which is not expiring except for the most recent message
if (!isExpiring && !isMostRecentMessage) {
// we hide the "sent" message status for a non-expiring messages unless it's the most recent outgoing message
if (!isExpiring && !isMostRecentOutgoingMessage) {
return null;
}
return (
@ -208,10 +207,10 @@ const MessageStatusRead = ({
const isExpiring = useIsExpiring(messageId);
const isGroup = useSelectedIsGroupOrCommunity();
const isMostRecentMessage = useIsMostRecentMessage(messageId);
const isMostRecentOutgoingMessage = useIsMostRecentOutgoingMessage(messageId);
// we hide an outgoing "read" message status which is not expiring except for the most recent message
if (!isIncoming && !isExpiring && !isMostRecentMessage) {
if (!isIncoming && !isExpiring && !isMostRecentOutgoingMessage) {
return null;
}

@ -18,11 +18,22 @@ import { SessionRadioGroup } from '../basic/SessionRadioGroup';
const deleteDbLocally = async () => {
window?.log?.info('last message sent successfully. Deleting everything');
window.persistStore?.purge();
window?.log?.info('store purged');
await deleteAllLogs();
window?.log?.info('deleteAllLogs: done');
await Data.removeAll();
window?.log?.info('Data.removeAll: done');
await Data.close();
window?.log?.info('Data.close: done');
await Data.removeDB();
window?.log?.info('Data.removeDB: done');
await Data.removeOtherData();
window?.log?.info('Data.removeOtherData: done');
window.localStorage.setItem('restart-reason', 'delete-account');
};

@ -790,8 +790,20 @@ async function removeDB() {
try {
console.error('Remove DB: removing.', userDir);
userConfig.remove();
ephemeralConfig.remove();
try {
userConfig.remove();
} catch (e) {
if (e.code !== 'ENOENT') {
throw e;
}
}
try {
ephemeralConfig.remove();
} catch (e) {
if (e.code !== 'ENOENT') {
throw e;
}
}
} catch (e) {
console.error('Remove DB: Failed to remove configs.', e);
}

@ -1,7 +1,7 @@
import { app, ipcMain } from 'electron';
import { sqlNode } from './sql'; // checked - only node
import { userConfig } from './config/user_config'; // checked - only node
import { ephemeralConfig } from './config/ephemeral_config'; // checked - only node
import { userConfig } from './config/user_config'; // checked - only node
import { sqlNode } from './sql'; // checked - only node
let initialized = false;
@ -31,8 +31,20 @@ export function initializeSqlChannel() {
ipcMain.on(ERASE_SQL_KEY, event => {
try {
userConfig.remove();
ephemeralConfig.remove();
try {
userConfig.remove();
} catch (e) {
if (e.code !== 'ENOENT') {
throw e;
}
}
try {
ephemeralConfig.remove();
} catch (e) {
if (e.code !== 'ENOENT') {
throw e;
}
}
event.sender.send(`${ERASE_SQL_KEY}-done`);
} catch (error) {
const errorForDisplay = error && error.stack ? error.stack : error;

@ -1,8 +1,8 @@
import path from 'path';
import { app, BrowserWindow, Menu, Tray } from 'electron';
import { LocaleMessagesType } from './locale';
import { getAppRootPath } from './getRootPath';
import { LocaleMessagesType } from './locale';
let trayContextMenu = null;
let tray: Tray | null = null;

@ -1,4 +1,4 @@
import { omit } from 'lodash';
import { isArray, omit } from 'lodash';
import { Snode } from '../../../data/data';
import { updateIsOnline } from '../../../state/ducks/onion';
import { doSnodeBatchRequest } from './batchRequest';
@ -7,6 +7,7 @@ import { SnodeNamespace, SnodeNamespaces } from './namespaces';
import { TTL_DEFAULT } from '../../constants';
import { UserUtils } from '../../utils';
import { sleepFor } from '../../utils/Promise';
import {
RetrieveLegacyClosedGroupSubRequestType,
RetrieveSubRequestType,
@ -123,14 +124,14 @@ async function retrieveNextMessages(
);
// let exceptions bubble up
// no retry for this one as this a call we do every few seconds while polling for messages
const results = await doSnodeBatchRequest(
retrieveRequestsParams,
targetNode,
4000,
associatedWith
);
if (!results || !results.length) {
const timeOutMs = 4 * 1000;
const timeoutPromise = async () => sleepFor(timeOutMs);
const fetchPromise = async () =>
doSnodeBatchRequest(retrieveRequestsParams, targetNode, timeOutMs, associatedWith);
// just to make sure that we don't hang for more than timeOutMs
const results = await Promise.race([timeoutPromise(), fetchPromise()]);
if (!results || !isArray(results) || !results.length) {
window?.log?.warn(
`_retrieveNextMessages - sessionRpc could not talk to ${targetNode.ip}:${targetNode.port}`
);

@ -228,12 +228,21 @@ export class SwarmPolling {
let resultsFromAllNamespaces: RetrieveMessagesResultsBatched | null;
try {
// Note: always print something so we know if the polling is hanging
window.log.info(
`about to pollNodeForKey of ${ed25519Str(pubkey.key)} from snode: ${ed25519Str(toPollFrom.pubkey_ed25519)} namespaces: ${namespaces} `
);
resultsFromAllNamespaces = await this.pollNodeForKey(
toPollFrom,
pubkey,
namespaces,
!isGroup
);
// Note: always print something so we know if the polling is hanging
window.log.info(
`pollNodeForKey of ${ed25519Str(pubkey.key)} from snode: ${ed25519Str(toPollFrom.pubkey_ed25519)} namespaces: ${namespaces} returned: ${resultsFromAllNamespaces?.length}`
);
} catch (e) {
window.log.warn(
`pollNodeForKey of ${pubkey} namespaces: ${namespaces} failed with: ${e.message}`
@ -475,6 +484,9 @@ export class SwarmPolling {
return last(r.messages.messages);
});
window.log.info(
`updating last hashes for ${ed25519Str(pubkey.key)}: ${ed25519Str(snodeEdkey)} ${lastMessages.map(m => m?.hash || '')}`
);
await Promise.all(
lastMessages.map(async (lastMessage, index) => {
if (!lastMessage) {

@ -593,6 +593,13 @@ export const getMostRecentMessageId = (state: StateType): string | null => {
return state.conversations.mostRecentMessageId;
};
export const getMostRecentOutgoingMessageId = createSelector(
getSortedMessagesOfSelectedConversation,
(messages: Array<MessageModelPropsWithoutConvoProps>): string | undefined => {
return messages.find(m => m.propsForMessage.direction === 'outgoing')?.propsForMessage.id;
}
);
export const getOldestMessageId = createSelector(
getSortedMessagesOfSelectedConversation,
(messages: Array<MessageModelPropsWithoutConvoProps>): string | undefined => {

Loading…
Cancel
Save