mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 04:04:21 -04:00
Fix authorization tokens usage on android images
This commit is contained in:
parent
0008aa95c2
commit
e16fdc1036
@ -138,6 +138,11 @@ export const getTokenWJ = async (
|
|||||||
|
|
||||||
export const getToken = async (): Promise<string | null> => (await getTokenWJ())[0];
|
export const getToken = async (): Promise<string | null> => (await getTokenWJ())[0];
|
||||||
|
|
||||||
|
export const getCurrentToken = () => {
|
||||||
|
const account = getCurrentAccount();
|
||||||
|
return account ? `${account.token.token_type} ${account.token.access_token}` : null;
|
||||||
|
};
|
||||||
|
|
||||||
export const useToken = () => {
|
export const useToken = () => {
|
||||||
const account = getCurrentAccount();
|
const account = getCurrentAccount();
|
||||||
const refresher = useRef<NodeJS.Timeout | null>(null);
|
const refresher = useRef<NodeJS.Timeout | null>(null);
|
||||||
|
@ -25,6 +25,7 @@ import { Blurhash } from "react-native-blurhash";
|
|||||||
import { percent, useYoshiki } from "yoshiki/native";
|
import { percent, useYoshiki } from "yoshiki/native";
|
||||||
import { Props, ImageLayout } from "./base-image";
|
import { Props, ImageLayout } from "./base-image";
|
||||||
import { Skeleton } from "../skeleton";
|
import { Skeleton } from "../skeleton";
|
||||||
|
import { getCurrentToken } from "@kyoo/models";
|
||||||
|
|
||||||
export const Image = ({
|
export const Image = ({
|
||||||
src,
|
src,
|
||||||
@ -60,6 +61,7 @@ export const Image = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
quality ??= "high";
|
quality ??= "high";
|
||||||
|
const token = getCurrentToken();
|
||||||
return (
|
return (
|
||||||
<View {...css([layout, border], props)}>
|
<View {...css([layout, border], props)}>
|
||||||
{state !== "finished" && (
|
{state !== "finished" && (
|
||||||
@ -72,6 +74,11 @@ export const Image = ({
|
|||||||
<FastImage
|
<FastImage
|
||||||
source={{
|
source={{
|
||||||
uri: src[quality],
|
uri: src[quality],
|
||||||
|
headers: token
|
||||||
|
? {
|
||||||
|
Authorization: token,
|
||||||
|
}
|
||||||
|
: {},
|
||||||
priority: FastImage.priority[quality === "medium" ? "normal" : quality],
|
priority: FastImage.priority[quality === "medium" ? "normal" : quality],
|
||||||
}}
|
}}
|
||||||
accessibilityLabel={alt}
|
accessibilityLabel={alt}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user