2018-03-19 13:06:31 -06:00
|
|
|
import { EnvName } from "./interfaces";
|
2018-03-23 09:44:06 -06:00
|
|
|
import { determineInstalledOsVersion, MinVersionOverride } from "../util/index";
|
2018-03-19 14:01:05 -06:00
|
|
|
import { maybeGetDevice } from "../resources/selectors";
|
|
|
|
import { MW } from "./middlewares";
|
|
|
|
import { Everything } from "../interfaces";
|
2018-07-27 11:48:59 -06:00
|
|
|
import { Store, Action } from "redux";
|
2018-03-19 14:01:05 -06:00
|
|
|
import { Dispatch } from "redux";
|
2018-03-23 09:44:06 -06:00
|
|
|
import { createReminderFn } from "./upgrade_reminder";
|
2018-03-19 12:39:17 -06:00
|
|
|
|
2018-03-23 09:44:06 -06:00
|
|
|
const maybeRemindUserToUpdate = createReminderFn();
|
2018-03-23 09:16:32 -06:00
|
|
|
|
|
|
|
function getVersionFromState(state: Everything) {
|
|
|
|
const device = maybeGetDevice(state.resources.index);
|
2018-03-23 09:44:06 -06:00
|
|
|
const v =
|
|
|
|
determineInstalledOsVersion(state.bot, device) || MinVersionOverride.ALWAYS;
|
2018-03-24 08:32:57 -06:00
|
|
|
maybeRemindUserToUpdate(v);
|
|
|
|
return v;
|
2018-03-23 09:16:32 -06:00
|
|
|
}
|
|
|
|
|
2018-03-19 14:01:05 -06:00
|
|
|
const fn: MW =
|
|
|
|
(store: Store<Everything>) =>
|
2018-07-27 11:48:59 -06:00
|
|
|
(dispatch: Dispatch<Action<object>>) =>
|
2018-08-08 08:44:12 -06:00
|
|
|
// tslint:disable-next-line:no-any
|
2018-03-19 14:01:05 -06:00
|
|
|
(action: any) => {
|
2018-03-24 08:32:57 -06:00
|
|
|
const fbos = getVersionFromState(store.getState());
|
2020-01-03 13:04:45 -07:00
|
|
|
window.Rollbar?.configure({ payload: { fbos } });
|
2018-03-19 14:01:05 -06:00
|
|
|
return dispatch(action);
|
|
|
|
};
|
2018-03-19 12:39:17 -06:00
|
|
|
|
2018-03-19 13:06:31 -06:00
|
|
|
const env: EnvName = "*";
|
2018-03-19 12:39:17 -06:00
|
|
|
|
2018-03-19 13:06:31 -06:00
|
|
|
export const versionChangeMiddleware = { env, fn };
|