File tree Expand file tree Collapse file tree 3 files changed +31
-5
lines changed Expand file tree Collapse file tree 3 files changed +31
-5
lines changed Original file line number Diff line number Diff line change 99 UnmuteOverlay ,
1010 URLLoadOptions ,
1111 WindowMode ,
12+ CacheBehavior ,
1213} from "../../public/config" ;
1314import { MovieMetadata , ReadyState } from "../../public/player" ;
1415import { ruffleShadowTemplate } from "../ui/shadow-template" ;
@@ -2137,10 +2138,14 @@ 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 ) {
21422143 return ;
21432144 }
2145+ if ( this . loadedConfig ?. bfcacheBehavior === CacheBehavior . Reload ) {
2146+ this . reload ( ) ;
2147+ return ;
2148+ }
21442149 const message = textAsParagraphs ( "message-restored-from-bfcache" ) ;
21452150 this . displayMessageOrElement ( message ) ;
21462151
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import {
1010 UnmuteOverlay ,
1111 WindowMode ,
1212 ScrollingBehavior ,
13+ CacheBehavior ,
1314} from "./load-options" ;
1415
1516export 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 ,
Original file line number Diff line number Diff 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.
You can’t perform that action at this time.
0 commit comments