Skip to content
This repository has been archived by the owner on Aug 6, 2022. It is now read-only.

Commit

Permalink
Command+R to refresh albums
Browse files Browse the repository at this point in the history
  • Loading branch information
knoopx committed May 5, 2017
1 parent 508a10b commit 66a528d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/app/views/player-view/index.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// @flow

import React from 'react'
import mousetrap from 'mousetrap'
import PlayListView from './play-list-view'
import AlbumListView from './album-list-view'
import PlayerView from './player-view'
import EjectIcon from 'react-icons/lib/fa/eject'
import { autobind } from 'core-decorators'
import { inject, observer } from 'mobx-react'
import { View, Button, Gutter, Divider } from 'ui'
import { Toolbar } from 'app/components'
Expand All @@ -13,8 +15,23 @@ import OrderButtonGroup from './order-button-group'
import LightIcon from 'react-icons/lib/md/lightbulb-outline'

@inject('appState')
@inject('albumStore')
@autobind
@observer
export default class PlayerScreen extends React.Component {
componentWillMount() {
mousetrap.bind('command+r', this.refresh)
}

componentWillUnmount() {
mousetrap.unbind('command+r', this.refresh)
}

refresh(e) {
this.props.albumStore.fetch(true)
e.preventDefault()
}

render() {
const { appState } = this.props

Expand Down
4 changes: 2 additions & 2 deletions src/stores/album-store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export default class AlbumStore {
setItem(this.connection.device.clientIdentifier, this.albums.map(({ connection, ...props }) => props))
}

@action async fetch() {
this.setIsLoading(this.albums.length === 0)
@action async fetch(displaySpinner = this.albums.length === 0) {
this.setIsLoading(displaySpinner)
try {
this.setAlbums(await this.connection.albums.findAll())
} finally {
Expand Down

0 comments on commit 66a528d

Please sign in to comment.