Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mastofe
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Haelwenn
mastofe
Commits
5e41c262
Commit
5e41c262
authored
May 28, 2017
by
Nolan Lawson
Committed by
Eugen Rochko
May 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use immutable list in UploadButton to avoid wasteful re-render (#3394)
parent
45837c53
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
app/javascript/mastodon/features/compose/components/upload_button.js
...ipt/mastodon/features/compose/components/upload_button.js
+6
-4
No files found.
app/javascript/mastodon/features/compose/components/upload_button.js
View file @
5e41c262
...
@@ -3,6 +3,8 @@ import IconButton from '../../../components/icon_button';
...
@@ -3,6 +3,8 @@ import IconButton from '../../../components/icon_button';
import
PropTypes
from
'
prop-types
'
;
import
PropTypes
from
'
prop-types
'
;
import
{
defineMessages
,
injectIntl
}
from
'
react-intl
'
;
import
{
defineMessages
,
injectIntl
}
from
'
react-intl
'
;
import
{
connect
}
from
'
react-redux
'
;
import
{
connect
}
from
'
react-redux
'
;
import
ImmutablePureComponent
from
'
react-immutable-pure-component
'
;
import
ImmutablePropTypes
from
'
react-immutable-proptypes
'
;
const
messages
=
defineMessages
({
const
messages
=
defineMessages
({
upload
:
{
id
:
'
upload_button.label
'
,
defaultMessage
:
'
Add media
'
},
upload
:
{
id
:
'
upload_button.label
'
,
defaultMessage
:
'
Add media
'
},
...
@@ -10,7 +12,7 @@ const messages = defineMessages({
...
@@ -10,7 +12,7 @@ const messages = defineMessages({
const
makeMapStateToProps
=
()
=>
{
const
makeMapStateToProps
=
()
=>
{
const
mapStateToProps
=
(
state
,
props
)
=>
({
const
mapStateToProps
=
(
state
,
props
)
=>
({
acceptContentTypes
:
state
.
getIn
([
'
media_attachments
'
,
'
accept_content_types
'
])
.
toArray
()
,
acceptContentTypes
:
state
.
getIn
([
'
media_attachments
'
,
'
accept_content_types
'
]),
});
});
return
mapStateToProps
;
return
mapStateToProps
;
...
@@ -21,14 +23,14 @@ const iconStyle = {
...
@@ -21,14 +23,14 @@ const iconStyle = {
lineHeight
:
'
27px
'
,
lineHeight
:
'
27px
'
,
};
};
class
UploadButton
extends
React
.
PureComponent
{
class
UploadButton
extends
Immutable
PureComponent
{
static
propTypes
=
{
static
propTypes
=
{
disabled
:
PropTypes
.
bool
,
disabled
:
PropTypes
.
bool
,
onSelectFile
:
PropTypes
.
func
.
isRequired
,
onSelectFile
:
PropTypes
.
func
.
isRequired
,
style
:
PropTypes
.
object
,
style
:
PropTypes
.
object
,
resetFileKey
:
PropTypes
.
number
,
resetFileKey
:
PropTypes
.
number
,
acceptContentTypes
:
PropTypes
.
array
Of
(
PropTypes
.
string
).
isRequired
,
acceptContentTypes
:
ImmutablePropTypes
.
list
Of
(
PropTypes
.
string
).
isRequired
,
intl
:
PropTypes
.
object
.
isRequired
,
intl
:
PropTypes
.
object
.
isRequired
,
};
};
...
@@ -58,7 +60,7 @@ class UploadButton extends React.PureComponent {
...
@@ -58,7 +60,7 @@ class UploadButton extends React.PureComponent {
ref
=
{
this
.
setRef
}
ref
=
{
this
.
setRef
}
type
=
'
file
'
type
=
'
file
'
multiple
=
{
false
}
multiple
=
{
false
}
accept
=
{
acceptContentTypes
.
join
(
'
,
'
)}
accept
=
{
acceptContentTypes
.
toArray
().
join
(
'
,
'
)}
onChange
=
{
this
.
handleChange
}
onChange
=
{
this
.
handleChange
}
disabled
=
{
disabled
}
disabled
=
{
disabled
}
style
=
{{
display
:
'
none
'
}}
style
=
{{
display
:
'
none
'
}}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment