11const remote = require ( '@electron/remote' )
2+ const { webUtils } = require ( 'electron' )
23const { app, dialog } = remote
34const html = require ( 'choo/html' )
45const Component = require ( 'nanocomponent' )
@@ -36,7 +37,7 @@ const styles = css`
3637`
3738
3839class Header extends Component {
39- constructor ( opts ) {
40+ constructor ( opts ) {
4041 super ( opts )
4142
4243 this . emit = null
@@ -52,12 +53,12 @@ class Header extends Component {
5253 this . searchComp = new Search ( )
5354 }
5455
55- handleSearch ( val ) {
56+ handleSearch ( val ) {
5657 this . search = val
5758 this . emit ( 'library:search' , val )
5859 }
5960
60- handleAddButton ( ) {
61+ handleAddButton ( ) {
6162 if ( ! this . dialogOpen ) {
6263 this . dialogOpen = true
6364 const paths = config . get ( 'paths' )
@@ -74,26 +75,27 @@ class Header extends Component {
7475 }
7576 }
7677
77- handlePaths ( { filePaths } ) {
78+ handlePaths ( { filePaths } ) {
7879 this . dialogOpen = false
7980 if ( Array . isArray ( filePaths ) && filePaths . length > 0 ) {
8081 this . emit ( 'config:set' , { filePaths } )
8182 this . emit ( 'library:update-library' , filePaths )
8283 }
8384 }
8485
85- handleNav ( ) {
86+ handleNav ( ) {
8687 this . emit ( 'pushState' , '#preferences' )
8788 }
8889
89- handleDrop ( event ) {
90+ handleDrop ( event ) {
9091 event . preventDefault ( )
9192 const { files } = event . dataTransfer
92- const paths = Array ( files . length ) . fill ( 0 ) . map ( ( _ , i ) => files . item ( i ) . path )
93+
94+ const paths = Array ( files . length ) . fill ( 0 ) . map ( ( _ , i ) => webUtils . getPathForFile ( files . item ( i ) ) )
9395 this . handlePaths ( { filePaths : paths } )
9496 }
9597
96- createElement ( state , emit ) {
98+ createElement ( state , emit ) {
9799 this . emit = emit
98100 this . search = state . library . search
99101 this . loading = state . library . loading
@@ -106,22 +108,22 @@ class Header extends Component {
106108 < header class ="${ styles . toolbar } ">
107109 < div class ="${ styles . toolbarLeft } ">
108110 ${ this . searchComp . render ( { /* eslint-disable indent */
109- onchange : this . handleSearch ,
110- value : this . search
111- } ) /* eslint-enable indent */ }
111+ onchange : this . handleSearch ,
112+ value : this . search
113+ } ) /* eslint-enable indent */ }
112114 </ div >
113115 < div class ="${ styles . toolbarRight } ">
114116 ${ button ( { /* eslint-disable indent */
115- className : this . loading ? styles . spin : null ,
116- onclick : this . handleAddButton ,
117- iconName : this . loading ? 'entypo-cog' : 'entypo-folder-music'
118- } ) /* eslint-enable indent */ }
117+ className : this . loading ? styles . spin : null ,
118+ onclick : this . handleAddButton ,
119+ iconName : this . loading ? 'entypo-cog' : 'entypo-folder-music'
120+ } ) /* eslint-enable indent */ }
119121 </ div >
120122 </ header >
121123 `
122124 }
123125
124- update ( state , emit ) {
126+ update ( state , emit ) {
125127 if ( this . search !== state . library . search ) return true
126128 if ( this . loading !== state . library . loading ) return true
127129 return false
0 commit comments