Skip to content

Commit

Permalink
Revert "Add back async alerts"
Browse files Browse the repository at this point in the history
This reverts commit 3201204.
  • Loading branch information
ewc340 committed Mar 5, 2022
1 parent 7c760c2 commit 25d6cce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 40 deletions.
35 changes: 2 additions & 33 deletions renderer/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { useCallback, useEffect, useState } from 'react';
import React, { useEffect, useState } from 'react';
import Joyride, { Step } from 'react-joyride';
import { remote, ipcRenderer } from 'electron';
import * as electronJSONStorage from 'electron-json-storage';
import { connect } from 'react-redux';
import { Dispatch } from 'redux';
import smalltalk from 'smalltalk';
import { Dashboard } from './Dashboard';
import { DNav } from './DNav';
import { joyrideSteps } from './JoyrideSteps';
Expand All @@ -21,19 +20,12 @@ library.add(fas);

const storage = remote.require('electron-json-storage') as ElectronJSONStorage;

// TODO: synchronize below type with AsyncAlerts Redux state
interface Alert {
heading?: string;
message?: string;
id: number;
}

interface StateProps {
connectionStatus: boolean;
runtimeStatus: boolean;
masterStatus: boolean;
isRunningCode: boolean;
asyncAlerts: Array<Alert>;
asyncAlerts: Array<Object>;
globalTheme: string;
}

Expand All @@ -47,8 +39,6 @@ type Props = StateProps & DispatchProps;
export const AppComponent = (props: Props) => {
const [steps, changeSteps] = useState<Array<Step>>([]);
const [tourRunning, changeTourRunning] = useState(false);

const { asyncAlerts } = props;
startLog();

useEffect(() => {
Expand Down Expand Up @@ -82,27 +72,6 @@ export const AppComponent = (props: Props) => {
});
}, []);

const updateAlert = useCallback(
(latestAlert: Alert) => {
smalltalk.alert(latestAlert.heading, latestAlert.message).then(
() => {
props.onAlertDone(latestAlert.id);
},
() => {
props.onAlertDone(latestAlert.id);
}
);
},
[props]
);

useEffect(() => {
const latestAlert = asyncAlerts[asyncAlerts.length - 1] as Alert;
if (latestAlert !== undefined) {
updateAlert(latestAlert);
}
}, [asyncAlerts, updateAlert]);

const addSteps = (newSteps: Array<Step>) => {
if (!Array.isArray(newSteps)) {
newSteps = [newSteps];
Expand Down
12 changes: 5 additions & 7 deletions renderer/reducers/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import { AddAsyncAlertAction, RemoveAsyncAlertAction } from '../types';

type Actions = AddAsyncAlertAction | RemoveAsyncAlertAction;

interface Alert {
id: number;
type AsyncAlertsState = Array<{
id?: number;
heading?: string;
message?: string;
}

type AsyncAlertsState = Array<Alert>;
}>;

const initialState: AsyncAlertsState = [];

Expand All @@ -25,8 +23,8 @@ export const asyncAlerts = (state: AsyncAlertsState = initialState, action: Acti
{
id: action.id,
heading: action.heading,
message: action.message
}
message: action.message,
},
];
case consts.AlertActionsTypes.REMOVE_ASYNC_ALERT:
return state.filter((el: { id?: number }) => el.id !== action.id);
Expand Down

0 comments on commit 25d6cce

Please sign in to comment.