-
-
Notifications
You must be signed in to change notification settings - Fork 771
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Innei <i@innei.in>
- Loading branch information
Showing
14 changed files
with
213 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
import { cache } from 'react' | ||
import { headers } from 'next/dist/client/components/headers' | ||
|
||
import { REQUEST_QUERY } from '~/constants/system' | ||
import { attachServerFetch, getAuthFromCookie } from '~/lib/attach-fetch' | ||
import { getQueryClient } from '~/lib/query-client.server' | ||
import { requestErrorHandler } from '~/lib/request.server' | ||
import { queries } from '~/queries/definition' | ||
|
||
export const getData = cache(async (params: { id: string }) => { | ||
attachServerFetch() | ||
export const getData = cache( | ||
async (params: { | ||
id: string | ||
|
||
const header = headers() | ||
const searchParams = new URLSearchParams(header.get(REQUEST_QUERY) || '') | ||
const id = params.id | ||
const token = searchParams.get('token') | ||
const query = queries.note.byNid( | ||
id, | ||
searchParams.get('password') || undefined, | ||
token ? `${token}` : undefined, | ||
) | ||
token?: string | ||
password?: string | ||
}) => { | ||
attachServerFetch() | ||
|
||
const data = await getQueryClient() | ||
.fetchQuery({ | ||
...query, | ||
staleTime: getAuthFromCookie() ? 0 : undefined, | ||
}) | ||
.catch(requestErrorHandler) | ||
return data | ||
}) | ||
const { id, password, token } = params | ||
|
||
const query = queries.note.byNid( | ||
id, | ||
password, | ||
token ? `${token}` : undefined, | ||
) | ||
|
||
const data = await getQueryClient() | ||
.fetchQuery({ | ||
...query, | ||
staleTime: getAuthFromCookie() ? 0 : undefined, | ||
}) | ||
.catch(requestErrorHandler) | ||
return data | ||
}, | ||
) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.