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

Store cuePoints across page loads #100

Open
wants to merge 1 commit into
base: main
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
14 changes: 13 additions & 1 deletion renin/src/renin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,16 @@ export interface Options {
maxHeight?: number;
}

const stored = JSON.parse(localStorage.getItem('renin:stored') || '{}');

export class Renin {
static instance: Renin;
width: number = 1;
height: number = 1;
audioBar: AudioBar;
music = new Music();
sync: Sync;
frame = 0;
frame = stored.frame || 0;
oldTime: number = 0;
time: number = 0;
dt: number = 0;
Expand Down Expand Up @@ -418,6 +420,9 @@ export class Renin {
this.music.setPlaybackRate(playbackRates[e.key]);
}
});
if (stored.frame) {
this.jumpToFrame(stored.frame);
}
}

startRealTimeScreenRecording() {
Expand Down Expand Up @@ -638,6 +643,13 @@ export class Renin {
if (this.options.productionMode) {
return false;
}
localStorage.setItem(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How often is this function called – will this localStorage add a noticeable penalty on the update loop in dev mode? 🤔

'renin:stored',
JSON.stringify({
frame: this.frame,
cuePoints: this.cuePoints.length > 0 ? this.cuePoints : null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR only stores cuePoints, but doesn't read them?

})
);
let needsRenderAfter = false;
const time = performance.now();
needsRenderAfter ||= this.fullscreenAnimation.update(this.uiTime);
Expand Down