Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions web/packages/core/src/internal/player/inner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
UnmuteOverlay,
URLLoadOptions,
WindowMode,
BFCacheBehavior,
} from "../../public/config";
import { MovieMetadata, ReadyState } from "../../public/player";
import { ruffleShadowTemplate } from "../ui/shadow-template";
Expand Down Expand Up @@ -2134,8 +2135,15 @@ export class InnerPlayer {
* Inform the user that the browser restored the file from the back/forward cache.
*/
protected displayRestoredFromBfcacheMessage(): void {
// Do not display the message if another one is already shown.
if (this.container.querySelector("#message-overlay") !== null) {
// Do not display the message if another one is already shown or website opted out.
if (
this.container.querySelector("#message-overlay") !== null ||
this.loadedConfig?.bfcacheBehavior === BFCacheBehavior.Restore
) {
return;
}
if (this.loadedConfig?.bfcacheBehavior === BFCacheBehavior.Reload) {
this.reload();
return;
}
const message = textAsParagraphs("message-restored-from-bfcache");
Expand Down
2 changes: 2 additions & 0 deletions web/packages/core/src/public/config/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
UnmuteOverlay,
WindowMode,
ScrollingBehavior,
BFCacheBehavior,
} from "./load-options";

export const DEFAULT_CONFIG: Required<BaseLoadOptions> = {
Expand All @@ -22,6 +23,7 @@ export const DEFAULT_CONFIG: Required<BaseLoadOptions> = {
upgradeToHttps: true,
compatibilityRules: true,
favorFlash: true,
bfcacheBehavior: BFCacheBehavior.Inform,
warnOnUnsupportedContent: true,
logLevel: LogLevel.Error,
showSwfDownload: false,
Expand Down
27 changes: 27 additions & 0 deletions web/packages/core/src/public/config/load-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,26 @@ export enum GamepadButton {
DPadRight = "dpad-right",
}

/**
* The behavior when the bfcache takes effect
*/
export enum BFCacheBehavior {
/**
* Inform the user that the content was restore from the bfcache.
*/
Inform = "inform",

/**
* Restore the content from the bfcache without a message.
*/
Restore = "restore",

/**
* Reload the content so it starts fresh if the bfcache takes effect.
*/
Reload = "reload",
}

/**
* Any options used for loading a movie.
*/
Expand Down Expand Up @@ -450,6 +470,13 @@ export interface BaseLoadOptions {
*/
favorFlash?: boolean;

/**
* Behavior when the bfcache takes effect
*
* @default BFCacheBehavior.Inform
*/
bfcacheBehavior?: BFCacheBehavior;

/**
* This is no longer used and does not affect anything.
* It is only kept for backwards compatibility.
Expand Down