forked from external-repos/squoosh
Naming changes
This commit is contained in:
@@ -49,7 +49,7 @@ interface Props {
|
|||||||
}
|
}
|
||||||
interface State {
|
interface State {
|
||||||
fetchingDemoIndex?: number;
|
fetchingDemoIndex?: number;
|
||||||
installEvent?: BeforeInstallPromptEvent;
|
beforeInstallEvent?: BeforeInstallPromptEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Intro extends Component<Props, State> {
|
export default class Intro extends Component<Props, State> {
|
||||||
@@ -110,7 +110,7 @@ export default class Intro extends Component<Props, State> {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
// Save the beforeinstallprompt event so it can be called later.
|
// Save the beforeinstallprompt event so it can be called later.
|
||||||
this.setState({ installEvent: event });
|
this.setState({ beforeInstallEvent: event });
|
||||||
|
|
||||||
// Log the event.
|
// Log the event.
|
||||||
ga('send', 'event', 'pwa-install', 'available');
|
ga('send', 'event', 'pwa-install', 'available');
|
||||||
@@ -119,17 +119,17 @@ export default class Intro extends Component<Props, State> {
|
|||||||
@bind
|
@bind
|
||||||
private async onInstallClick(event: Event) {
|
private async onInstallClick(event: Event) {
|
||||||
// Get the deferred beforeinstallprompt event
|
// Get the deferred beforeinstallprompt event
|
||||||
const deferredPrompt = this.state.installEvent;
|
const beforeInstallEvent = this.state.beforeInstallEvent;
|
||||||
// If there's no deferred prompt, bail.
|
// If there's no deferred prompt, bail.
|
||||||
if (!deferredPrompt) return;
|
if (!beforeInstallEvent) return;
|
||||||
|
|
||||||
this.installingViaButton = true;
|
this.installingViaButton = true;
|
||||||
|
|
||||||
// Show the browser install prompt
|
// Show the browser install prompt
|
||||||
deferredPrompt.prompt();
|
beforeInstallEvent.prompt();
|
||||||
|
|
||||||
// Wait for the user to accept or dismiss the install prompt
|
// Wait for the user to accept or dismiss the install prompt
|
||||||
const { outcome } = await deferredPrompt.userChoice;
|
const { outcome } = await beforeInstallEvent.userChoice;
|
||||||
ga('send', 'event', 'pwa-install', installButtonSource, outcome);
|
ga('send', 'event', 'pwa-install', installButtonSource, outcome);
|
||||||
|
|
||||||
// If the prompt was dismissed, we aren't going to install via the button.
|
// If the prompt was dismissed, we aren't going to install via the button.
|
||||||
@@ -146,10 +146,10 @@ export default class Intro extends Component<Props, State> {
|
|||||||
|
|
||||||
this.installingViaButton = false;
|
this.installingViaButton = false;
|
||||||
// We don't need the install button, if it's shown
|
// We don't need the install button, if it's shown
|
||||||
this.setState({ installEvent: undefined });
|
this.setState({ beforeInstallEvent: undefined });
|
||||||
}
|
}
|
||||||
|
|
||||||
render({ }: Props, { fetchingDemoIndex, installEvent }: State) {
|
render({ }: Props, { fetchingDemoIndex, beforeInstallEvent }: State) {
|
||||||
return (
|
return (
|
||||||
<div class={style.intro}>
|
<div class={style.intro}>
|
||||||
<div>
|
<div>
|
||||||
@@ -191,7 +191,7 @@ export default class Intro extends Component<Props, State> {
|
|||||||
)}
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{installEvent &&
|
{beforeInstallEvent &&
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class={style.installButton}
|
class={style.installButton}
|
||||||
|
|||||||
Reference in New Issue
Block a user