mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-06 21:22:36 +00:00
fix: update shortcut
This commit is contained in:
@ -28,11 +28,11 @@ interface State {
|
||||
const ShortcutDetail = () => {
|
||||
const { t } = useTranslation();
|
||||
const params = useParams();
|
||||
const shortcutName = params["*"] || "";
|
||||
const shortcutId = Number(params["shortcutId"]);
|
||||
const navigateTo = useNavigateTo();
|
||||
const shortcutStore = useShortcutStore();
|
||||
const userStore = useUserStore();
|
||||
const shortcut = shortcutStore.getShortcutByName(shortcutName);
|
||||
const shortcut = shortcutStore.getShortcutById(shortcutId);
|
||||
const currentUser = useUserStore().getCurrentUser();
|
||||
const [state, setState] = useState<State>({
|
||||
showEditDrawer: false,
|
||||
@ -46,11 +46,11 @@ const ShortcutDetail = () => {
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const shortcut = await shortcutStore.getOrFetchShortcutByName(shortcutName);
|
||||
const shortcut = await shortcutStore.getOrFetchShortcutById(shortcutId);
|
||||
await userStore.getOrFetchUserById(shortcut.creatorId);
|
||||
loadingState.setFinish();
|
||||
})();
|
||||
}, [shortcutName]);
|
||||
}, [shortcutId]);
|
||||
|
||||
if (loadingState.isLoading) {
|
||||
return null;
|
||||
@ -67,7 +67,7 @@ const ShortcutDetail = () => {
|
||||
content: `Are you sure to delete shortcut \`${shortcut.name}\`? You cannot undo this action.`,
|
||||
style: "danger",
|
||||
onConfirm: async () => {
|
||||
await shortcutStore.deleteShortcut(shortcut.name);
|
||||
await shortcutStore.deleteShortcut(shortcut.id);
|
||||
navigateTo("/", {
|
||||
replace: true,
|
||||
});
|
||||
@ -198,7 +198,7 @@ const ShortcutDetail = () => {
|
||||
<Icon.BarChart2 className="w-6 h-auto mr-1" />
|
||||
{t("analytics.self")}
|
||||
</h3>
|
||||
<AnalyticsView className="mt-4 w-full grid grid-cols-1 sm:grid-cols-2 gap-2 sm:gap-4" shortcutName={shortcut.name} />
|
||||
<AnalyticsView className="mt-4 w-full grid grid-cols-1 sm:grid-cols-2 gap-2 sm:gap-4" shortcutId={shortcut.id} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -206,7 +206,7 @@ const ShortcutDetail = () => {
|
||||
|
||||
{state.showEditDrawer && (
|
||||
<CreateShortcutDrawer
|
||||
shortcutName={shortcut.name}
|
||||
shortcutId={shortcut.id}
|
||||
onClose={() =>
|
||||
setState({
|
||||
...state,
|
||||
|
Reference in New Issue
Block a user