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 Subscriptions #140

Closed
wants to merge 3 commits into from
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
1 change: 1 addition & 0 deletions src/lib/ApiConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const ApiConnection = ({ children }) => (
const wsLink = new WebSocketLink({
uri: publicRuntimeConfig.GRAPHQL_API.replace(/https/, 'wss').replace(/http/, 'ws'),
options: {
lazy: true,
reconnect: true,
connectionParams: {
authToken: auth.apiToken,
Expand Down
17 changes: 0 additions & 17 deletions src/lib/subscription/Backups.js

This file was deleted.

15 changes: 0 additions & 15 deletions src/lib/subscription/Deployments.js

This file was deleted.

13 changes: 0 additions & 13 deletions src/lib/subscription/Tasks.js

This file was deleted.

49 changes: 1 addition & 48 deletions src/pages/backups.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import NavTabsSkeleton from 'components/NavTabs/NavTabsSkeleton';
import ResultsLimited from 'components/ResultsLimited';
import MainLayout from 'layouts/MainLayout';
import EnvironmentWithBackupsQuery from 'lib/query/EnvironmentWithBackups';
import BackupsSubscription from 'lib/subscription/Backups';
import * as R from 'ramda';

import EnvironmentNotFound from '../components/errors/EnvironmentNotFound';
import QueryError from '../components/errors/QueryError';
import { CommonWrapperWNotification } from '../styles/commonPageStyles';
Expand All @@ -34,7 +32,7 @@ export const PageBackups = ({ router }) => {
const [resultLimit, setResultLimit] = useState(null);

const { continueTour } = useTourContext();
const { data, error, loading, subscribeToMore } = useQuery(EnvironmentWithBackupsQuery, {
const { data, error, loading } = useQuery(EnvironmentWithBackupsQuery, {
variables: {
openshiftProjectName: router.query.openshiftProjectName,
limit: resultLimit,
Expand Down Expand Up @@ -117,51 +115,6 @@ export const PageBackups = ({ router }) => {
);
}

subscribeToMore({
document: BackupsSubscription,
variables: { environment: environment.id },
updateQuery: (prevStore, { subscriptionData }) => {
if (!subscriptionData.data) return prevStore;
const prevBackups = prevStore.environment.backups;
const incomingBackup = subscriptionData.data.backupChanged;
const existingIndex = prevBackups.findIndex(prevBackup => prevBackup.id === incomingBackup.id);
let newBackups;

// New backup.
if (existingIndex === -1) {
// Don't add new deleted backups.
if (incomingBackup.deleted !== '0000-00-00 00:00:00') {
return prevStore;
}

newBackups = [incomingBackup, ...prevBackups];
}
// Existing backup.
else {
// Updated backup
if (incomingBackup.deleted === '0000-00-00 00:00:00') {
newBackups = Object.assign([...prevBackups], {
[existingIndex]: incomingBackup,
});
}
// Deleted backup
else {
newBackups = R.remove(existingIndex, 1, prevBackups);
}
}

const newStore = {
...prevStore,
environment: {
...prevStore.environment,
backups: newBackups,
},
};

return newStore;
},
});

return (
<>
<Head>
Expand Down
37 changes: 1 addition & 36 deletions src/pages/deployments.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import NavTabsSkeleton from 'components/NavTabs/NavTabsSkeleton';
import ResultsLimited from 'components/ResultsLimited';
import MainLayout from 'layouts/MainLayout';
import EnvironmentWithDeploymentsQuery from 'lib/query/EnvironmentWithDeployments';
import DeploymentsSubscription from 'lib/subscription/Deployments';

import EnvironmentNotFound from '../components/errors/EnvironmentNotFound';
import QueryError from '../components/errors/QueryError';
import { DeploymentsWrapper } from '../styles/pageStyles';
Expand All @@ -36,7 +34,7 @@ export const PageDeployments = ({ router }) => {

const [resultLimit, setResultLimit] = useState(null);

const { data, error, loading, subscribeToMore, refetch } = useQuery(EnvironmentWithDeploymentsQuery, {
const { data, error, loading, refetch } = useQuery(EnvironmentWithDeploymentsQuery, {
variables: {
openshiftProjectName: router.query.openshiftProjectName,
limit: resultLimit,
Expand Down Expand Up @@ -119,39 +117,6 @@ export const PageDeployments = ({ router }) => {
);
}

subscribeToMore({
document: DeploymentsSubscription,
variables: { environment: environment.id },
updateQuery: (prevStore, { subscriptionData }) => {
if (!subscriptionData.data) return prevStore;
const prevDeployments = prevStore.environment.deployments;
const incomingDeployment = subscriptionData.data.deploymentChanged;
const existingIndex = prevDeployments.findIndex(prevDeployment => prevDeployment.id === incomingDeployment.id);
let newDeployments;

// New deployment.
if (existingIndex === -1) {
newDeployments = [incomingDeployment, ...prevDeployments];
}
// Updated deployment
else {
newDeployments = Object.assign([...prevDeployments], {
[existingIndex]: incomingDeployment,
});
}

const newStore = {
...prevStore,
environment: {
...prevStore.environment,
deployments: newDeployments,
},
};

return newStore;
},
});

return (
<>
<Head>
Expand Down
37 changes: 1 addition & 36 deletions src/pages/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import Tasks from 'components/Tasks';
import TasksSkeleton from 'components/Tasks/TasksSkeleton';
import MainLayout from 'layouts/MainLayout';
import EnvironmentWithTasksQuery from 'lib/query/EnvironmentWithTasks';
import TasksSubscription from 'lib/subscription/Tasks';

import EnvironmentNotFound from '../components/errors/EnvironmentNotFound';
import QueryError from '../components/errors/QueryError';
import { TasksWrapper } from '../styles/pageStyles';
Expand All @@ -35,7 +33,7 @@ export const PageTasks = ({ router, renderAddTasks }) => {
const [resultLimit, setResultLimit] = useState(null);

const { continueTour } = useTourContext();
const { data, error, loading, subscribeToMore, refetch } = useQuery(EnvironmentWithTasksQuery, {
const { data, error, loading, refetch } = useQuery(EnvironmentWithTasksQuery, {
variables: {
openshiftProjectName: router.query.openshiftProjectName,
limit: resultLimit,
Expand Down Expand Up @@ -120,39 +118,6 @@ export const PageTasks = ({ router, renderAddTasks }) => {
);
}

subscribeToMore({
document: TasksSubscription,
variables: { environment: environment.id },
updateQuery: (prevStore, { subscriptionData }) => {
if (!subscriptionData.data) return prevStore;
const prevTasks = prevStore.environment.tasks;
const incomingTask = subscriptionData.data.taskChanged;
const existingIndex = prevTasks.findIndex(prevTask => prevTask.id === incomingTask.id);
let newTasks;

// New task.
if (existingIndex === -1) {
newTasks = [incomingTask, ...prevTasks];
}
// Updated task
else {
newTasks = Object.assign([...prevTasks], {
[existingIndex]: incomingTask,
});
}

const newStore = {
...prevStore,
environment: {
...prevStore.environment,
tasks: newTasks,
},
};

return newStore;
},
});

return (
<>
<Head>
Expand Down
Loading