Skip to content

Commit

Permalink
fix nil pointer dereference, fix mal auth
Browse files Browse the repository at this point in the history
  • Loading branch information
5rahim committed Apr 27, 2024
1 parent a007200 commit 6f20645
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions internal/library/anime/episode.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func NewEpisodeMetadata(
md.Summary = epMetadata.Summary
md.Overview = epMetadata.Overview
} else {
md.Image = *media.GetBannerImage()
md.Image = media.GetBannerImageSafe()
}

return md
Expand Down Expand Up @@ -332,7 +332,7 @@ func NewSimpleMediaEntryEpisode(opts *NewSimpleMediaEntryEpisodeOptions) *MediaE
}
}

entryEp.EpisodeMetadata.Image = *opts.Media.GetCoverImage().GetLarge()
entryEp.EpisodeMetadata.Image = opts.Media.GetCoverImageSafe()

}

Expand Down
3 changes: 2 additions & 1 deletion seanime-web/src/api/hooks/mal.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import { MalAuthResponse } from "@/api/generated/types"
import { useQueryClient } from "@tanstack/react-query"
import { toast } from "sonner"

export function useMALAuth(enabled: boolean) {
export function useMALAuth(variables: Partial<MALAuth_Variables>, enabled: boolean) {
return useServerQuery<MalAuthResponse, MALAuth_Variables>({
endpoint: API_ENDPOINTS.MAL.MALAuth.endpoint,
method: API_ENDPOINTS.MAL.MALAuth.methods[0],
queryKey: [API_ENDPOINTS.MAL.MALAuth.key],
data: variables as MALAuth_Variables,
enabled: enabled,
})
}
Expand Down
12 changes: 8 additions & 4 deletions seanime-web/src/app/(main)/mal/auth/callback/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ export default function Page() {

const { code, state, challenge } = React.useMemo(() => {
const urlParams = new URLSearchParams(window?.location?.search || "")
const code = urlParams.get("code")
const state = urlParams.get("state")
const challenge = sessionStorage.getItem("mal-" + state)
const code = urlParams.get("code") || undefined
const state = urlParams.get("state") || undefined
const challenge = sessionStorage.getItem("mal-" + state) || undefined
return { code, state, challenge }
}, [])

const { data, isError } = useMALAuth(!!code && !!state && !!challenge)
const { data, isError } = useMALAuth({
code: code,
state: state,
code_verifier: challenge,
}, !!code && !!state && !!challenge)

React.useEffect(() => {
if (!!data?.access_token) {
Expand Down

0 comments on commit 6f20645

Please sign in to comment.