Reload bookmarks after import.
This commit is contained in:
parent
60a8ead973
commit
96b1b8a0e3
3 changed files with 20 additions and 4 deletions
|
@ -132,7 +132,7 @@ export const importBookmark =
|
|||
type: ActionType.createNotification,
|
||||
payload: {
|
||||
title: 'Success',
|
||||
message: `Bookmark file uploaded.`,
|
||||
message: `Bookmark file imported.`,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -140,6 +140,20 @@ export const importBookmark =
|
|||
type: ActionType.importBookmark,
|
||||
payload: res.data.data,
|
||||
});
|
||||
|
||||
// Fetch bookmarks after import.
|
||||
try {
|
||||
const res = await axios.get<ApiResponse<Category[]>>('/api/categories', {
|
||||
headers: applyAuth(),
|
||||
});
|
||||
|
||||
dispatch<any>({
|
||||
type: ActionType.getCategoriesSuccess,
|
||||
payload: res.data.data,
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
|
|
@ -19,4 +19,4 @@ const importBookmark = asyncWrapper(async (req, res, next) => {
|
|||
}
|
||||
});
|
||||
|
||||
module.exports = importBookmark;
|
||||
module.exports = importBookmark;
|
|
@ -14,6 +14,8 @@ const {
|
|||
importBookmark,
|
||||
} = require('../controllers/bookmarks');
|
||||
|
||||
const { getAllCategories } = require('../controllers/categories');
|
||||
|
||||
router
|
||||
.route('/')
|
||||
.post(auth, requireAuth, upload.icon, createBookmark)
|
||||
|
@ -25,9 +27,9 @@ router
|
|||
.put(auth, requireAuth, upload.icon, updateBookmark)
|
||||
.delete(auth, requireAuth, deleteBookmark);
|
||||
|
||||
router
|
||||
router
|
||||
.route('/import')
|
||||
.post(auth, requireAuth, upload.bookmark, importBookmark, getAllBookmarks)
|
||||
.post(auth, requireAuth, upload.bookmark, importBookmark, getAllCategories);
|
||||
|
||||
router.route('/0/reorder').put(auth, requireAuth, reorderBookmarks);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue