@bbki.ng/site 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @bbki.ng/site
2
2
 
3
+ ## 1.2.1
4
+
3
5
  ## 1.2.0
4
6
 
5
7
  ## 1.1.28
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/site",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "code behind bbki.ng",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -25,7 +25,7 @@
25
25
  "react-hotkeys-hook": "^3.4.3",
26
26
  "react-router-dom": "6",
27
27
  "sonner": "1.4.0",
28
- "swr": "^2.2.1"
28
+ "swr": "^2.2.5"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@bbki.ng/stylebase": "workspace:0.1.0",
@@ -18,7 +18,7 @@ export const useFile2Post = (): fileReader => {
18
18
 
19
19
  setIsLoading(true);
20
20
 
21
- post({ title, content })
21
+ post(title, content)
22
22
  .then((r) => {
23
23
  console.log(r);
24
24
  })
@@ -1,7 +1,6 @@
1
1
  import { useCallback } from "react";
2
2
  import { API } from "@/constants/routes";
3
3
  import { useAuthedFetcher } from "@/hooks/use_authed_fetcher";
4
- import useSWRMutation from "swr/mutation";
5
4
 
6
5
  export const usePost = () => {
7
6
  const authedFetcher = useAuthedFetcher();
@@ -19,7 +18,9 @@ export const usePost = () => {
19
18
  [authedFetcher]
20
19
  );
21
20
 
22
- const { trigger } = useSWRMutation(API.POST, req);
23
-
24
- return trigger;
21
+ return useCallback(
22
+ (title: string, content: string) =>
23
+ req(API.POSTS, { arg: { title, content } }),
24
+ [req]
25
+ );
25
26
  };
@@ -26,7 +26,9 @@ export const useProjects = (name: string = "", suspense?: boolean) => {
26
26
  if (!n) {
27
27
  return;
28
28
  }
29
- return cache.get("projects")?.find((p: { name: string }) => p.name === n);
29
+ return cache
30
+ .get("projects")
31
+ ?.data.find((p: { name: string }) => p.name === n);
30
32
  };
31
33
 
32
34
  const refresh = useCallback(() => {
@@ -2,7 +2,9 @@ import { Photo } from "@/types/photo";
2
2
  import { ossProcessType } from "@/types/oss";
3
3
  import { API_ENDPOINT, OSS_ADDRESS } from "@/constants/routes";
4
4
  import { DEFAULT_DELAY } from "@/constants";
5
- import useSWR, { Fetcher } from "swr";
5
+ import useSWR from "swr";
6
+
7
+ type Fetcher = (resource: string, init?: any) => Promise<any>;
6
8
 
7
9
  export const floatNumberToPercentageString = (num: number): string => {
8
10
  return `${num * 100}%`;
@@ -96,7 +98,7 @@ export const withToken =
96
98
  };
97
99
 
98
100
  export const withBBApi =
99
- (fetcher: Fetcher<Promise<void>>) =>
101
+ (fetcher: Fetcher) =>
100
102
  (apiEndPoint = API_ENDPOINT): Fetcher =>
101
103
  async (resource: string, init: RequestInit = {}) =>
102
104
  fetcher(`${apiEndPoint}/${resource}`, { ...init, mode: "cors" });