Skip to content

Commit

Permalink
Remove websocket subscription for notifications scope in redux explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
jinchung committed Nov 30, 2023
1 parent 59c2407 commit b8376a5
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 65 deletions.
13 changes: 0 additions & 13 deletions src/migrations/__tests__/migrations-prod.test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@ jest.mock('@/env', () => ({
IS_PROD: true,
}));

/*
* We need to mock below two mocks because one of the migrations has imported our redux store
* which has a lot of module dependencies. We don't want to mock all of them so we mock the used redux files
* since we are not testing them here.
*/
jest.mock('@/redux/explorer', () => ({
notificationsSubscription: jest.fn(),
}));

jest.mock('@/redux/store', () => ({
dispatch: jest.fn(),
}));

describe(`@/migrations IS_PROD`, () => {
const storage = new MMKV({ id: MIGRATIONS_STORAGE_ID });

Expand Down
13 changes: 0 additions & 13 deletions src/migrations/__tests__/migrations.test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@ import {
MIGRATIONS_STORAGE_ID,
} from '@/migrations/types';

/*
* We need to mock below two mocks because one of the migrations has imported our redux store
* which has a lot of module dependencies. We don't want to mock all of them so we mock the used redux files
* since we are not testing them here.
*/
jest.mock('@/redux/explorer', () => ({
notificationsSubscription: jest.fn(),
}));

jest.mock('@/redux/store', () => ({
dispatch: jest.fn(),
}));

InteractionManager.runAfterInteractions = jest.fn();

describe(`@/migrations`, () => {
Expand Down
14 changes: 3 additions & 11 deletions src/notifications/settings/__tests__/initialization.test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,10 @@ const EMPTY_INIT_STATE = {
};

/*
* We need to mock below three mocks because one of the migrations has imported our redux store
* which has a lot of module dependencies and firebase which mocks aren't working as they should.
* We don't want to mock all of them so we mock the used redux and firebase files, since we are not testing them here.
* We need to mock firebase below because one of the migrations imports
* firebase where mocks aren't working as they should.
* We don't want to mock all of them so we mock the firebase file, since we are not testing them here.
*/
jest.mock('@/redux/explorer', () => ({
notificationsSubscription: jest.fn(),
}));

jest.mock('@/redux/store', () => ({
dispatch: jest.fn(),
}));

jest.mock('@/notifications/settings/firebase');

describe('Notification settings initialization', () => {
Expand Down
3 changes: 0 additions & 3 deletions src/notifications/settings/initialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import {
notificationSettingsStorage,
setAllNotificationSettingsToStorage,
} from '@/notifications/settings/storage';
import { notificationsSubscription } from '@/redux/explorer';
import store from '@/redux/store';
import {
subscribeWalletToAllEnabledTopics,
unsubscribeWalletFromAllNotificationTopics,
Expand Down Expand Up @@ -114,7 +112,6 @@ export const _prepareSubscriptionQueueAndCreateInitialSettings = (
const { alreadySaved, newSettings, subscriptionQueue } = initializationState;
// preparing list of wallets that need to be subscribed
addresses.forEach(entry => {
store.dispatch(notificationsSubscription(entry.address));
const alreadySavedEntry = alreadySaved.get(entry.address);
// handling a case where we import a seed phrase of a previously watched wallet
if (
Expand Down
25 changes: 0 additions & 25 deletions src/redux/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,31 +188,6 @@ const portfolioSubscription = (
},
];

/**
* Configures a notifications subscription.
*
* @param address The address to subscribe to.
* @returns Arguments for an `emit` function call.
*/
export const notificationsSubscription = (address: string) => (
_: Dispatch,
getState: AppGetState
) => {
const { addressSocket } = getState().explorer;

const payload: SocketEmitArguments = [
'get',
{
payload: {
address,
action: 'subscribe',
},
scope: ['notifications'],
},
];
addressSocket?.emit(...payload);
};

/**
* Configures an asset price subscription.
*
Expand Down

0 comments on commit b8376a5

Please sign in to comment.