Skip to content

Commit

Permalink
Remove the realease version and use dissmisskey
Browse files Browse the repository at this point in the history
  • Loading branch information
Wentao-Kuang committed Oct 8, 2024
1 parent 92213dd commit 90d9abc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
24 changes: 5 additions & 19 deletions packages/landing/src/components/feature.updates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type FeatureUpdatesProps = {
header: string;
wrapperClass?: string;
id: string;
releaseVersion: string;
dismissedKey: string;
closingDate: Date;
enabled: boolean;
children?: ReactNode;
Expand All @@ -27,30 +27,16 @@ export class FeatureUpdates extends Component<FeatureUpdatesProps, FeatureUpdate
constructor(props: FeatureUpdatesProps) {
super(props);

const id = window.localStorage.getItem(this.props.id);

this.state = {
showModal: this.showModal(),
showModal: this.props.enabled && this.props.dismissedKey !== id && this.props.closingDate >= new Date(),
};
}

showModal(): boolean {
if (!this.props.enabled) return false;
// Disable after closing date
if (this.props.closingDate < new Date()) return false;
// Disable if dismissed
const id = window.localStorage.getItem(this.props.id);
const releaseVersion = this.props.releaseVersion.trim();
if (releaseVersion === id) return false;
// Disable if not same release version
const currentVersion = Config.Version.trim();
if (Config.Version === '' || currentVersion.length <= releaseVersion.length) return false;
const versionMatch = currentVersion.slice(0, releaseVersion.length);
if (versionMatch !== releaseVersion) return false;
return true;
}

handleClose = (): void => {
this.setState({ showModal: false });
window.localStorage.setItem(this.props.id, this.props.releaseVersion);
window.localStorage.setItem(this.props.id, this.props.dismissedKey);
};

override render(): ReactNode {
Expand Down
8 changes: 4 additions & 4 deletions packages/landing/src/components/new-features/3d.map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const baseUrl = WindowUrl.baseUrl();
const bigImage = new URL('assets/Lg+3D+Maps+splash.gif', baseUrl).href; // Large gif file location
const smallImage = new URL('assets/Sml+3D+map+splash.gif', baseUrl).href; // Small gif file location
const closingDate = new Date('2024-10-30'); // End date for pop up screen
const dismissedKey = `DISMISSED_MODALS_LINZ_Basemaps_3D_Map`; // Optional to set as Config.Version to disable Modal as default
const releaseVersion = 'v7'; // Feature released version can both been major version or minor version
const id = `LINZ_Basemaps_3D_Map`; // Optional to set as Config.Version to disable Modal as default
const dismissedKey = 'DISMISSED_MODALS_2024_10_3d_map'; // Feature released version can both been major version or minor version
const recentUpdates = {
children: (
<>
Expand All @@ -34,9 +34,9 @@ export class NewFeature extends Component {
override render(): ReactNode {
return (
<FeatureUpdates
id={dismissedKey}
id={id}
header="What's new"
releaseVersion={releaseVersion}
dismissedKey={dismissedKey}
closingDate={closingDate}
bigImage={recentUpdates.bigImage}
smallImage={recentUpdates.smallImage}
Expand Down

0 comments on commit 90d9abc

Please sign in to comment.