Skip to content

Commit

Permalink
Track the total history
Browse files Browse the repository at this point in the history
  • Loading branch information
ryelle committed Jun 10, 2024
1 parent ce52446 commit e111117
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ const { state } = store( 'wporg/themes/preview', {
const context = getContext();
return context.isLoaded;
},
pages: 1,
initialHistory: window.history.length,
},
actions: {
onLoad() {
const context = getContext();
context.isLoaded = true;
},
goBack( event ) {
if ( window.history.length > state.pages ) {
if ( state.initialHistory > 2 ) {
event.preventDefault();
window.history.go( state.pages * -1 );
window.history.go( state.initialHistory - window.history.length - 1 );
}
},
navigateIframe( event ) {
Expand Down Expand Up @@ -53,7 +53,6 @@ const { state } = store( 'wporg/themes/preview', {

context.url = previewURL;
window.history.replaceState( {}, '', permalinkURL );
state.pages++;
}
},
},
Expand Down

0 comments on commit e111117

Please sign in to comment.