Skip to content

Commit

Permalink
Test on main
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Nov 26, 2024
1 parent 63348fe commit 7175202
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
3 changes: 1 addition & 2 deletions packages/docprovider-extension/src/filebrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ export const statusBarTimeline: JupyterFrontEndPlugin<void> = {
fullPath,
provider,
provider.contentType,
provider.format,
DOCUMENT_TIMELINE_URL
provider.format
);

const elt = document.getElementById('jp-slider-status-bar');
Expand Down
6 changes: 1 addition & 5 deletions packages/docprovider/src/TimelineSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,18 @@ export class TimelineWidget extends ReactWidget {
private provider: IForkProvider;
private contentType: string;
private format: string;
private documentTimelineUrl: string;

constructor(
apiURL: string,
provider: IForkProvider,
contentType: string,
format: string,
documentTimelineUrl: string
format: string
) {
super();
this.apiURL = apiURL;
this.provider = provider;
this.contentType = contentType;
this.format = format;
this.documentTimelineUrl = documentTimelineUrl;
this.addClass('jp-timelineSliderWrapper');
}

Expand All @@ -39,7 +36,6 @@ export class TimelineWidget extends ReactWidget {
provider={this.provider}
contentType={this.contentType}
format={this.format}
documentTimelineUrl={this.documentTimelineUrl}
/>
);
}
Expand Down
17 changes: 5 additions & 12 deletions packages/docprovider/src/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ type Props = {
provider: IForkProvider;
contentType: string;
format: string;
documentTimelineUrl: string;
};

export const TimelineSliderComponent: React.FC<Props> = ({
apiURL,
provider,
contentType,
format,
documentTimelineUrl
format
}) => {
const [data, setData] = useState({
roomId: '',
Expand Down Expand Up @@ -149,21 +147,16 @@ export const TimelineSliderComponent: React.FC<Props> = ({
function determineAction(currentTimestamp: number): 'undo' | 'redo' {
return currentTimestamp < currentTimestampIndex ? 'undo' : 'redo';
}

function extractFilenameFromURL(url: string): string {
try {
const parsedURL = new URL(url);
const pathname = parsedURL.pathname;
const segments = pathname.split('/');

const apiIndex = pathname.lastIndexOf(documentTimelineUrl);
if (apiIndex === -1) {
throw new Error(
`API segment "${documentTimelineUrl}" not found in URL.`
);
}

return pathname.slice(apiIndex + documentTimelineUrl.length);
return segments.slice(4 - segments.length).join('/');
} catch (error) {
console.error('Invalid URL or unable to extract filename:', error);
console.error('Invalid URL:', error);
return '';
}
}
Expand Down

0 comments on commit 7175202

Please sign in to comment.