feat: add shortcut detail page

This commit is contained in:
Steven
2023-08-01 23:19:17 +08:00
parent 23d84299e4
commit 74200f468c
6 changed files with 296 additions and 49 deletions

View File

@ -29,13 +29,25 @@ const shortcutService = {
},
getShortcutById: (id: ShortcutId) => {
for (const s of shortcutService.getState().shortcutList) {
if (s.id === id) {
return s;
for (const shortcut of shortcutService.getState().shortcutList) {
if (shortcut.id === id) {
return shortcut;
}
}
return null;
},
getOrFetchShortcutById: async (id: ShortcutId) => {
for (const shortcut of shortcutService.getState().shortcutList) {
if (shortcut.id === id) {
return shortcut;
}
}
return null;
const data = (await api.getShortcutById(id)).data;
const shortcut = convertResponseModelShortcut(data);
store.dispatch(createShortcut(shortcut));
return shortcut;
},
createShortcut: async (shortcutCreate: ShortcutCreate) => {