mirror of
https://github.com/movie-web/movie-web.git
synced 2024-12-29 06:21:51 +01:00
Fix styling bugs, fix player not switching source after error, fix allowed state in extension, add ip locked sourced for extension
Co-authored-by: Jip Frijlink <JipFr@users.noreply.github.com>
This commit is contained in:
parent
d32ef6ed9a
commit
3704dfba10
@ -37,7 +37,7 @@ export async function sendExtensionRequest<T>(
|
|||||||
ops: Omit<MessagesMetadata["makeRequest"]["req"], "requestDomain">,
|
ops: Omit<MessagesMetadata["makeRequest"]["req"], "requestDomain">,
|
||||||
): Promise<ExtensionMakeRequestResponse<T> | null> {
|
): Promise<ExtensionMakeRequestResponse<T> | null> {
|
||||||
return sendMessage("makeRequest", {
|
return sendMessage("makeRequest", {
|
||||||
requestDomain: window.location.origin,
|
requestDomain: window.location.origin, // TODO unsafe
|
||||||
...ops,
|
...ops,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -54,13 +54,16 @@ export async function setDomainRule(
|
|||||||
export async function extensionInfo(): Promise<
|
export async function extensionInfo(): Promise<
|
||||||
MessagesMetadata["hello"]["res"] | null
|
MessagesMetadata["hello"]["res"] | null
|
||||||
> {
|
> {
|
||||||
return sendMessage(
|
const message = await sendMessage(
|
||||||
"hello",
|
"hello",
|
||||||
{
|
{
|
||||||
requestDomain: window.location.origin,
|
requestDomain: window.location.origin,
|
||||||
},
|
},
|
||||||
300,
|
300,
|
||||||
);
|
);
|
||||||
|
if (!message?.success) return null;
|
||||||
|
if (!message.allowed) return null;
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isExtensionActiveCached(): boolean {
|
export function isExtensionActiveCached(): boolean {
|
||||||
|
@ -13,6 +13,7 @@ export type ExtensionBaseResponse<T = object> =
|
|||||||
|
|
||||||
export type ExtensionHelloResponse = ExtensionBaseResponse<{
|
export type ExtensionHelloResponse = ExtensionBaseResponse<{
|
||||||
version: string;
|
version: string;
|
||||||
|
allowed: boolean;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
export interface ExtensionMakeRequest extends ExtensionBaseRequest {
|
export interface ExtensionMakeRequest extends ExtensionBaseRequest {
|
||||||
@ -38,10 +39,6 @@ export interface ExtensionPrepareStreamRequest extends ExtensionBaseRequest {
|
|||||||
responseHeaders?: Record<string, string>;
|
responseHeaders?: Record<string, string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ExtensionHelloReply {
|
|
||||||
version: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MmMetadata {
|
export interface MmMetadata {
|
||||||
hello: {
|
hello: {
|
||||||
req: ExtensionBaseRequest;
|
req: ExtensionBaseRequest;
|
||||||
|
@ -15,6 +15,7 @@ export function getProviders() {
|
|||||||
return makeProviders({
|
return makeProviders({
|
||||||
fetcher: makeExtensionFetcher(),
|
fetcher: makeExtensionFetcher(),
|
||||||
target: targets.BROWSER_EXTENSION,
|
target: targets.BROWSER_EXTENSION,
|
||||||
|
consistentIpForRequests: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ export function SourceSelectionView({
|
|||||||
<Menu.BackLink onClick={() => router.navigate("/")}>
|
<Menu.BackLink onClick={() => router.navigate("/")}>
|
||||||
{t("player.menus.sources.title")}
|
{t("player.menus.sources.title")}
|
||||||
</Menu.BackLink>
|
</Menu.BackLink>
|
||||||
<Menu.Section>
|
<Menu.Section className="pb-4">
|
||||||
{sources.map((v) => (
|
{sources.map((v) => (
|
||||||
<SelectableLink
|
<SelectableLink
|
||||||
key={v.id}
|
key={v.id}
|
||||||
|
@ -116,6 +116,7 @@ export const createSourceSlice: MakeSlice<SourceSlice> = (set, get) => ({
|
|||||||
},
|
},
|
||||||
setSourceId(id) {
|
setSourceId(id) {
|
||||||
set((s) => {
|
set((s) => {
|
||||||
|
s.status = playerStatus.PLAYING;
|
||||||
s.sourceId = id;
|
s.sourceId = id;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -153,6 +154,8 @@ export const createSourceSlice: MakeSlice<SourceSlice> = (set, get) => ({
|
|||||||
s.qualities = qualities as SourceQuality[];
|
s.qualities = qualities as SourceQuality[];
|
||||||
s.currentQuality = loadableStream.quality;
|
s.currentQuality = loadableStream.quality;
|
||||||
s.captionList = captions;
|
s.captionList = captions;
|
||||||
|
s.interface.error = undefined;
|
||||||
|
s.status = playerStatus.PLAYING;
|
||||||
});
|
});
|
||||||
const store = get();
|
const store = get();
|
||||||
store.redisplaySource(startAt);
|
store.redisplaySource(startAt);
|
||||||
@ -166,7 +169,10 @@ export const createSourceSlice: MakeSlice<SourceSlice> = (set, get) => ({
|
|||||||
automaticQuality: qualityPreferences.quality.automaticQuality,
|
automaticQuality: qualityPreferences.quality.automaticQuality,
|
||||||
lastChosenQuality: quality,
|
lastChosenQuality: quality,
|
||||||
});
|
});
|
||||||
|
set((s) => {
|
||||||
|
s.interface.error = undefined;
|
||||||
|
s.status = playerStatus.PLAYING;
|
||||||
|
});
|
||||||
store.display?.load({
|
store.display?.load({
|
||||||
source: loadableStream.stream,
|
source: loadableStream.stream,
|
||||||
startAt,
|
startAt,
|
||||||
@ -182,6 +188,8 @@ export const createSourceSlice: MakeSlice<SourceSlice> = (set, get) => ({
|
|||||||
if (!selectedQuality) return;
|
if (!selectedQuality) return;
|
||||||
set((s) => {
|
set((s) => {
|
||||||
s.currentQuality = quality;
|
s.currentQuality = quality;
|
||||||
|
s.status = playerStatus.PLAYING;
|
||||||
|
s.interface.error = undefined;
|
||||||
});
|
});
|
||||||
store.display?.load({
|
store.display?.load({
|
||||||
source: selectedQuality,
|
source: selectedQuality,
|
||||||
|
@ -86,7 +86,7 @@ function populateLanguageCode(language: string): string {
|
|||||||
* @returns pretty format for language, null if it no info can be found for language
|
* @returns pretty format for language, null if it no info can be found for language
|
||||||
*/
|
*/
|
||||||
export function getPrettyLanguageNameFromLocale(locale: string): string | null {
|
export function getPrettyLanguageNameFromLocale(locale: string): string | null {
|
||||||
const tag = getTag(populateLanguageCode(locale), true);
|
const tag = getTag(locale, true);
|
||||||
const lang = tag?.language?.Description?.[0] ?? null;
|
const lang = tag?.language?.Description?.[0] ?? null;
|
||||||
if (!lang) return null;
|
if (!lang) return null;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user