Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
c6d893a7
Commit
c6d893a7
authored
8 years ago
by
Eugen Rochko
Browse files
Options
Downloads
Patches
Plain Diff
Uploading/undoing media modifies status text. Also: status text trimmed before validation
parent
b1a670af
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/assets/javascripts/components/reducers/compose.jsx
+29
-11
29 additions, 11 deletions
app/assets/javascripts/components/reducers/compose.jsx
app/controllers/media_controller.rb
+1
-1
1 addition, 1 deletion
app/controllers/media_controller.rb
app/models/status.rb
+4
-0
4 additions, 0 deletions
app/models/status.rb
with
34 additions
and
12 deletions
app/assets/javascripts/components/reducers/compose.jsx
+
29
−
11
View file @
c6d893a7
...
...
@@ -27,6 +27,32 @@ function statusToTextMentions(status) {
return
Immutable
.
OrderedSet
([
`@
${
status
.
getIn
([
'
account
'
,
'
acct
'
])}
`
]).
union
(
status
.
get
(
'
mentions
'
).
map
(
mention
=>
`@
${
mention
.
get
(
'
acct
'
)}
`
)).
join
(
''
);
};
function
clearAll
(
state
)
{
return
state
.
withMutations
(
map
=>
{
map
.
set
(
'
text
'
,
''
);
map
.
set
(
'
is_submitting
'
,
false
);
map
.
set
(
'
in_reply_to
'
,
null
);
map
.
update
(
'
media_attachments
'
,
list
=>
list
.
clear
());
});
};
function
appendMedia
(
state
,
media
)
{
return
state
.
withMutations
(
map
=>
{
map
.
update
(
'
media_attachments
'
,
list
=>
list
.
push
(
media
));
map
.
set
(
'
is_uploading
'
,
false
);
map
.
update
(
'
text
'
,
oldText
=>
`
${
oldText
}
${
media
.
get
(
'
text_url
'
)}
`
.
trim
());
});
};
function
removeMedia
(
state
,
mediaId
)
{
const
media
=
state
.
get
(
'
media_attachments
'
).
find
(
item
=>
item
.
get
(
'
id
'
)
===
mediaId
);
return
state
.
withMutations
(
map
=>
{
map
.
update
(
'
media_attachments
'
,
list
=>
list
.
filterNot
(
item
=>
item
.
get
(
'
id
'
)
===
mediaId
));
map
.
update
(
'
text
'
,
text
=>
text
.
replace
(
media
.
get
(
'
text_url
'
),
''
).
trim
());
});
};
export
default
function
compose
(
state
=
initialState
,
action
)
{
switch
(
action
.
type
)
{
case
COMPOSE_CHANGE
:
...
...
@@ -44,25 +70,17 @@ export default function compose(state = initialState, action) {
case
COMPOSE_SUBMIT_REQUEST
:
return
state
.
set
(
'
is_submitting
'
,
true
);
case
COMPOSE_SUBMIT_SUCCESS
:
return
state
.
withMutations
(
map
=>
{
map
.
set
(
'
text
'
,
''
);
map
.
set
(
'
is_submitting
'
,
false
);
map
.
set
(
'
in_reply_to
'
,
null
);
map
.
update
(
'
media_attachments
'
,
list
=>
list
.
clear
());
});
return
clearAll
(
state
);
case
COMPOSE_SUBMIT_FAIL
:
return
state
.
set
(
'
is_submitting
'
,
false
);
case
COMPOSE_UPLOAD_REQUEST
:
return
state
.
set
(
'
is_uploading
'
,
true
);
case
COMPOSE_UPLOAD_SUCCESS
:
return
state
.
withMutations
(
map
=>
{
map
.
update
(
'
media_attachments
'
,
list
=>
list
.
push
(
Immutable
.
fromJS
(
action
.
media
)));
map
.
set
(
'
is_uploading
'
,
false
);
});
return
appendMedia
(
state
,
Immutable
.
fromJS
(
action
.
media
));
case
COMPOSE_UPLOAD_FAIL
:
return
state
.
set
(
'
is_uploading
'
,
false
);
case
COMPOSE_UPLOAD_UNDO
:
return
state
.
update
(
'
media_attachments
'
,
list
=>
list
.
filterNot
(
item
=>
item
.
get
(
'
id
'
)
===
action
.
media_id
)
)
;
return
removeMedia
(
state
,
action
.
media_id
);
case
COMPOSE_UPLOAD_PROGRESS
:
return
state
.
set
(
'
progress
'
,
Math
.
round
((
action
.
loaded
/
action
.
total
)
*
100
));
case
TIMELINE_DELETE
:
...
...
This diff is collapsed.
Click to expand it.
app/controllers/media_controller.rb
+
1
−
1
View file @
c6d893a7
...
...
@@ -2,7 +2,7 @@ class MediaController < ApplicationController
before_action
:set_media_attachment
def
show
redirect
TagManager
.
instance
.
url_for
(
@media_attachment
.
status
)
redirect
_to
TagManager
.
instance
.
url_for
(
@media_attachment
.
status
)
end
private
...
...
This diff is collapsed.
Click to expand it.
app/models/status.rb
+
4
−
0
View file @
c6d893a7
...
...
@@ -89,4 +89,8 @@ class Status < ApplicationRecord
def
self
.
reblogs_map
(
status_ids
,
account_id
)
self
.
where
(
reblog_of_id:
status_ids
).
where
(
account_id:
account_id
).
map
{
|
s
|
[
s
.
reblog_of_id
,
true
]
}.
to_h
end
before_validation
do
self
.
text
.
strip!
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment