mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 06:56:38 +00:00
Added session based view updation for gallery notebooks (#120)
This commit is contained in:
parent
dab6e43d0d
commit
14ef40029d
@ -19,6 +19,7 @@ import { DialogComponent, DialogProps } from "../DialogReactComponent/DialogComp
|
||||
import { NotebookMetadataComponent } from "./NotebookMetadataComponent";
|
||||
import "./NotebookViewerComponent.less";
|
||||
import Explorer from "../../Explorer";
|
||||
import { SessionStorageUtility } from "../../../Shared/StorageUtility";
|
||||
|
||||
export interface NotebookViewerComponentProps {
|
||||
container?: Explorer;
|
||||
@ -88,13 +89,13 @@ export class NotebookViewerComponent extends React.Component<
|
||||
this.notebookComponentBootstrapper.setContent("json", notebook);
|
||||
this.setState({ content: notebook, showProgressBar: false });
|
||||
|
||||
if (this.props.galleryItem) {
|
||||
if (this.props.galleryItem && !SessionStorageUtility.getEntry(this.props.galleryItem.id)) {
|
||||
const response = await this.props.junoClient.increaseNotebookViews(this.props.galleryItem.id);
|
||||
if (!response.data) {
|
||||
throw new Error(`Received HTTP ${response.status} while increasing notebook views`);
|
||||
}
|
||||
|
||||
this.setState({ galleryItem: response.data });
|
||||
SessionStorageUtility.setEntry(this.props.galleryItem?.id, "true");
|
||||
}
|
||||
} catch (error) {
|
||||
this.setState({ showProgressBar: false });
|
||||
|
@ -44,7 +44,11 @@ export class SessionStorageUtility {
|
||||
}
|
||||
|
||||
public static getEntryNumber(key: StorageKey): number {
|
||||
return StringUtility.toNumber(localStorage.getItem(StorageKey[key]));
|
||||
return StringUtility.toNumber(sessionStorage.getItem(StorageKey[key]));
|
||||
}
|
||||
|
||||
public static getEntry(key: string): string | null {
|
||||
return sessionStorage.getItem(key);
|
||||
}
|
||||
|
||||
public static removeEntry(key: StorageKey): void {
|
||||
@ -55,6 +59,10 @@ export class SessionStorageUtility {
|
||||
sessionStorage.setItem(StorageKey[key], value);
|
||||
}
|
||||
|
||||
public static setEntry(key: string, value: string): void {
|
||||
sessionStorage.setItem(key, value);
|
||||
}
|
||||
|
||||
public static setEntryNumber(key: StorageKey, value: number): void {
|
||||
sessionStorage.setItem(StorageKey[key], value.toString());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user