Compare commits
1 commit
main
...
filekey-pr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b68e79ab4 |
6 changed files with 16 additions and 9 deletions
|
|
@ -88,7 +88,7 @@ function WebPlayer(props: any) {
|
|||
);
|
||||
if (usePrefetched) {
|
||||
if (mobData?.data) {
|
||||
WebPlayerInst.preloadFirstFile(mobData?.data);
|
||||
WebPlayerInst.preloadFirstFile(mobData?.data, mobData?.fileKey);
|
||||
}
|
||||
}
|
||||
setContextValue({ player: WebPlayerInst, store: PlayerStore });
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ export default class SessionStore {
|
|||
previousId = '';
|
||||
nextId = '';
|
||||
userTimezone = '';
|
||||
prefetchedMobUrls: Record<string, { data: Uint8Array; entryNum: number }> = {};
|
||||
prefetchedMobUrls: Record<string, { data: Uint8Array; entryNum: number, fileKey?: string }> = {};
|
||||
prefetched: boolean = false;
|
||||
fetchFailed: boolean = false;
|
||||
loadingLiveSessions: boolean = false;
|
||||
|
|
@ -161,11 +161,11 @@ export default class SessionStore {
|
|||
}
|
||||
|
||||
getFirstMob = async (sessionId: string) => {
|
||||
const { domURL } = await sessionService.getFirstMobUrl(sessionId);
|
||||
await loadFile(domURL[0], (data) => this.setPrefetchedMobUrl(sessionId, data));
|
||||
const { domURL, fileKey } = await sessionService.getFirstMobUrl(sessionId);
|
||||
await loadFile(domURL[0], (data) => this.setPrefetchedMobUrl(sessionId, data, fileKey));
|
||||
}
|
||||
|
||||
setPrefetchedMobUrl = (sessionId: string, fileData: Uint8Array) => {
|
||||
setPrefetchedMobUrl = (sessionId: string, fileData: Uint8Array, fileKey?: string) => {
|
||||
const keys = Object.keys(this.prefetchedMobUrls);
|
||||
const toLimit = 10 - keys.length;
|
||||
if (toLimit < 0) {
|
||||
|
|
@ -181,6 +181,7 @@ export default class SessionStore {
|
|||
: 0;
|
||||
this.prefetchedMobUrls[sessionId] = {
|
||||
data: fileData,
|
||||
fileKey,
|
||||
entryNum: nextEntryNum,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ const unpack = (b: Uint8Array): Uint8Array => {
|
|||
);
|
||||
data = uData;
|
||||
}
|
||||
if (!isGzip && !isZstd) {
|
||||
console.debug('No unpacking needed', Math.floor(b.byteLength / 1024) + 'kb');
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -214,7 +214,10 @@ export default class MessageLoader {
|
|||
}
|
||||
|
||||
preloaded = false;
|
||||
async preloadFirstFile(data: Uint8Array) {
|
||||
async preloadFirstFile(data: Uint8Array, fileKey?: string) {
|
||||
if (fileKey) {
|
||||
this.session.fileKey = fileKey;
|
||||
}
|
||||
this.mobParser = this.createNewParser(true, this.processMessages, 'p:dom');
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -86,8 +86,8 @@ export default class WebPlayer extends Player {
|
|||
window.playerJumpToTime = this.jump.bind(this)
|
||||
}
|
||||
|
||||
preloadFirstFile(data: Uint8Array) {
|
||||
void this.messageLoader.preloadFirstFile(data)
|
||||
preloadFirstFile(data: Uint8Array, fileKey?: string) {
|
||||
void this.messageLoader.preloadFirstFile(data, fileKey)
|
||||
}
|
||||
|
||||
reinit(session: SessionFilesInfo) {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export default class SettingsService {
|
|||
.catch((e) => Promise.reject(e));
|
||||
}
|
||||
|
||||
getFirstMobUrl(sessionId: string): Promise<{ domURL: string[] }> {
|
||||
getFirstMobUrl(sessionId: string): Promise<{ domURL: string[], fileKey?: string }> {
|
||||
return this.client
|
||||
.get(`/sessions/${sessionId}/first-mob`)
|
||||
.then((r) => r.json())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue