Skip to content

Commit fee93da

Browse files
committedApr 3, 2020
feat: add update message in chat if available
1 parent 136c09c commit fee93da

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed
 

‎packages/metastream-app/src/containers/LobbyPage.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { NetworkError, NetworkErrorCode } from '../network/error'
2727
import { addChat } from '../lobby/actions/chat'
2828
import { MultiTabObserver } from '../utils/multitab'
2929
import { SafeBrowse } from '../services/safeBrowse'
30+
import { UpdateService } from 'services/updater'
3031

3132
interface IRouteParams {
3233
lobbyId: string
@@ -233,6 +234,10 @@ export class _LobbyPage extends Component<PrivateProps, IState> {
233234
if (!this.host || this.supportsNetworking) {
234235
this.setupLobby()
235236
}
237+
238+
if (UpdateService.getInstance().isUpdateAvailable) {
239+
this.props.dispatch(addChat({ content: `🆕 ${t('updateAvailable')}`, timestamp: Date.now() }))
240+
}
236241
}
237242

238243
private onLeaveScreen() {

‎packages/metastream-app/src/locale/en-US.ts

+2
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ export default {
135135
toggleDJ: 'Toggle DJ',
136136
unlimited: 'Unlimited',
137137
unlockQueue: 'Unlock queue',
138+
updateAvailable:
139+
'An update for Metastream is available. Press the UPDATE button in the top-right to receive the update.',
138140
username: 'Username',
139141
users: 'Users',
140142
userJoined: '<Username id="{{userId}}">{{username}}</Username> has joined.',

‎packages/metastream-app/src/services/updater.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export class UpdateService extends EventEmitter {
1212
return updateService
1313
}
1414

15+
isUpdateAvailable: boolean = false
16+
1517
private constructor() {
1618
super()
1719
this.checkForUpdate = this.checkForUpdate.bind(this)
@@ -32,9 +34,9 @@ export class UpdateService extends EventEmitter {
3234

3335
if (!liveVersion) return
3436

35-
const isUpdateAvailable = VERSION !== liveVersion
37+
this.isUpdateAvailable = VERSION !== liveVersion
3638

37-
if (isUpdateAvailable) {
39+
if (this.isUpdateAvailable) {
3840
this.emit('update', liveVersion, VERSION)
3941
}
4042
}

0 commit comments

Comments
 (0)