mirror of
				https://github.com/zoriya/Kyoo.git
				synced 2025-11-03 19:17:16 -05: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 getCurrentToken = () => {
 | 
			
		||||
	const account = getCurrentAccount();
 | 
			
		||||
	return account ? `${account.token.token_type} ${account.token.access_token}` : null;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const useToken = () => {
 | 
			
		||||
	const account = getCurrentAccount();
 | 
			
		||||
	const refresher = useRef<NodeJS.Timeout | null>(null);
 | 
			
		||||
 | 
			
		||||
@ -25,6 +25,7 @@ import { Blurhash } from "react-native-blurhash";
 | 
			
		||||
import { percent, useYoshiki } from "yoshiki/native";
 | 
			
		||||
import { Props, ImageLayout } from "./base-image";
 | 
			
		||||
import { Skeleton } from "../skeleton";
 | 
			
		||||
import { getCurrentToken } from "@kyoo/models";
 | 
			
		||||
 | 
			
		||||
export const Image = ({
 | 
			
		||||
	src,
 | 
			
		||||
@ -60,6 +61,7 @@ export const Image = ({
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	quality ??= "high";
 | 
			
		||||
	const token = getCurrentToken();
 | 
			
		||||
	return (
 | 
			
		||||
		<View {...css([layout, border], props)}>
 | 
			
		||||
			{state !== "finished" && (
 | 
			
		||||
@ -72,6 +74,11 @@ export const Image = ({
 | 
			
		||||
			<FastImage
 | 
			
		||||
				source={{
 | 
			
		||||
					uri: src[quality],
 | 
			
		||||
					headers: token
 | 
			
		||||
						? {
 | 
			
		||||
								Authorization: token,
 | 
			
		||||
							}
 | 
			
		||||
						: {},
 | 
			
		||||
					priority: FastImage.priority[quality === "medium" ? "normal" : quality],
 | 
			
		||||
				}}
 | 
			
		||||
				accessibilityLabel={alt}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user