]> Untitled Git - lemmy-ui.git/blobdiff - src/shared/routes.ts
Make pages use query params instead of route params where appropriate (#977)
[lemmy-ui.git] / src / shared / routes.ts
index b4404a7983a32b56a749649b39af6f882d2ef7a3..875ba5020487253c828fb813b773355c5de63806 100644 (file)
@@ -1,4 +1,3 @@
-import { Inferno } from "inferno";
 import { IRouteProps } from "inferno-router/dist/Route";
 import { Communities } from "./components/community/communities";
 import { Community } from "./components/community/community";
@@ -26,21 +25,15 @@ import { InitialFetchRequest } from "./interfaces";
 
 interface IRoutePropsWithFetch extends IRouteProps {
   // TODO Make sure this one is good.
-  component: Inferno.ComponentClass;
   fetchInitialData?(req: InitialFetchRequest): Promise<any>[];
 }
 
 export const routes: IRoutePropsWithFetch[] = [
   {
     path: `/`,
-    exact: true,
     component: Home,
-    fetchInitialData: req => Home.fetchInitialData(req),
-  },
-  {
-    path: `/home/data_type/:data_type/listing_type/:listing_type/sort/:sort/page/:page`,
-    component: Home,
-    fetchInitialData: req => Home.fetchInitialData(req),
+    fetchInitialData: Home.fetchInitialData,
+    exact: true,
   },
   {
     path: `/login`,
@@ -53,101 +46,81 @@ export const routes: IRoutePropsWithFetch[] = [
   {
     path: `/create_post`,
     component: CreatePost,
-    fetchInitialData: req => CreatePost.fetchInitialData(req),
+    fetchInitialData: CreatePost.fetchInitialData,
   },
   {
     path: `/create_community`,
     component: CreateCommunity,
   },
   {
-    path: `/create_private_message/recipient/:recipient_id`,
+    path: `/create_private_message/:recipient_id`,
     component: CreatePrivateMessage,
-    fetchInitialData: req => CreatePrivateMessage.fetchInitialData(req),
-  },
-  {
-    path: `/communities/listing_type/:listing_type/page/:page`,
-    component: Communities,
-    fetchInitialData: req => Communities.fetchInitialData(req),
+    fetchInitialData: CreatePrivateMessage.fetchInitialData,
   },
   {
     path: `/communities`,
     component: Communities,
-    fetchInitialData: req => Communities.fetchInitialData(req),
+    fetchInitialData: Communities.fetchInitialData,
   },
   {
     path: `/post/:post_id`,
     component: Post,
-    fetchInitialData: req => Post.fetchInitialData(req),
+    fetchInitialData: Post.fetchInitialData,
   },
   {
     path: `/comment/:comment_id`,
     component: Post,
-    fetchInitialData: req => Post.fetchInitialData(req),
-  },
-  {
-    path: `/c/:name/data_type/:data_type/sort/:sort/page/:page`,
-    component: Community,
-    fetchInitialData: req => Community.fetchInitialData(req),
+    fetchInitialData: Post.fetchInitialData,
   },
   {
     path: `/c/:name`,
     component: Community,
-    fetchInitialData: req => Community.fetchInitialData(req),
-  },
-  {
-    path: `/u/:username/view/:view/sort/:sort/page/:page`,
-    component: Profile,
-    fetchInitialData: req => Profile.fetchInitialData(req),
+    fetchInitialData: Community.fetchInitialData,
   },
   {
     path: `/u/:username`,
     component: Profile,
-    fetchInitialData: req => Profile.fetchInitialData(req),
+    fetchInitialData: Profile.fetchInitialData,
   },
   {
     path: `/inbox`,
     component: Inbox,
-    fetchInitialData: req => Inbox.fetchInitialData(req),
+    fetchInitialData: Inbox.fetchInitialData,
   },
   {
     path: `/settings`,
     component: Settings,
   },
   {
-    path: `/modlog/community/:community_id`,
+    path: `/modlog`,
     component: Modlog,
-    fetchInitialData: req => Modlog.fetchInitialData(req),
+    fetchInitialData: Modlog.fetchInitialData,
   },
   {
-    path: `/modlog`,
+    path: `/modlog/:communityId`,
     component: Modlog,
-    fetchInitialData: req => Modlog.fetchInitialData(req),
+    fetchInitialData: Modlog.fetchInitialData,
   },
   { path: `/setup`, component: Setup },
   {
     path: `/admin`,
     component: AdminSettings,
-    fetchInitialData: req => AdminSettings.fetchInitialData(req),
+    fetchInitialData: AdminSettings.fetchInitialData,
   },
   {
     path: `/reports`,
     component: Reports,
-    fetchInitialData: req => Reports.fetchInitialData(req),
+    fetchInitialData: Reports.fetchInitialData,
   },
   {
     path: `/registration_applications`,
     component: RegistrationApplications,
-    fetchInitialData: req => RegistrationApplications.fetchInitialData(req),
-  },
-  {
-    path: `/search/q/:q/type/:type/sort/:sort/listing_type/:listing_type/community_id/:community_id/creator_id/:creator_id/page/:page`,
-    component: Search,
-    fetchInitialData: req => Search.fetchInitialData(req),
+    fetchInitialData: RegistrationApplications.fetchInitialData,
   },
   {
     path: `/search`,
     component: Search,
-    fetchInitialData: req => Search.fetchInitialData(req),
+    fetchInitialData: Search.fetchInitialData,
   },
   {
     path: `/password_change/:token`,