1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-08-04 02:15:18 +02:00

Fixed notification emitting

This commit is contained in:
Paweł Malak 2021-11-09 15:04:13 +01:00
parent 969bdb7d24
commit 0d5a4c418e
3 changed files with 76 additions and 45 deletions

View file

@ -11,7 +11,6 @@ import {
UpdateAppAction,
} from '../actions/app';
import axios from 'axios';
import { createNotification } from '.';
export const getApps =
() => async (dispatch: Dispatch<GetAppsAction<undefined | App[]>>) => {
@ -44,9 +43,12 @@ export const pinApp =
? 'unpinned from Homescreen'
: 'pinned to Homescreen';
createNotification({
title: 'Success',
message: `App ${name} ${status}`,
dispatch<any>({
type: ActionType.createNotification,
payload: {
title: 'Success',
message: `App ${name} ${status}`,
},
});
dispatch({
@ -63,9 +65,12 @@ export const addApp =
try {
const res = await axios.post<ApiResponse<App>>('/api/apps', formData);
createNotification({
title: 'Success',
message: `App added`,
dispatch<any>({
type: ActionType.createNotification,
payload: {
title: 'Success',
message: `App added`,
},
});
await dispatch({
@ -74,8 +79,7 @@ export const addApp =
});
// Sort apps
// dispatch<any>(sortApps());
sortApps();
dispatch<any>(sortApps());
} catch (err) {
console.log(err);
}
@ -86,9 +90,12 @@ export const deleteApp =
try {
await axios.delete<ApiResponse<{}>>(`/api/apps/${id}`);
createNotification({
title: 'Success',
message: 'App deleted',
dispatch<any>({
type: ActionType.createNotification,
payload: {
title: 'Success',
message: 'App deleted',
},
});
dispatch({
@ -109,9 +116,12 @@ export const updateApp =
formData
);
createNotification({
title: 'Success',
message: `App updated`,
dispatch<any>({
type: ActionType.createNotification,
payload: {
title: 'Success',
message: `App updated`,
},
});
await dispatch({