Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Register
Sign in
Toggle navigation
Menu
Open sidebar
Tiger Ton
mastodon
Commits
dd512c14
Commit
dd512c14
authored
4 years ago
by
Eugen Rochko
Browse files
Options
Download
Email Patches
Plain Diff
WIP
parent
9c273c2a
Changes
81
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
app/controllers/account_follow_controller.rb
+0
-12
app/controllers/account_follow_controller.rb
app/controllers/account_unfollow_controller.rb
+0
-12
app/controllers/account_unfollow_controller.rb
app/controllers/accounts_controller.rb
+1
-23
app/controllers/accounts_controller.rb
app/controllers/api/v1/accounts/lookup_controller.rb
+16
-0
app/controllers/api/v1/accounts/lookup_controller.rb
app/controllers/authorize_interactions_controller.rb
+1
-1
app/controllers/authorize_interactions_controller.rb
app/controllers/concerns/account_controller_concern.rb
+0
-7
app/controllers/concerns/account_controller_concern.rb
app/controllers/concerns/web_app_controller_concern.rb
+18
-0
app/controllers/concerns/web_app_controller_concern.rb
app/controllers/directories_controller.rb
+3
-25
app/controllers/directories_controller.rb
app/controllers/follower_accounts_controller.rb
+5
-4
app/controllers/follower_accounts_controller.rb
app/controllers/following_accounts_controller.rb
+5
-4
app/controllers/following_accounts_controller.rb
app/controllers/home_controller.rb
+4
-39
app/controllers/home_controller.rb
app/controllers/public_timelines_controller.rb
+5
-13
app/controllers/public_timelines_controller.rb
app/controllers/statuses_controller.rb
+2
-16
app/controllers/statuses_controller.rb
app/controllers/tags_controller.rb
+2
-13
app/controllers/tags_controller.rb
app/helpers/application_helper.rb
+5
-9
app/helpers/application_helper.rb
app/javascript/mastodon/actions/accounts.js
+32
-0
app/javascript/mastodon/actions/accounts.js
app/javascript/mastodon/actions/compose.js
+2
-2
app/javascript/mastodon/actions/compose.js
app/javascript/mastodon/components/account.js
+1
-1
app/javascript/mastodon/components/account.js
app/javascript/mastodon/components/hashtag.js
+1
-1
app/javascript/mastodon/components/hashtag.js
app/javascript/mastodon/components/status.js
+35
-29
app/javascript/mastodon/components/status.js
with
138 additions
and
211 deletions
+138
-211
app/controllers/account_follow_controller.rb
deleted
100644 → 0
+
0
-
12
View file @
9c273c2a
# frozen_string_literal: true
class
AccountFollowController
<
ApplicationController
include
AccountControllerConcern
before_action
:authenticate_user!
def
create
FollowService
.
new
.
call
(
current_user
.
account
,
@account
,
with_rate_limit:
true
)
redirect_to
account_path
(
@account
)
end
end
This diff is collapsed.
Click to expand it.
app/controllers/account_unfollow_controller.rb
deleted
100644 → 0
+
0
-
12
View file @
9c273c2a
# frozen_string_literal: true
class
AccountUnfollowController
<
ApplicationController
include
AccountControllerConcern
before_action
:authenticate_user!
def
create
UnfollowService
.
new
.
call
(
current_user
.
account
,
@account
)
redirect_to
account_path
(
@account
)
end
end
This diff is collapsed.
Click to expand it.
app/controllers/accounts_controller.rb
+
1
-
23
View file @
dd512c14
...
...
@@ -5,11 +5,11 @@ class AccountsController < ApplicationController
PAGE_SIZE_MAX
=
200
include
AccountControllerConcern
include
WebAppControllerConcern
include
SignatureAuthentication
before_action
:require_signature!
,
if:
->
{
request
.
format
==
:json
&&
authorized_fetch_mode?
}
before_action
:set_cache_headers
before_action
:set_body_classes
skip_around_action
:set_locale
,
if:
->
{
[
:json
,
:rss
].
include?
(
request
.
format
&
.
to_sym
)
}
skip_before_action
:require_functional!
,
unless: :whitelist_mode?
...
...
@@ -18,24 +18,6 @@ class AccountsController < ApplicationController
respond_to
do
|
format
|
format
.
html
do
expires_in
0
,
public:
true
unless
user_signed_in?
@pinned_statuses
=
[]
@endorsed_accounts
=
@account
.
endorsed_accounts
.
to_a
.
sample
(
4
)
@featured_hashtags
=
@account
.
featured_tags
.
order
(
statuses_count: :desc
)
if
current_account
&&
@account
.
blocking?
(
current_account
)
@statuses
=
[]
return
end
@pinned_statuses
=
cache_collection
(
@account
.
pinned_statuses
,
Status
)
if
show_pinned_statuses?
@statuses
=
cached_filtered_status_page
@rss_url
=
rss_url
unless
@statuses
.
empty?
@older_url
=
older_url
if
@statuses
.
last
.
id
>
filtered_statuses
.
last
.
id
@newer_url
=
newer_url
if
@statuses
.
first
.
id
<
filtered_statuses
.
first
.
id
end
end
format
.
rss
do
...
...
@@ -56,10 +38,6 @@ class AccountsController < ApplicationController
private
def
set_body_classes
@body_classes
=
'with-modals'
end
def
show_pinned_statuses?
[
replies_requested?
,
media_requested?
,
tag_requested?
,
params
[
:max_id
].
present?
,
params
[
:min_id
].
present?
].
none?
end
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/accounts/lookup_controller.rb
0 → 100644
+
16
-
0
View file @
dd512c14
# frozen_string_literal: true
class
Api::V1::Accounts::LookupController
<
Api
::
BaseController
before_action
->
{
authorize_if_got_token!
:read
,
:'read:accounts'
}
before_action
:set_account
def
show
render
json:
@account
,
serializer:
REST
::
AccountSerializer
end
private
def
set_account
@account
=
ResolveAccountService
.
new
.
call
(
params
[
:acct
],
skip_webfinger:
true
)
||
raise
(
ActiveRecord
::
RecordNotFound
)
end
end
This diff is collapsed.
Click to expand it.
app/controllers/authorize_interactions_controller.rb
+
1
-
1
View file @
dd512c14
...
...
@@ -13,7 +13,7 @@ class AuthorizeInteractionsController < ApplicationController
if
@resource
.
is_a?
(
Account
)
render
:show
elsif
@resource
.
is_a?
(
Status
)
redirect_to
web_url
(
"statuses/
#{
@resource
.
id
}
"
)
redirect_to
short_account_status_path
(
@resource
.
account
.
acct
,
@resource
.
id
)
else
render
:error
end
...
...
This diff is collapsed.
Click to expand it.
app/controllers/concerns/account_controller_concern.rb
+
0
-
7
View file @
dd512c14
...
...
@@ -8,18 +8,11 @@ module AccountControllerConcern
FOLLOW_PER_PAGE
=
12
included
do
layout
'public'
before_action
:set_instance_presenter
before_action
:set_link_headers
,
if:
->
{
request
.
format
.
nil?
||
request
.
format
==
:html
}
end
private
def
set_instance_presenter
@instance_presenter
=
InstancePresenter
.
new
end
def
set_link_headers
response
.
headers
[
'Link'
]
=
LinkHeader
.
new
(
[
...
...
This diff is collapsed.
Click to expand it.
app/controllers/concerns/web_app_controller_concern.rb
0 → 100644
+
18
-
0
View file @
dd512c14
# frozen_string_literal: true
module
WebAppControllerConcern
extend
ActiveSupport
::
Concern
included
do
before_action
:set_body_classes
before_action
:set_referrer_policy_header
end
def
set_body_classes
@body_classes
=
'app-body'
end
def
set_referrer_policy_header
response
.
headers
[
'Referrer-Policy'
]
=
'origin'
end
end
This diff is collapsed.
Click to expand it.
app/controllers/directories_controller.rb
+
3
-
25
View file @
dd512c14
# frozen_string_literal: true
class
DirectoriesController
<
ApplicationController
layout
'public'
include
WebAppControllerConcern
before_action
:authenticate_user!
,
if: :whitelist_mode?
before_action
:require_enabled!
before_action
:set_instance_presenter
before_action
:set_tag
,
only: :show
before_action
:set_accounts
skip_before_action
:require_functional!
,
unless: :whitelist_mode?
def
index
render
:index
end
def
show
render
:index
expires_in
0
,
public:
true
if
current_account
.
nil?
end
private
def
require_enabled!
return
not_found
unless
Setting
.
profile_directory
end
def
set_tag
@tag
=
Tag
.
discoverable
.
find_normalized!
(
params
[
:id
])
end
def
set_accounts
@accounts
=
Account
.
local
.
discoverable
.
by_recent_status
.
page
(
params
[
:page
]).
per
(
20
).
tap
do
|
query
|
query
.
merge!
(
Account
.
tagged_with
(
@tag
.
id
))
if
@tag
query
.
merge!
(
Account
.
not_excluded_by_account
(
current_account
))
if
current_account
end
end
def
set_instance_presenter
@instance_presenter
=
InstancePresenter
.
new
not_found
unless
Setting
.
profile_directory
end
end
This diff is collapsed.
Click to expand it.
app/controllers/follower_accounts_controller.rb
+
5
-
4
View file @
dd512c14
...
...
@@ -2,6 +2,7 @@
class
FollowerAccountsController
<
ApplicationController
include
AccountControllerConcern
include
WebAppControllerConcern
include
SignatureVerification
before_action
:require_signature!
,
if:
->
{
request
.
format
==
:json
&&
authorized_fetch_mode?
}
...
...
@@ -14,10 +15,6 @@ class FollowerAccountsController < ApplicationController
respond_to
do
|
format
|
format
.
html
do
expires_in
0
,
public:
true
unless
user_signed_in?
next
if
@account
.
user_hides_network?
follows
end
format
.
json
do
...
...
@@ -36,6 +33,10 @@ class FollowerAccountsController < ApplicationController
private
def
username_param
params
[
:username
]
||
params
[
:account_username
]
end
def
follows
return
@follows
if
defined?
(
@follows
)
...
...
This diff is collapsed.
Click to expand it.
app/controllers/following_accounts_controller.rb
+
5
-
4
View file @
dd512c14
...
...
@@ -2,6 +2,7 @@
class
FollowingAccountsController
<
ApplicationController
include
AccountControllerConcern
include
WebAppControllerConcern
include
SignatureVerification
before_action
:require_signature!
,
if:
->
{
request
.
format
==
:json
&&
authorized_fetch_mode?
}
...
...
@@ -14,10 +15,6 @@ class FollowingAccountsController < ApplicationController
respond_to
do
|
format
|
format
.
html
do
expires_in
0
,
public:
true
unless
user_signed_in?
next
if
@account
.
user_hides_network?
follows
end
format
.
json
do
...
...
@@ -36,6 +33,10 @@ class FollowingAccountsController < ApplicationController
private
def
username_param
params
[
:username
]
||
params
[
:account_username
]
end
def
follows
return
@follows
if
defined?
(
@follows
)
...
...
This diff is collapsed.
Click to expand it.
app/controllers/home_controller.rb
+
4
-
39
View file @
dd512c14
# frozen_string_literal: true
class
HomeController
<
ApplicationController
before_action
:redirect_unauthenticated_to_permalinks!
before_action
:authenticate_user!
before_action
:set_referrer_policy_header
def
index
@body_classes
=
'app-body'
end
private
def
redirect_unauthenticated_to_permalinks!
return
if
user_signed_in?
include
WebAppControllerConcern
matches
=
request
.
path
.
match
(
/\A\/web\/(statuses|accounts)\/([\d]+)\z/
)
def
index
;
end
if
matches
case
matches
[
1
]
when
'statuses'
status
=
Status
.
find_by
(
id:
matches
[
2
])
if
status
&
.
distributable?
redirect_to
(
ActivityPub
::
TagManager
.
instance
.
url_for
(
status
))
return
end
when
'accounts'
account
=
Account
.
find_by
(
id:
matches
[
2
])
if
account
redirect_to
(
ActivityPub
::
TagManager
.
instance
.
url_for
(
account
))
return
end
end
end
matches
=
request
.
path
.
match
(
%r{
\A
/web/timelines/tag/(?<tag>.+)
\z
}
)
redirect_to
(
matches
?
tag_path
(
CGI
.
unescape
(
matches
[
:tag
]))
:
default_redirect_path
)
end
private
def
default_redirect_path
if
request
.
path
.
start_with?
(
'/web'
)
||
whitelist_mode?
if
whitelist_mode?
new_user_session_path
elsif
single_user_mode?
short_account_path
(
Account
.
local
.
without_suspended
.
where
(
'id > 0'
).
first
)
...
...
@@ -49,8 +18,4 @@ class HomeController < ApplicationController
about_path
end
end
def
set_referrer_policy_header
response
.
headers
[
'Referrer-Policy'
]
=
'origin'
end
end
This diff is collapsed.
Click to expand it.
app/controllers/public_timelines_controller.rb
+
5
-
13
View file @
dd512c14
# frozen_string_literal: true
class
PublicTimelinesController
<
ApplicationController
layout
'public'
include
WebAppControllerConcern
before_action
:authenticate_user!
,
if: :whitelist_mode?
before_action
:require_enabled!
before_action
:set_body_classes
before_action
:set_instance_presenter
def
show
;
end
def
show
expires_in
0
,
public:
true
if
current_account
.
nil?
end
private
def
require_enabled!
not_found
unless
Setting
.
timeline_preview
end
def
set_body_classes
@body_classes
=
'with-modals'
end
def
set_instance_presenter
@instance_presenter
=
InstancePresenter
.
new
not_found
unless
user_signed_in?
||
Setting
.
timeline_preview
end
end
This diff is collapsed.
Click to expand it.
app/controllers/statuses_controller.rb
+
2
-
16
View file @
dd512c14
# frozen_string_literal: true
class
StatusesController
<
ApplicationController
include
StatusControllerConcern
include
SignatureAuthentication
include
Authorization
include
AccountOwnedConcern
layout
'public'
include
WebAppControllerConcern
before_action
:require_signature!
,
only:
[
:show
,
:activity
],
if:
->
{
request
.
format
==
:json
&&
authorized_fetch_mode?
}
before_action
:set_status
before_action
:set_instance_presenter
before_action
:set_link_headers
before_action
:redirect_to_original
,
only: :show
before_action
:set_referrer_policy_header
,
only: :show
before_action
:set_cache_headers
before_action
:set_body_classes
before_action
:set_autoplay
,
only: :embed
skip_around_action
:set_locale
,
if:
->
{
request
.
format
==
:json
}
...
...
@@ -29,8 +25,6 @@ class StatusesController < ApplicationController
respond_to
do
|
format
|
format
.
html
do
expires_in
10
.
seconds
,
public:
true
if
current_account
.
nil?
set_ancestors
set_descendants
end
format
.
json
do
...
...
@@ -56,10 +50,6 @@ class StatusesController < ApplicationController
private
def
set_body_classes
@body_classes
=
'with-modals'
end
def
set_link_headers
response
.
headers
[
'Link'
]
=
LinkHeader
.
new
([[
ActivityPub
::
TagManager
.
instance
.
uri_for
(
@status
),
[
%w(rel alternate)
,
%w(type application/activity+json)
]]])
end
...
...
@@ -71,16 +61,12 @@ class StatusesController < ApplicationController
not_found
end
def
set_instance_presenter
@instance_presenter
=
InstancePresenter
.
new
end
def
redirect_to_original
redirect_to
ActivityPub
::
TagManager
.
instance
.
url_for
(
@status
.
reblog
)
if
@status
.
reblog?
end
def
set_referrer_policy_header
response
.
headers
[
'Referrer-Policy'
]
=
'origin'
unless
@status
.
distributable?
response
.
headers
[
'Referrer-Policy'
]
=
'origin'
end
def
set_autoplay
...
...
This diff is collapsed.
Click to expand it.
app/controllers/tags_controller.rb
+
2
-
13
View file @
dd512c14
...
...
@@ -2,26 +2,23 @@
class
TagsController
<
ApplicationController
include
SignatureVerification
include
WebAppControllerConcern
PAGE_SIZE
=
20
PAGE_SIZE_MAX
=
200
layout
'public'
before_action
:require_signature!
,
if:
->
{
request
.
format
==
:json
&&
authorized_fetch_mode?
}
before_action
:authenticate_user!
,
if: :whitelist_mode?
before_action
:set_local
before_action
:set_tag
before_action
:set_statuses
before_action
:set_body_classes
before_action
:set_instance_presenter
skip_before_action
:require_functional!
,
unless: :whitelist_mode?
def
show
respond_to
do
|
format
|
format
.
html
do
expires_in
0
,
public:
true
expires_in
0
,
public:
true
if
current_account
.
nil?
end
format
.
rss
do
...
...
@@ -55,14 +52,6 @@ class TagsController < ApplicationController
end
end
def
set_body_classes
@body_classes
=
'with-modals'
end
def
set_instance_presenter
@instance_presenter
=
InstancePresenter
.
new
end
def
limit_param
params
[
:limit
].
present?
?
[
params
[
:limit
].
to_i
,
PAGE_SIZE_MAX
].
min
:
PAGE_SIZE
end
...
...
This diff is collapsed.
Click to expand it.
app/helpers/application_helper.rb
+
5
-
9
View file @
dd512c14
...
...
@@ -158,19 +158,15 @@ module ApplicationHelper
def
render_initial_state
state_params
=
{
settings:
{
known_fediverse:
Setting
.
show_known_fediverse_at_about_page
,
},
text:
[
params
[
:title
],
params
[
:text
],
params
[
:url
]].
compact
.
join
(
' '
),
}
permit_visibilities
=
%w(public unlisted private direct)
default_privacy
=
current_account
&
.
user
&
.
setting_default_privacy
permit_visibilities
.
shift
(
permit_visibilities
.
index
(
default_privacy
)
+
1
)
if
default_privacy
.
present?
state_params
[
:visibility
]
=
params
[
:visibility
]
if
permit_visibilities
.
include?
params
[
:visibility
]
if
user_signed_in?
permit_visibilities
=
%w(public unlisted private direct)
default_privacy
=
current_account
&
.
user
&
.
setting_default_privacy
permit_visibilities
.
shift
(
permit_visibilities
.
index
(
default_privacy
)
+
1
)
if
default_privacy
.
present?
state_params
[
:visibility
]
=
params
[
:visibility
]
if
permit_visibilities
.
include?
params
[
:visibility
]
state_params
[
:settings
]
=
state_params
[
:settings
].
merge
(
Web
::
Setting
.
find_by
(
user:
current_user
)
&
.
data
||
{})
state_params
[
:push_subscription
]
=
current_account
.
user
.
web_push_subscription
(
current_session
)
state_params
[
:current_account
]
=
current_account
...
...
This diff is collapsed.
Click to expand it.
app/javascript/mastodon/actions/accounts.js
+
32
-
0
View file @
dd512c14
...
...
@@ -5,6 +5,10 @@ export const ACCOUNT_FETCH_REQUEST = 'ACCOUNT_FETCH_REQUEST';
export
const
ACCOUNT_FETCH_SUCCESS
=
'
ACCOUNT_FETCH_SUCCESS
'
;
export
const
ACCOUNT_FETCH_FAIL
=
'
ACCOUNT_FETCH_FAIL
'
;
export
const
ACCOUNT_LOOKUP_REQUEST
=
'
ACCOUNT_LOOKUP_REQUEST
'
;
export
const
ACCOUNT_LOOKUP_SUCCESS
=
'
ACCOUNT_LOOKUP_SUCCESS
'
;
export
const
ACCOUNT_LOOKUP_FAIL
=
'
ACCOUNT_LOOKUP_FAIL
'
;
export
const
ACCOUNT_FOLLOW_REQUEST
=
'
ACCOUNT_FOLLOW_REQUEST
'
;
export
const
ACCOUNT_FOLLOW_SUCCESS
=
'
ACCOUNT_FOLLOW_SUCCESS
'
;
export
const
ACCOUNT_FOLLOW_FAIL
=
'
ACCOUNT_FOLLOW_FAIL
'
;
...
...
@@ -87,6 +91,34 @@ export function fetchAccount(id) {
};
};
export
const
lookupAccount
=
acct
=>
(
dispatch
,
getState
)
=>
{
dispatch
(
lookupAccountRequest
(
acct
));
api
(
getState
).
get
(
'
/api/v1/accounts/lookup
'
,
{
params
:
{
acct
}
}).
then
(
response
=>
{
dispatch
(
fetchRelationships
([
response
.
data
.
id
]));
dispatch
(
importFetchedAccount
(
response
.
data
));
dispatch
(
lookupAccountSuccess
());
}).
catch
(
error
=>
{
dispatch
(
lookupAccountFail
(
acct
,
error
));
});
};
export
const
lookupAccountRequest
=
(
acct
)
=>
({
type
:
ACCOUNT_LOOKUP_REQUEST
,
acct
,
});
export
const
lookupAccountSuccess
=
()
=>
({
type
:
ACCOUNT_LOOKUP_SUCCESS
,
});
export
const
lookupAccountFail
=
(
acct
,
error
)
=>
({
type
:
ACCOUNT_LOOKUP_FAIL
,
acct
,
error
,
skipAlert
:
true
,
});
export
function
fetchAccountRequest
(
id
)
{
return
{
type
:
ACCOUNT_FETCH_REQUEST
,
...
...
This diff is collapsed.
Click to expand it.
app/javascript/mastodon/actions/compose.js
+
2
-
2
View file @
dd512c14
...
...
@@ -72,7 +72,7 @@ const COMPOSE_PANEL_BREAKPOINT = 600 + (285 * 1) + (10 * 1);
export
const
ensureComposeIsVisible
=
(
getState
,
routerHistory
)
=>
{
if
(
!
getState
().
getIn
([
'
compose
'
,
'
mounted
'
])
&&
window
.
innerWidth
<
COMPOSE_PANEL_BREAKPOINT
)
{
routerHistory
.
push
(
'
/
statuses/new
'
);
routerHistory
.
push
(
'
/
publish
'
);
}
};
...
...
@@ -152,7 +152,7 @@ export function submitCompose(routerHistory) {
'
Idempotency-Key
'
:
getState
().
getIn
([
'
compose
'
,
'
idempotencyKey
'
]),
},
}).
then
(
function
(
response
)
{
if
(
routerHistory
&&
routerHistory
.
location
.
pathname
===
'
/
statuses/new
'
&&
window
.
history
.
state
)
{
if
(
routerHistory
&&
routerHistory
.
location
.
pathname
===
'
/
publish
'
&&
window
.
history
.
state
)
{
routerHistory
.
goBack
();
}
...
...
This diff is collapsed.
Click to expand it.
app/javascript/mastodon/components/account.js
+
1
-
1
View file @
dd512c14
...
...
@@ -116,7 +116,7 @@ class Account extends ImmutablePureComponent {
return
(
<
div
className
=
'
account
'
>
<
div
className
=
'
account__wrapper
'
>
<
Permalink
key
=
{
account
.
get
(
'
id
'
)}
className
=
'
account__display-name
'
title
=
{
account
.
get
(
'
acct
'
)}
href
=
{
account
.
get
(
'
url
'
)}
to
=
{
`/
accounts/
${
account
.
get
(
'
id
'
)}
`
}
>
<
Permalink
key
=
{
account
.
get
(
'
id
'
)}
className
=
'
account__display-name
'
title
=
{
account
.
get
(
'
acct
'
)}
href
=
{
account
.
get
(
'
url
'
)}
to
=
{
`/
@
${
account
.
get
(
'
acct
'
)}
`
}
>
<
div
className
=
'
account__avatar-wrapper
'
><
Avatar
account
=
{
account
}
size
=
{
36
}
/></
div
>
{
mute_expires_at
}
<
DisplayName
account
=
{
account
}
/
>
...
...
This diff is collapsed.
Click to expand it.
app/javascript/mastodon/components/hashtag.js
+
1
-
1
View file @
dd512c14
...
...
@@ -27,7 +27,7 @@ const Hashtag = ({ hashtag }) => (
<
div
className
=
'
trends__item__name
'
>
<
Permalink
href
=
{
hashtag
.
get
(
'
url
'
)}
to
=
{
`/
timelines/
tag/
${
hashtag
.
get
(
'
name
'
)}
`
}
to
=
{
`/tag
s
/
${
hashtag
.
get
(
'
name
'
)}
`
}
>
#
<
span
>
{
hashtag
.
get
(
'
name
'
)}
<
/span
>
<
/Permalink
>
...
...
This diff is collapsed.
Click to expand it.
app/javascript/mastodon/components/status.js
+
35
-
29
View file @
dd512c14
...
...
@@ -134,42 +134,28 @@ class Status extends ImmutablePureComponent {
this
.
setState
({
showMedia
:
!
this
.
state
.
showMedia
});
}
handleClick
=
()
=>
{
if
(
this
.
props
.
onClick
)
{
this
.
props
.
onClick
();
handleClick
=
e
=>
{
if
(
e
&&
(
e
.
button
!==
0
||
e
.
ctrlKey
||
e
.
metaKey
))
{
return
;
}
if
(
!
this
.
context
.
router
)
{
return
;
if
(
e
)
{
e
.
preventDefault
()
;
}
const
{
status
}
=
this
.
props
;
this
.
context
.
router
.
history
.
push
(
`/statuses/
${
status
.
getIn
([
'
reblog
'
,
'
id
'
],
status
.
get
(
'
id
'
))}
`
);
this
.
handleHotkeyOpen
();
}
handleExpandClick
=
(
e
)
=>
{
if
(
this
.
props
.
onClick
)
{
this
.
props
.
onClick
();
handleAccountClick
=
e
=>
{
if
(
e
&&
(
e
.
button
!==
0
||
e
.
ctrlKey
||
e
.
metaKey
))
{
return
;
}
if
(
e
.
button
===
0
)
{
if
(
!
this
.
context
.
router
)
{
return
;
}
const
{
status
}
=
this
.
props
;
this
.
context
.
router
.
history
.
push
(
`/statuses/
${
status
.
getIn
([
'
reblog
'
,
'
id
'
],
status
.
get
(
'
id
'
))}
`
);
}
}
handleAccountClick
=
(
e
)
=>
{
if
(
this
.
context
.
router
&&
e
.
button
===
0
&&
!
(
e
.
ctrlKey
||
e
.
metaKey
))
{
const
id
=
e
.
currentTarget
.
getAttribute
(
'
data-id
'
);
if
(
e
)
{
e
.
preventDefault
();
this
.
context
.
router
.
history
.
push
(
`/accounts/
${
id
}
`
);
}
this
.
handleHotkeyOpenProfile
();
}
handleExpandedToggle
=
()
=>
{
...
...
@@ -242,11 +228,30 @@ class Status extends ImmutablePureComponent {
}
handleHotkeyOpen
=
()
=>
{
this
.
context
.
router
.
history
.
push
(
`/statuses/
${
this
.
_properStatus
().
get
(
'
id
'
)}
`
);
if
(
this
.
props
.
onClick
)
{
this
.
props
.
onClick
();
return
;
}
const
{
router
}
=
this
.
context
;
const
status
=
this
.
_properStatus
();
if
(
!
router
)
{
return
;
}
router
.
history
.
push
(
`/@
${
status
.
getIn
([
'
account
'
,
'
acct
'
])}
/
${
status
.
get
(
'
id
'
)}
`
);
}
handleHotkeyOpenProfile
=
()
=>
{
this
.
context
.
router
.
history
.
push
(
`/accounts/
${
this
.
_properStatus
().
getIn
([
'
account
'
,
'
id
'
])}
`
);
const
{
router
}
=
this
.
context
;
const
status
=
this
.
_properStatus
();
if
(
!
router
)
{
return
;
}
router
.
history
.
push
(
`/@
${
status
.
getIn
([
'
account
'
,
'
acct
'
])}
`
);
}
handleHotkeyMoveUp
=
e
=>
{
...
...
@@ -465,14 +470,15 @@ class Status extends ImmutablePureComponent {
{
prepend
}
<
div
className
=
{
classNames
(
'
status
'
,
`status-
${
status
.
get
(
'
visibility
'
)}
`
,
{
'
status-reply
'
:
!!
status
.
get
(
'
in_reply_to_id
'
),
muted
:
this
.
props
.
muted
})}
data
-
id
=
{
status
.
get
(
'
id
'
)}
>
<
div
className
=
'
status__expand
'
onClick
=
{
this
.
handleExpandClick
}
role
=
'
presentation
'
/>
<
div
className
=
'
status__expand
'
onClick
=
{
this
.
handleClick
}
role
=
'
presentation
'
/>
<
div
className
=
'
status__info
'
>
<
a
href
=
{
status
.
get
(
'
url
'
)}
className
=
'
status__relative-time
'
target
=
'
_blank
'
rel
=
'
noopener noreferrer
'
>
<
a
onClick
=
{
this
.
handleClick
}
href
=
{
status
.
get
(
'
url
'
)}
className
=
'
status__relative-time
'
target
=
'
_blank
'
rel
=
'
noopener noreferrer
'
>
<
span
className
=
'
status__visibility-icon
'
><
Icon
id
=
{
visibilityIcon
.
icon
}
title
=
{
visibilityIcon
.
text
}
/></
span
>
<
RelativeTimestamp
timestamp
=
{
status
.
get
(
'
created_at
'
)}
/
>
<
/a
>
<
a
onClick
=
{
this
.
handleAccountClick
}
data
-
id
=
{
status
.
getIn
([
'
account
'
,
'
id
'
])}
href
=
{
status
.
getIn
([
'
account
'
,
'
url
'
])}
title
=
{
status
.
getIn
([
'
account
'
,
'
acct
'
])}
className
=
'
status__display-name
'
target
=
'
_blank
'
rel
=
'
noopener noreferrer
'
>
<
a
onClick
=
{
this
.
handleAccountClick
}
href
=
{
status
.
getIn
([
'
account
'
,
'
url
'
])}
title
=
{
status
.
getIn
([
'
account
'
,
'
acct
'
])}
className
=
'
status__display-name
'
target
=
'
_blank
'
rel
=
'
noopener noreferrer
'
>
<
div
className
=
'
status__avatar
'
>
{
statusAvatar
}
<
/div
>
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
3
4
5
Next
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets