Skip to content

Commit

Permalink
remove legacy update notification system
Browse files Browse the repository at this point in the history
  • Loading branch information
timche committed May 15, 2023
1 parent bc2dd31 commit d97b151
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 220 deletions.
7 changes: 5 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 0 additions & 16 deletions scripts/bump-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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
Expand Down
54 changes: 0 additions & 54 deletions src/background/index.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
}
}
}
}
})
50 changes: 0 additions & 50 deletions src/changelogs.json

This file was deleted.

28 changes: 1 addition & 27 deletions src/popup/app.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -96,15 +75,10 @@ export default class App extends React.Component {

render() {
const { options, loading } = this.state
const { updateNotificationType, updateNotifications } = options

return (
<React.Fragment>
<AppBar
showUpdateNotifications={updateNotificationType === 'badge'}
updateNotifications={updateNotifications}
onClickUpdateNotification={this.onClickUpdateNotification}
/>
<AppBar />
<Drawer
loading={loading}
items={{
Expand Down
45 changes: 0 additions & 45 deletions src/popup/components/app-bar.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
import React from 'react'
import AppBar from '@material-ui/core/AppBar'
import Toolbar from '@material-ui/core/Toolbar'
import Button from '@material-ui/core/Button'
import Menu from '@material-ui/core/Menu'
import MenuItem from '@material-ui/core/MenuItem'
import LogoMark from './logo-mark'
import LogoType from './logo-type'

export default class extends React.Component {
state = {
anchorEl: null
}

onCloseMenu = () => this.setState({ anchorEl: null })

onClickNotificationUpdates = event =>
this.setState({ anchorEl: event.currentTarget })

render() {
const {
updateNotifications = [],
showUpdateNotifications,
onClickUpdateNotification
} = this.props
const { anchorEl } = this.state

return (
<AppBar
position="static"
Expand All @@ -44,32 +25,6 @@ export default class extends React.Component {
<LogoMark style={{ height: 40, width: 'auto' }} />
<LogoType style={{ height: 16, width: 'auto' }} />
</div>
{showUpdateNotifications && (
<React.Fragment>
<Button
variant="raised"
disabled={!updateNotifications.length}
onClick={this.onClickNotificationUpdates}
>
{updateNotifications.length} new Update
{updateNotifications.length !== 1 && 's'}
</Button>
<Menu
anchorEl={anchorEl}
open={Boolean(anchorEl)}
onClose={this.onCloseMenu}
>
{updateNotifications.map(version => (
<MenuItem
key={version}
onClick={() => onClickUpdateNotification(version)}
>
v{version}
</MenuItem>
))}
</Menu>
</React.Fragment>
)}
</Toolbar>
</AppBar>
)
Expand Down
7 changes: 1 addition & 6 deletions src/popup/sections/about.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -9,11 +8,7 @@ export const ABOUT = 'About'
export default () => (
<React.Fragment>
<ListSubheader>About</ListSubheader>
<ListItemLink
primary="Version"
secondary={version}
href={changelogs[version]}
/>
<ListItemLink primary="Version" secondary={version} />
<ListItemLink
primary="Website"
secondary="repeek.gg"
Expand Down
16 changes: 1 addition & 15 deletions src/popup/sections/general.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
import React from 'react'
import { UPDATE_NOTIFICATION_TYPES } from '../../shared/settings'
import ListSubheader from '../components/list-subheader'
import ListItemSwitch from '../components/list-item-switch'
import ListItemMenu from '../components/list-item-menu'

const UPDATE_NOTIFICATION_TYPES_MAP = {
tab: 'Open changelog in a new unfocused tab automatically',
badge: 'Show a badge on the extension icon and open changelog by myself',
disabled: 'Disabled'
}

export const GENERAL = 'General'

export default ({ getSwitchProps, getMenuProps }) => (
export default ({ getSwitchProps }) => (
<React.Fragment>
<ListSubheader>Extension</ListSubheader>
<ListItemSwitch
primary="Enabled"
secondary="FACEIT will be enhanced."
{...getSwitchProps('extensionEnabled')}
/>
<ListItemMenu
primary="Update Notification"
options={UPDATE_NOTIFICATION_TYPES}
mapOption={option => UPDATE_NOTIFICATION_TYPES_MAP[option]}
{...getMenuProps('updateNotificationType')}
/>
</React.Fragment>
)
4 changes: 0 additions & 4 deletions src/shared/settings.js
Original file line number Diff line number Diff line change
@@ -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'],
Expand Down Expand Up @@ -52,8 +50,6 @@ export const DEFAULTS = {
notifyMatchRoomAutoConnectToServer: true,
notifyMatchRoomAutoVetoLocations: true,
notifyMatchRoomAutoVetoMaps: true,
updateNotificationType: 'tab',
updateNotifications: [],
teamRosterPlayersInfo: true,
repeekNotificationClosed: false
}

0 comments on commit d97b151

Please sign in to comment.