Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
remove unused function
Browse files Browse the repository at this point in the history
Summary: As we now only allow installing PWA from setup wizard, this is no longer needed and it is already no longer used

Reviewed By: LukeDefeo

Differential Revision: D52204483

fbshipit-source-id: 06600339197d6f80899e9b707205679d744e8826
  • Loading branch information
antonk52 authored and facebook-github-bot committed Dec 18, 2023
1 parent 1323d3b commit b7555c4
Showing 1 changed file with 0 additions and 64 deletions.
64 changes: 0 additions & 64 deletions desktop/flipper-ui/src/chrome/PWAppInstallationWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import React from 'react';
import {Image, Button} from 'antd';
import {getFlipperLib, Layout, _NuxManagerContext} from 'flipper-plugin';
import isProduction from '../utils/isProduction';
import {getFlipperServer} from '../flipperServer';

type TrackerEvents = {
Expand All @@ -36,69 +35,6 @@ class PWAWizardTracker {

const tracker = new PWAWizardTracker();

const lastShownTimestampKey = 'flipper-pwa-wizard-last-shown-timestamp';
const neverAskAgainKey = 'flipper-pwa-wizard-never-ask-again';
export function shouldShowPWAInstallationWizard(): boolean {
if (!isProduction()) {
return false;
}

if (window.matchMedia('(display-mode: standalone)').matches) {
tracker.track('pwa-installation-wizard-should-show', {
show: false,
reason: 'Display mode is standalone, seems is already running as PWA',
});
return false;
}

let neverAskAgain = undefined;
try {
neverAskAgain = window.localStorage.getItem(neverAskAgainKey);
} catch (e) {}
if (neverAskAgain !== undefined && neverAskAgain !== null) {
return false;
}

let lastShownTimestampFromStorage = undefined;
try {
lastShownTimestampFromStorage = window.localStorage.getItem(
lastShownTimestampKey,
);
} catch (e) {}
if (lastShownTimestampFromStorage) {
const withinOneDay = (timestamp: number) => {
const Day = 1 * 24 * 60 * 60 * 1000;
const DayAgo = Date.now() - Day;

return timestamp > DayAgo;
};
const lastShownTimestamp = Number(lastShownTimestampFromStorage);

const notShownWithinOneDay = !withinOneDay(lastShownTimestamp);

tracker.track('pwa-installation-wizard-should-show', {
show: notShownWithinOneDay,
reason: 'Last shown timestamp from storage is available',
});
return notShownWithinOneDay;
}

const lastShownTimestamp = Date.now();
try {
window.localStorage.setItem(
lastShownTimestampKey,
String(lastShownTimestamp),
);
} catch (e) {}

tracker.track('pwa-installation-wizard-should-show', {
show: true,
reason: 'Last shown timestamp from storage is not available',
});

return true;
}

async function install(event: any) {
event.prompt();

Expand Down

0 comments on commit b7555c4

Please sign in to comment.