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

View file

@ -1,6 +1,5 @@
import axios from 'axios'; import axios from 'axios';
import { Dispatch } from 'redux'; import { Dispatch } from 'redux';
import { createNotification } from '.';
import { import {
ApiResponse, ApiResponse,
Bookmark, Bookmark,
@ -51,9 +50,12 @@ export const addCategory =
formData formData
); );
createNotification({ dispatch<any>({
title: 'Success', type: ActionType.createNotification,
message: `Category ${formData.name} created`, payload: {
title: 'Success',
message: `Category ${formData.name} created`,
},
}); });
dispatch({ dispatch({
@ -61,8 +63,7 @@ export const addCategory =
payload: res.data.data, payload: res.data.data,
}); });
// dispatch<any>(sortCategories()); dispatch<any>(sortCategories());
sortCategories();
} catch (err) { } catch (err) {
console.log(err); console.log(err);
} }
@ -77,9 +78,12 @@ export const addBookmark =
formData formData
); );
createNotification({ dispatch<any>({
title: 'Success', type: ActionType.createNotification,
message: `Bookmark created`, payload: {
title: 'Success',
message: `Bookmark created`,
},
}); });
dispatch({ dispatch({
@ -104,9 +108,12 @@ export const pinCategory =
? 'unpinned from Homescreen' ? 'unpinned from Homescreen'
: 'pinned to Homescreen'; : 'pinned to Homescreen';
createNotification({ dispatch<any>({
title: 'Success', type: ActionType.createNotification,
message: `Category ${name} ${status}`, payload: {
title: 'Success',
message: `Category ${name} ${status}`,
},
}); });
dispatch({ dispatch({
@ -123,9 +130,12 @@ export const deleteCategory =
try { try {
await axios.delete<ApiResponse<{}>>(`/api/categories/${id}`); await axios.delete<ApiResponse<{}>>(`/api/categories/${id}`);
createNotification({ dispatch<any>({
title: 'Success', type: ActionType.createNotification,
message: `Category deleted`, payload: {
title: 'Success',
message: `Category deleted`,
},
}); });
dispatch({ dispatch({
@ -145,9 +155,13 @@ export const updateCategory =
`/api/categories/${id}`, `/api/categories/${id}`,
formData formData
); );
createNotification({
title: 'Success', dispatch<any>({
message: `Category ${formData.name} updated`, type: ActionType.createNotification,
payload: {
title: 'Success',
message: `Category ${formData.name} updated`,
},
}); });
dispatch({ dispatch({
@ -155,8 +169,7 @@ export const updateCategory =
payload: res.data.data, payload: res.data.data,
}); });
// dispatch<any>(sortCategories()); dispatch<any>(sortCategories());
sortCategories();
} catch (err) { } catch (err) {
console.log(err); console.log(err);
} }
@ -168,9 +181,12 @@ export const deleteBookmark =
try { try {
await axios.delete<ApiResponse<{}>>(`/api/bookmarks/${bookmarkId}`); await axios.delete<ApiResponse<{}>>(`/api/bookmarks/${bookmarkId}`);
createNotification({ dispatch<any>({
title: 'Success', type: ActionType.createNotification,
message: 'Bookmark deleted', payload: {
title: 'Success',
message: 'Bookmark deleted',
},
}); });
dispatch({ dispatch({
@ -205,9 +221,12 @@ export const updateBookmark =
formData formData
); );
createNotification({ dispatch<any>({
title: 'Success', type: ActionType.createNotification,
message: `Bookmark updated`, payload: {
title: 'Success',
message: `Bookmark updated`,
},
}); });
// Check if category was changed // Check if category was changed

View file

@ -18,7 +18,6 @@ import {
} from '../../interfaces'; } from '../../interfaces';
import { ActionType } from '../action-types'; import { ActionType } from '../action-types';
import { storeUIConfig } from '../../utility'; import { storeUIConfig } from '../../utility';
import { createNotification } from '.';
export const getConfig = () => async (dispatch: Dispatch<GetConfigAction>) => { export const getConfig = () => async (dispatch: Dispatch<GetConfigAction>) => {
try { try {
@ -53,9 +52,12 @@ export const updateConfig =
try { try {
const res = await axios.put<ApiResponse<Config>>('/api/config', formData); const res = await axios.put<ApiResponse<Config>>('/api/config', formData);
createNotification({ dispatch<any>({
title: 'Success', type: ActionType.createNotification,
message: 'Settings updated', payload: {
title: 'Success',
message: 'Settings updated',
},
}); });
dispatch({ dispatch({