Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWIK-2088 Fix reloading presentation mode starting on the wrong slide #1010

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
26 changes: 25 additions & 1 deletion components/Deck/Presentation/Presentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ class Presentation extends React.Component{

componentDidMount(){
if(process.env.BROWSER){

window.addEventListener('beforeunload', (event) => {
if(window.localStorage)
window.localStorage.setItem('lastHash', JSON.stringify({'hash': window.location.hash, 'time': new Date().getTime(), 'deckID': this.props.PresentationStore.selector.id}) );//safe current slide for page refresh
});

let lastRevealHash = undefined;
if(window.localStorage) {
lastRevealHash = window.localStorage.getItem('lastHash');
lastRevealHash = (lastRevealHash) ? JSON.parse(lastRevealHash) : undefined;
if(lastRevealHash) {
if(lastRevealHash.deckID !== this.props.PresentationStore.selector.id){ //check that it is still the same deck, cause 15 secs is rather long
lastRevealHash = undefined;
} else {
let timePassed = (new Date().getTime()) - lastRevealHash.time;
lastRevealHash = (timePassed > 0 && timePassed <= 15*1000) ? lastRevealHash.hash : undefined;//not older than 15 secs ... just for reload of the page
}
}
window.localStorage.removeItem('lastHash');
}

//$('[style*="absolute"]').children().attr('tabindex', 0);

//remove existing tabindices
Expand Down Expand Up @@ -62,7 +83,10 @@ class Presentation extends React.Component{
pptxheight = '100%';
}

window.location.hash = '#slide-' + this.startingSlide;
if(lastRevealHash === undefined)
window.location.hash = '#slide-' + this.startingSlide;
else
window.location.hash = lastRevealHash;

let multiplexFileToLoad = (this.secret) ? '/custom_modules/reveal.js/plugin/multiplex/master.js' : '/custom_modules/reveal.js/plugin/multiplex/client.js' ;
multiplexFileToLoad = (this.id) ? multiplexFileToLoad : '' ;
Expand Down