mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-19 05:53:47 +00:00
Do not inject appupdated state or actions
This commit is contained in:
@@ -14,11 +14,7 @@ import { useLoadRemoteServers } from '../servers/reducers/remoteServers';
|
||||
import { useSettings } from '../settings/reducers/settings';
|
||||
import { Settings } from '../settings/Settings';
|
||||
import { forceUpdate } from '../utils/helpers/sw';
|
||||
|
||||
export type AppProps = {
|
||||
resetAppUpdate: () => void;
|
||||
appUpdated: boolean;
|
||||
};
|
||||
import { useAppUpdated } from './reducers/appUpdates';
|
||||
|
||||
type AppDeps = {
|
||||
Home: FC;
|
||||
@@ -27,7 +23,8 @@ type AppDeps = {
|
||||
ManageServers: FC;
|
||||
};
|
||||
|
||||
const App: FCWithDeps<AppProps, AppDeps> = ({ appUpdated, resetAppUpdate }) => {
|
||||
const App: FCWithDeps<any, AppDeps> = () => {
|
||||
const { appUpdated, resetAppUpdate } = useAppUpdated();
|
||||
const {
|
||||
Home,
|
||||
ShlinkWebComponentContainer,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
import { useCallback } from 'react';
|
||||
import { useAppDispatch, useAppSelector } from '../../store';
|
||||
|
||||
const { actions, reducer } = createSlice({
|
||||
name: 'shlink/appUpdates',
|
||||
@@ -12,3 +14,12 @@ const { actions, reducer } = createSlice({
|
||||
export const { appUpdateAvailable, resetAppUpdate } = actions;
|
||||
|
||||
export const appUpdatesReducer = reducer;
|
||||
|
||||
export const useAppUpdated = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
const appUpdateAvailable = useCallback(() => dispatch(actions.appUpdateAvailable()), [dispatch]);
|
||||
const resetAppUpdate = useCallback(() => dispatch(actions.resetAppUpdate()), [dispatch]);
|
||||
const appUpdated = useAppSelector((state) => state.appUpdated);
|
||||
|
||||
return { appUpdated, appUpdateAvailable, resetAppUpdate };
|
||||
};
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
import type Bottle from 'bottlejs';
|
||||
import type { ConnectDecorator } from '../../container/types';
|
||||
import { AppFactory } from '../App';
|
||||
import { appUpdateAvailable, resetAppUpdate } from '../reducers/appUpdates';
|
||||
|
||||
export const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
|
||||
export const provideServices = (bottle: Bottle) => {
|
||||
// Components
|
||||
bottle.factory('App', AppFactory);
|
||||
bottle.decorator('App', connect(['appUpdated'], ['resetAppUpdate']));
|
||||
|
||||
// Actions
|
||||
bottle.serviceFactory('appUpdateAvailable', () => appUpdateAvailable);
|
||||
bottle.serviceFactory('resetAppUpdate', () => resetAppUpdate);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user