Skip to content

Commit 7cab140

Browse files
committed
web: Change config to bfcacheBehavior enum (inform, restore, reload)
1 parent 57fd5d5 commit 7cab140

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

web/packages/core/src/internal/player/inner.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
UnmuteOverlay,
1010
URLLoadOptions,
1111
WindowMode,
12+
CacheBehavior,
1213
} from "../../public/config";
1314
import { MovieMetadata, ReadyState } from "../../public/player";
1415
import { ruffleShadowTemplate } from "../ui/shadow-template";
@@ -2137,10 +2138,17 @@ export class InnerPlayer {
21372138
// Do not display the message if another one is already shown or website opted out.
21382139
if (
21392140
this.container.querySelector("#message-overlay") !== null ||
2140-
this.loadedConfig?.hideRestoredMessage
2141+
this.loadedConfig?.bfcacheBehavior === CacheBehavior.Restore
21412142
) {
2143+
console.log("Restore");
21422144
return;
21432145
}
2146+
if (this.loadedConfig?.bfcacheBehavior === CacheBehavior.Reload) {
2147+
console.log("Reload");
2148+
this.reload();
2149+
return;
2150+
}
2151+
console.log("Inform");
21442152
const message = textAsParagraphs("message-restored-from-bfcache");
21452153
this.displayMessageOrElement(message);
21462154

web/packages/core/src/public/config/default.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
UnmuteOverlay,
1111
WindowMode,
1212
ScrollingBehavior,
13+
CacheBehavior,
1314
} from "./load-options";
1415

1516
export const DEFAULT_CONFIG: Required<BaseLoadOptions> = {
@@ -22,7 +23,7 @@ export const DEFAULT_CONFIG: Required<BaseLoadOptions> = {
2223
upgradeToHttps: true,
2324
compatibilityRules: true,
2425
favorFlash: true,
25-
hideRestoredMessage: false,
26+
bfcacheBehavior: CacheBehavior.Inform,
2627
warnOnUnsupportedContent: true,
2728
logLevel: LogLevel.Error,
2829
showSwfDownload: false,

web/packages/core/src/public/config/load-options.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,26 @@ export enum GamepadButton {
361361
DPadRight = "dpad-right",
362362
}
363363

364+
/**
365+
* The behavior when the bfcache takes effect
366+
*/
367+
export enum CacheBehavior {
368+
/**
369+
* Inform the user that the content was restore from the bfcache.
370+
*/
371+
Inform = "inform",
372+
373+
/**
374+
* Restore the content from the bfcache without a message.
375+
*/
376+
Restore = "restore",
377+
378+
/**
379+
* Reload the content so it starts fresh if the bfcache takes effect.
380+
*/
381+
Reload = "reload",
382+
}
383+
364384
/**
365385
* Any options used for loading a movie.
366386
*/
@@ -451,11 +471,11 @@ export interface BaseLoadOptions {
451471
favorFlash?: boolean;
452472

453473
/**
454-
* Hide the message when content is restored from the back/forward cache.
474+
* Behavior when the bfcache takes effect
455475
*
456-
* @default false
476+
* @default CacheBehavior.Inform
457477
*/
458-
hideRestoredMessage?: boolean;
478+
bfcacheBehavior?: CacheBehavior;
459479

460480
/**
461481
* This is no longer used and does not affect anything.

0 commit comments

Comments
 (0)