do not trigger redux update if onion path did not change

pull/1884/head
audric 4 years ago
parent 4968244491
commit ec2eab6e23

@ -93,6 +93,7 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
padding: 10px;
} }
.module-message__generic-attachment__icon-container { .module-message__generic-attachment__icon-container {

@ -142,9 +142,13 @@ export async function getOnionPath(toExclude?: Snode): Promise<Array<Snode>> {
} }
if (onionPaths.length <= 0) { if (onionPaths.length <= 0) {
window.inboxStore?.dispatch(updateOnionPaths([])); if (!_.isEmpty(window.inboxStore?.getState().onionPaths.snodePaths)) {
window.inboxStore?.dispatch(updateOnionPaths([]));
}
} else { } else {
window.inboxStore?.dispatch(updateOnionPaths(onionPaths)); if (!_.isEqual(window.inboxStore?.getState().onionPaths.snodePaths, onionPaths)) {
window.inboxStore?.dispatch(updateOnionPaths(onionPaths));
}
} }
const onionPathsWithoutExcluded = toExclude const onionPathsWithoutExcluded = toExclude

@ -578,12 +578,16 @@ export async function retrieveNextMessages(
try { try {
const json = JSON.parse(result.body); const json = JSON.parse(result.body);
window.inboxStore?.dispatch(updateIsOnline(true)); if (!window.inboxStore?.getState().onionPaths.isOnline) {
window.inboxStore?.dispatch(updateIsOnline(true));
}
return json.messages || []; return json.messages || [];
} catch (e) { } catch (e) {
window?.log?.warn('exception while parsing json of nextMessage:', e); window?.log?.warn('exception while parsing json of nextMessage:', e);
window.inboxStore?.dispatch(updateIsOnline(true)); if (!window.inboxStore?.getState().onionPaths.isOnline) {
window.inboxStore?.dispatch(updateIsOnline(true));
}
throw new Error( throw new Error(
`loki_message:::_retrieveNextMessages - exception while parsing json of nextMessage ${targetNode.ip}:${targetNode.port}: ${e?.message}` `loki_message:::_retrieveNextMessages - exception while parsing json of nextMessage ${targetNode.ip}:${targetNode.port}: ${e?.message}`
); );

@ -296,9 +296,13 @@ export class SwarmPolling {
); );
} catch (e) { } catch (e) {
if (e.message === ERROR_CODE_NO_CONNECT) { if (e.message === ERROR_CODE_NO_CONNECT) {
window.inboxStore?.dispatch(updateIsOnline(false)); if (window.inboxStore?.getState().onionPaths.isOnline) {
window.inboxStore?.dispatch(updateIsOnline(false));
}
} else { } else {
window.inboxStore?.dispatch(updateIsOnline(true)); if (!window.inboxStore?.getState().onionPaths.isOnline) {
window.inboxStore?.dispatch(updateIsOnline(true));
}
} }
window?.log?.info('pollNodeForKey failed with', e.message); window?.log?.info('pollNodeForKey failed with', e.message);
return null; return null;

Loading…
Cancel
Save