From d97b15147c0cd07e5119e372ab41037d50dffffc Mon Sep 17 00:00:00 2001 From: Tim Cheung Date: Mon, 15 May 2023 12:44:04 +0100 Subject: [PATCH] remove legacy update notification system --- package-lock.json | 7 +++-- package.json | 1 - scripts/bump-version.js | 16 ---------- src/background/index.js | 54 --------------------------------- src/changelogs.json | 50 ------------------------------ src/popup/app.js | 28 +---------------- src/popup/components/app-bar.js | 45 --------------------------- src/popup/sections/about.js | 7 +---- src/popup/sections/general.js | 16 +--------- src/shared/settings.js | 4 --- 10 files changed, 8 insertions(+), 220 deletions(-) delete mode 100644 src/changelogs.json diff --git a/package-lock.json b/package-lock.json index cbd61481..8274a348 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,6 @@ "react-dom": "^16.2.0", "react-sortable-hoc": "^0.6.8", "select-dom": "^4.1.1", - "semver-diff": "^2.1.0", "style-inject": "^0.3.0", "webext-options-sync": "^4.0.0", "webextension-polyfill": "^0.2.1" @@ -16573,6 +16572,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/semver-diff/-/semver-diff-2.1.0.tgz", "integrity": "sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY=", + "dev": true, "license": "MIT", "dependencies": { "semver": "^5.0.3" @@ -16585,6 +16585,7 @@ "version": "5.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", + "dev": true, "license": "ISC", "bin": { "semver": "bin/semver" @@ -34726,6 +34727,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/semver-diff/-/semver-diff-2.1.0.tgz", "integrity": "sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY=", + "dev": true, "requires": { "semver": "^5.0.3" }, @@ -34733,7 +34735,8 @@ "semver": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", + "dev": true } } }, diff --git a/package.json b/package.json index c500d2db..d2c462cf 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,6 @@ "react-dom": "^16.2.0", "react-sortable-hoc": "^0.6.8", "select-dom": "^4.1.1", - "semver-diff": "^2.1.0", "style-inject": "^0.3.0", "webext-options-sync": "^4.0.0", "webextension-polyfill": "^0.2.1" diff --git a/scripts/bump-version.js b/scripts/bump-version.js index 634e5f44..d9ace34d 100644 --- a/scripts/bump-version.js +++ b/scripts/bump-version.js @@ -8,7 +8,6 @@ const execa = require('execa') ;(async () => { try { const releaseType = process.argv[2] - const changelogUrl = process.argv[3] const manifestFile = path.resolve(__dirname, '..', 'src', 'manifest.json') @@ -19,21 +18,6 @@ const execa = require('execa') console.log(`Bumped to version ${manifest.version}`) - if (changelogUrl) { - const changelogsFile = path.resolve( - __dirname, - '..', - 'src', - 'changelogs.json' - ) - const changelogs = await loadJsonFile(changelogsFile) - await writeJsonFile(changelogsFile, { - [manifest.version]: changelogUrl, - ...changelogs - }) - console.log(`Added changelog ${changelogUrl}`) - } - const gitCommitProc = execa('git', ['commit', '-am', manifest.version]) gitCommitProc.stdout.pipe(process.stdout) await gitCommitProc diff --git a/src/background/index.js b/src/background/index.js index c11f3273..fe66fe97 100644 --- a/src/background/index.js +++ b/src/background/index.js @@ -1,8 +1,4 @@ import browser from 'webextension-polyfill' -import semverDiff from 'semver-diff' -import storage from '../shared/storage' -import changelogs from '../changelogs' -import { UPDATE_NOTIFICATION_TYPES } from '../shared/settings' import { IS_PRODUCTION, ACTION_NOTIFICATION, @@ -100,53 +96,3 @@ browser.runtime.onMessage.addListener(async message => { default: } }) - -browser.runtime.onInstalled.addListener(async ({ reason, previousVersion }) => { - if (reason === 'update') { - const { installType } = await browser.management.getSelf() - - if (installType === 'development') { - return - } - - const { version } = browser.runtime.getManifest() - - const versionDiffType = semverDiff(previousVersion, version) - if (versionDiffType === null || versionDiffType === 'patch') { - return - } - - const changelogUrl = changelogs[version] - - if (changelogUrl) { - const { - updateNotificationType, - updateNotifications - } = await storage.getAll() - - switch (updateNotificationType) { - // Tab - case UPDATE_NOTIFICATION_TYPES[0]: { - browser.tabs.create({ - url: changelogUrl, - active: false - }) - break - } - // Badge - case UPDATE_NOTIFICATION_TYPES[1]: { - updateNotifications.push(version) - await storage.set({ updateNotifications }) - browser.browserAction.setBadgeText({ - text: updateNotifications.length.toString() - }) - browser.browserAction.setBadgeBackgroundColor({ color: '#f50' }) - break - } - default: { - break - } - } - } - } -}) diff --git a/src/changelogs.json b/src/changelogs.json deleted file mode 100644 index 4800f985..00000000 --- a/src/changelogs.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "2.9.0": "https://redd.it/dds14w", - "2.0.0": "https://redd.it/bkx7tl", - "1.6.7": "https://redd.it/9afkzy", - "1.6.6": "https://redd.it/9afkzy", - "1.4.1": "https://redd.it/8kd917", - "1.4.0": "https://redd.it/8kd917", - "1.3.3": "https://redd.it/8f2jxc", - "1.3.2": "https://redd.it/8f2jxc", - "1.3.1": "https://redd.it/8f2jxc", - "1.3.0": "https://redd.it/8f2jxc", - "1.2.2": "https://redd.it/8cppf1", - "1.2.1": "https://redd.it/8cppf1", - "1.2.0": "https://redd.it/8cppf1", - "1.1.0": "https://redd.it/8b6mqw", - "1.0.2": "https://redd.it/89rwwm", - "1.0.1": "https://redd.it/89rwwm", - "1.0.0": "https://redd.it/89rwwm", - "0.18.1": "https://redd.it/87iuka", - "0.18.0": "https://redd.it/87iuka", - "0.17.1": "https://redd.it/87d0g3", - "0.17.0": "https://redd.it/87d0g3", - "0.16.2": "https://redd.it/871ffx", - "0.16.1": "https://redd.it/871ffx", - "0.16.0": "https://redd.it/871ffx", - "0.15.5": "https://redd.it/86mi95", - "0.15.4": "https://redd.it/86mi95", - "0.15.3": "https://redd.it/86mi95", - "0.15.2": "https://redd.it/86mi95", - "0.15.1": "https://redd.it/86mi95", - "0.15.0": "https://redd.it/86mi95", - "0.14.3": "https://redd.it/86d9fw", - "0.14.2": "https://redd.it/86d9fw", - "0.14.1": "https://redd.it/86d9fw", - "0.14.0": "https://redd.it/86d9fw", - "0.13.0": "https://redd.it/85ud1b", - "0.12.1": "https://redd.it/85o957", - "0.12.0": "https://redd.it/85o957", - "0.11.3": "https://redd.it/85et26", - "0.11.2": "https://redd.it/85et26", - "0.11.1": "https://redd.it/85et26", - "0.11.0": "https://redd.it/85et26", - "0.10.3": "https://redd.it/850ife", - "0.10.2": "https://redd.it/850ife", - "0.10.1": "https://redd.it/850ife", - "0.10.0": "https://redd.it/850ife", - "0.9.0": "https://redd.it/84i064", - "0.8.0": "https://redd.it/84f9n9", - "0.7.0": "https://redd.it/847yin" -} diff --git a/src/popup/app.js b/src/popup/app.js index c718acff..74af64a5 100644 --- a/src/popup/app.js +++ b/src/popup/app.js @@ -1,7 +1,5 @@ import React from 'react' -import browser from 'webextension-polyfill' import storage from '../shared/storage' -import changelogs from '../changelogs' import { MATCH_ROOM_VETO_LOCATION_REGIONS } from '../shared/settings' import AppBar from './components/app-bar' import Drawer from './components/drawer' @@ -29,25 +27,6 @@ export default class App extends React.Component { })) } - onClickUpdateNotification = async versionClicked => { - const updateNotifications = this.state.options.updateNotifications.filter( - updateVersion => updateVersion !== versionClicked - ) - - await storage.set({ updateNotifications }) - - browser.browserAction.setBadgeText({ - text: - updateNotifications.length > 0 - ? updateNotifications.length.toString() - : '' - }) - - browser.tabs.create({ - url: changelogs[versionClicked] - }) - } - getUpdateOption = option => newValue => { this.setState(({ options }) => { const updatedOption = { [option]: newValue } @@ -96,15 +75,10 @@ export default class App extends React.Component { render() { const { options, loading } = this.state - const { updateNotificationType, updateNotifications } = options return ( - + this.setState({ anchorEl: null }) - - onClickNotificationUpdates = event => - this.setState({ anchorEl: event.currentTarget }) - render() { - const { - updateNotifications = [], - showUpdateNotifications, - onClickUpdateNotification - } = this.props - const { anchorEl } = this.state - return ( - {showUpdateNotifications && ( - - - - {updateNotifications.map(version => ( - onClickUpdateNotification(version)} - > - v{version} - - ))} - - - )} ) diff --git a/src/popup/sections/about.js b/src/popup/sections/about.js index 730f1a6a..75a97ad3 100644 --- a/src/popup/sections/about.js +++ b/src/popup/sections/about.js @@ -1,5 +1,4 @@ import React from 'react' -import changelogs from '../../changelogs' import { version } from '../../manifest' import ListSubheader from '../components/list-subheader' import ListItemLink from '../components/list-item-link' @@ -9,11 +8,7 @@ export const ABOUT = 'About' export default () => ( About - + ( +export default ({ getSwitchProps }) => ( Extension ( secondary="FACEIT will be enhanced." {...getSwitchProps('extensionEnabled')} /> - UPDATE_NOTIFICATION_TYPES_MAP[option]} - {...getMenuProps('updateNotificationType')} - /> ) diff --git a/src/shared/settings.js b/src/shared/settings.js index 5a8b8a4e..eb77ab8a 100644 --- a/src/shared/settings.js +++ b/src/shared/settings.js @@ -1,5 +1,3 @@ -export const UPDATE_NOTIFICATION_TYPES = ['tab', 'badge', 'disabled'] - export const MATCH_ROOM_VETO_LOCATION_ITEMS = { EU: ['UK', 'Sweden', 'France', 'Germany', 'Netherlands'], US: ['Chicago', 'Dallas', 'Denver', 'LosAngeles', 'NewYork'], @@ -52,8 +50,6 @@ export const DEFAULTS = { notifyMatchRoomAutoConnectToServer: true, notifyMatchRoomAutoVetoLocations: true, notifyMatchRoomAutoVetoMaps: true, - updateNotificationType: 'tab', - updateNotifications: [], teamRosterPlayersInfo: true, repeekNotificationClosed: false }