Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the old websocket notif subscription (pt 3) #5212

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -190,31 +190,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
Loading