diff --git a/.gitignore b/.gitignore index 4545270b3..8b7cb2eaa 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,11 @@ yarn-debug.log # Ignore Docker option files docker-compose.override.yml + + +/public/packs +/public/packs-test +/node_modules +/yarn-error.log +yarn-debug.log* +.yarn-integrity diff --git a/.nope_browserlistrc b/.nope_browserlistrc new file mode 100644 index 000000000..e94f8140c --- /dev/null +++ b/.nope_browserlistrc @@ -0,0 +1 @@ +defaults diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d749c255..9aa7447a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ Changelog All notable changes to this project will be documented in this file. -## [3.3.0] - 2020-12-27 +## Unreleased ### Added - **Add hotkeys for audio/video control in web UI** ([Gargron](https://github.com/tootsuite/mastodon/pull/15158), [Gargron](https://github.com/tootsuite/mastodon/pull/15198)) @@ -81,11 +81,11 @@ All notable changes to this project will be documented in this file. ### Changed -- **Change media modals look in web UI** ([Gargron](https://github.com/tootsuite/mastodon/pull/15217), [Gargron](https://github.com/tootsuite/mastodon/pull/15221), [Gargron](https://github.com/tootsuite/mastodon/pull/15284), [Gargron](https://github.com/tootsuite/mastodon/pull/15283), [Kjwon15](https://github.com/tootsuite/mastodon/pull/15308), [noellabo](https://github.com/tootsuite/mastodon/pull/15305), [ThibG](https://github.com/tootsuite/mastodon/pull/15417)) +- **Change media modals look in web UI** ([Gargron](https://github.com/tootsuite/mastodon/pull/15217), [Gargron](https://github.com/tootsuite/mastodon/pull/15221), [Gargron](https://github.com/tootsuite/mastodon/pull/15284), [Gargron](https://github.com/tootsuite/mastodon/pull/15283), [Kjwon15](https://github.com/tootsuite/mastodon/pull/15308), [noellabo](https://github.com/tootsuite/mastodon/pull/15305)) - Background of the overlay matches the color of the image - Action bar to interact with or open the toot from the modal - Change order of announcements in admin UI to be newest-first ([ThibG](https://github.com/tootsuite/mastodon/pull/15091)) -- **Change account suspensions to be reversible by default** ([Gargron](https://github.com/tootsuite/mastodon/pull/14726), [ThibG](https://github.com/tootsuite/mastodon/pull/15152), [ThibG](https://github.com/tootsuite/mastodon/pull/15106), [ThibG](https://github.com/tootsuite/mastodon/pull/15100), [ThibG](https://github.com/tootsuite/mastodon/pull/15099), [noellabo](https://github.com/tootsuite/mastodon/pull/14855), [ThibG](https://github.com/tootsuite/mastodon/pull/15380), [Gargron](https://github.com/tootsuite/mastodon/pull/15420), [Gargron](https://github.com/tootsuite/mastodon/pull/15414)) +- **Change account suspensions to be reversible by default** ([Gargron](https://github.com/tootsuite/mastodon/pull/14726), [ThibG](https://github.com/tootsuite/mastodon/pull/15152), [ThibG](https://github.com/tootsuite/mastodon/pull/15106), [ThibG](https://github.com/tootsuite/mastodon/pull/15100), [ThibG](https://github.com/tootsuite/mastodon/pull/15099), [noellabo](https://github.com/tootsuite/mastodon/pull/14855), [ThibG](https://github.com/tootsuite/mastodon/pull/15380)) - Suspensions no longer equal deletions - A suspended account can be unsuspended with minimal consequences for 30 days - Immediate deletion of data is still available as an explicit option @@ -123,7 +123,7 @@ All notable changes to this project will be documented in this file. ### Fixed - Fix layout on about page when contact account has a long username ([ThibG](https://github.com/tootsuite/mastodon/pull/15357)) -- Fix follow limit preventing re-following of a moved account ([Gargron](https://github.com/tootsuite/mastodon/pull/14207), [ThibG](https://github.com/tootsuite/mastodon/pull/15384)) +- Fix follow limit preventing re-following of a moved account ([Gargron](https://github.com/tootsuite/mastodon/pull/14207)) - **Fix deletes not reaching every server that interacted with toot** ([Gargron](https://github.com/tootsuite/mastodon/pull/15200)) - Previously, delete of a toot would be primarily sent to the followers of its author, people mentioned in the toot, and people who reblogged the toot - Now, additionally, it is ensured that it is sent to people who replied to it, favourited it, and to the person it replies to even if that person is not mentioned @@ -163,7 +163,7 @@ All notable changes to this project will be documented in this file. - Fix inefficiency when fetching bookmarks ([akihikodaki](https://github.com/tootsuite/mastodon/pull/14674)) - Fix inefficiency when fetching favourites ([akihikodaki](https://github.com/tootsuite/mastodon/pull/14673)) - Fix inefficiency when fetching media-only account timeline ([akihikodaki](https://github.com/tootsuite/mastodon/pull/14675)) -- Fix inefficieny when deleting accounts ([Gargron](https://github.com/tootsuite/mastodon/pull/15387), [ThibG](https://github.com/tootsuite/mastodon/pull/15409), [ThibG](https://github.com/tootsuite/mastodon/pull/15407), [ThibG](https://github.com/tootsuite/mastodon/pull/15408), [ThibG](https://github.com/tootsuite/mastodon/pull/15402), [ThibG](https://github.com/tootsuite/mastodon/pull/15416), [Gargron](https://github.com/tootsuite/mastodon/pull/15421)) +- Fix inefficieny when deleting accounts ([Gargron](https://github.com/tootsuite/mastodon/pull/15387), [ThibG](https://github.com/tootsuite/mastodon/pull/15409), [ThibG](https://github.com/tootsuite/mastodon/pull/15407), [ThibG](https://github.com/tootsuite/mastodon/pull/15408), [ThibG](https://github.com/tootsuite/mastodon/pull/15402)) - Fix redundant query when processing batch actions on custom emojis ([niwatori24](https://github.com/tootsuite/mastodon/pull/14534)) - Fix slow distinct queries where grouped queries are faster ([Gargron](https://github.com/tootsuite/mastodon/pull/15287)) - Fix performance on instances list in admin UI ([Gargron](https://github.com/tootsuite/mastodon/pull/15282)) @@ -387,14 +387,21 @@ All notable changes to this project will be documented in this file. - Only then proceed to start removing their data (slow) - Clear out media attachments in a separate worker (slow) -## [3.1.5] - 2020-07-07 +## [v3.1.5] - 2020-07-07 ### Security - Fix media attachment enumeration ([ThibG](https://github.com/tootsuite/mastodon/pull/14254)) - Change rate limits for various paths ([Gargron](https://github.com/tootsuite/mastodon/pull/14253)) - Fix other sessions not being logged out on password change ([Gargron](https://github.com/tootsuite/mastodon/pull/14252)) -## [3.1.4] - 2020-05-14 +## [v3.1.5] - 2020-07-07 +### Security + +- Fix media attachment enumeration ([ThibG](https://github.com/tootsuite/mastodon/pull/14254)) +- Change rate limits for various paths ([Gargron](https://github.com/tootsuite/mastodon/pull/14253)) +- Fix other sessions not being logged out on password change ([Gargron](https://github.com/tootsuite/mastodon/pull/14252)) + +## [v3.1.4] - 2020-05-14 ### Added - Add `vi` to available locales ([taicv](https://github.com/tootsuite/mastodon/pull/13542)) @@ -461,7 +468,7 @@ All notable changes to this project will be documented in this file. - For apps that self-register on behalf of every individual user (such as most mobile apps), this is a non-issue - The issue only affects developers of apps who are shared between multiple users, such as server-side apps like cross-posters -## [3.1.3] - 2020-04-05 +## [v3.1.3] - 2020-04-05 ### Added - Add ability to filter audit log in admin UI ([Gargron](https://github.com/tootsuite/mastodon/pull/13381)) diff --git a/Gemfile.lock b/Gemfile.lock index 3a7453a78..388a8477d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -811,3 +811,9 @@ DEPENDENCIES webpacker (~> 5.2) webpush xorcist (~> 1.1) + +RUBY VERSION + ruby 2.6.6p146 + +BUNDLED WITH + 2.1.4 diff --git a/README.md b/README.md index 3c6daf4f8..8407d4ed4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![Mastodon](https://i.imgur.com/NhZc40l.png) +![Mastodon](https://i.imgur.com/NhZc40l.png) - [mastodon.CipherBliss.com](https://mastodon.CipherBliss.com) version ======== [![GitHub release](https://img.shields.io/github/release/tootsuite/mastodon.svg)][releases] diff --git a/app/assets/javascripts/user_groups.js b/app/assets/javascripts/user_groups.js new file mode 100644 index 000000000..dee720fac --- /dev/null +++ b/app/assets/javascripts/user_groups.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/scaffold.css b/app/assets/stylesheets/scaffold.css new file mode 100644 index 000000000..cd4f3de38 --- /dev/null +++ b/app/assets/stylesheets/scaffold.css @@ -0,0 +1,80 @@ +body { + background-color: #fff; + color: #333; + margin: 33px; +} + +body, p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { + color: #000; +} + +a:visited { + color: #666; +} + +a:hover { + color: #fff; + background-color: #000; +} + +th { + padding-bottom: 5px; +} + +td { + padding: 0 5px 7px; +} + +div.field, +div.actions { + margin-bottom: 10px; +} + +#notice { + color: green; +} + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; +} + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px 7px 0; + margin-bottom: 20px; + background-color: #f0f0f0; +} + +#error_explanation h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px -7px 0; + background-color: #c00; + color: #fff; +} + +#error_explanation ul li { + font-size: 12px; + list-style: square; +} + +label { + display: block; +} diff --git a/app/assets/stylesheets/user_groups.css b/app/assets/stylesheets/user_groups.css new file mode 100644 index 000000000..afad32db0 --- /dev/null +++ b/app/assets/stylesheets/user_groups.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/user_groups_controller.rb b/app/controllers/user_groups_controller.rb new file mode 100644 index 000000000..d4ec0a2b4 --- /dev/null +++ b/app/controllers/user_groups_controller.rb @@ -0,0 +1,58 @@ +class UserGroupsController < ApplicationController + before_action :set_user_group, only: [:show, :edit, :update, :destroy] + + # GET /user_groups + def index + @user_groups = UserGroup.all + end + + # GET /user_groups/1 + def show + end + + # GET /user_groups/new + def new + @user_group = UserGroup.new + end + + # GET /user_groups/1/edit + def edit + end + + # POST /user_groups + def create + @user_group = UserGroup.new(user_group_params) + + if @user_group.save + redirect_to @user_group, notice: 'User group was successfully created.' + else + render :new + end + end + + # PATCH/PUT /user_groups/1 + def update + if @user_group.update(user_group_params) + redirect_to @user_group, notice: 'User group was successfully updated.' + else + render :edit + end + end + + # DELETE /user_groups/1 + def destroy + @user_group.destroy + redirect_to user_groups_url, notice: 'User group was successfully destroyed.' + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_user_group + @user_group = UserGroup.find(params[:id]) + end + + # Only allow a trusted parameter "white list" through. + def user_group_params + params.require(:user_group).permit(:name, :createAt, :visibility, :members) + end +end diff --git a/app/helpers/user_groups_helper.rb b/app/helpers/user_groups_helper.rb new file mode 100644 index 000000000..83cd8f3cd --- /dev/null +++ b/app/helpers/user_groups_helper.rb @@ -0,0 +1,2 @@ +module UserGroupsHelper +end diff --git a/app/javascript/images/logo_cipherbliss.png b/app/javascript/images/logo_cipherbliss.png new file mode 100755 index 000000000..40c7e37a7 Binary files /dev/null and b/app/javascript/images/logo_cipherbliss.png differ diff --git a/app/javascript/mastodon/actions/accounts.js b/app/javascript/mastodon/actions/accounts.js index 58b636602..b941de8cc 100644 --- a/app/javascript/mastodon/actions/accounts.js +++ b/app/javascript/mastodon/actions/accounts.js @@ -85,20 +85,20 @@ export function fetchAccount(id) { dispatch(fetchAccountFail(id, error)); }); }; -}; +} export function fetchAccountRequest(id) { return { type: ACCOUNT_FETCH_REQUEST, id, }; -}; +} export function fetchAccountSuccess() { return { type: ACCOUNT_FETCH_SUCCESS, }; -}; +} export function fetchAccountFail(id, error) { return { @@ -107,7 +107,7 @@ export function fetchAccountFail(id, error) { error, skipAlert: true, }; -}; +} export function followAccount(id, options = { reblogs: true }) { return (dispatch, getState) => { @@ -122,7 +122,7 @@ export function followAccount(id, options = { reblogs: true }) { dispatch(followAccountFail(error, locked)); }); }; -}; +} export function unfollowAccount(id) { return (dispatch, getState) => { @@ -134,7 +134,7 @@ export function unfollowAccount(id) { dispatch(unfollowAccountFail(error)); }); }; -}; +} export function followAccountRequest(id, locked) { return { @@ -143,7 +143,7 @@ export function followAccountRequest(id, locked) { locked, skipLoading: true, }; -}; +} export function followAccountSuccess(relationship, alreadyFollowing) { return { @@ -152,7 +152,7 @@ export function followAccountSuccess(relationship, alreadyFollowing) { alreadyFollowing, skipLoading: true, }; -}; +} export function followAccountFail(error, locked) { return { @@ -161,7 +161,7 @@ export function followAccountFail(error, locked) { locked, skipLoading: true, }; -}; +} export function unfollowAccountRequest(id) { return { @@ -169,7 +169,7 @@ export function unfollowAccountRequest(id) { id, skipLoading: true, }; -}; +} export function unfollowAccountSuccess(relationship, statuses) { return { @@ -178,7 +178,7 @@ export function unfollowAccountSuccess(relationship, statuses) { statuses, skipLoading: true, }; -}; +} export function unfollowAccountFail(error) { return { @@ -186,7 +186,7 @@ export function unfollowAccountFail(error) { error, skipLoading: true, }; -}; +} export function blockAccount(id) { return (dispatch, getState) => { @@ -199,7 +199,7 @@ export function blockAccount(id) { dispatch(blockAccountFail(id, error)); }); }; -}; +} export function unblockAccount(id) { return (dispatch, getState) => { @@ -211,14 +211,14 @@ export function unblockAccount(id) { dispatch(unblockAccountFail(id, error)); }); }; -}; +} export function blockAccountRequest(id) { return { type: ACCOUNT_BLOCK_REQUEST, id, }; -}; +} export function blockAccountSuccess(relationship, statuses) { return { @@ -226,35 +226,35 @@ export function blockAccountSuccess(relationship, statuses) { relationship, statuses, }; -}; +} export function blockAccountFail(error) { return { type: ACCOUNT_BLOCK_FAIL, error, }; -}; +} export function unblockAccountRequest(id) { return { type: ACCOUNT_UNBLOCK_REQUEST, id, }; -}; +} export function unblockAccountSuccess(relationship) { return { type: ACCOUNT_UNBLOCK_SUCCESS, relationship, }; -}; +} export function unblockAccountFail(error) { return { type: ACCOUNT_UNBLOCK_FAIL, error, }; -}; +} export function muteAccount(id, notifications, duration=0) { @@ -268,7 +268,7 @@ export function muteAccount(id, notifications, duration=0) { dispatch(muteAccountFail(id, error)); }); }; -}; +} export function unmuteAccount(id) { return (dispatch, getState) => { @@ -280,14 +280,14 @@ export function unmuteAccount(id) { dispatch(unmuteAccountFail(id, error)); }); }; -}; +} export function muteAccountRequest(id) { return { type: ACCOUNT_MUTE_REQUEST, id, }; -}; +} export function muteAccountSuccess(relationship, statuses) { return { @@ -295,35 +295,35 @@ export function muteAccountSuccess(relationship, statuses) { relationship, statuses, }; -}; +} export function muteAccountFail(error) { return { type: ACCOUNT_MUTE_FAIL, error, }; -}; +} export function unmuteAccountRequest(id) { return { type: ACCOUNT_UNMUTE_REQUEST, id, }; -}; +} export function unmuteAccountSuccess(relationship) { return { type: ACCOUNT_UNMUTE_SUCCESS, relationship, }; -}; +} export function unmuteAccountFail(error) { return { type: ACCOUNT_UNMUTE_FAIL, error, }; -}; +} export function fetchFollowers(id) { @@ -340,14 +340,14 @@ export function fetchFollowers(id) { dispatch(fetchFollowersFail(id, error)); }); }; -}; +} export function fetchFollowersRequest(id) { return { type: FOLLOWERS_FETCH_REQUEST, id, }; -}; +} export function fetchFollowersSuccess(id, accounts, next) { return { @@ -356,16 +356,16 @@ export function fetchFollowersSuccess(id, accounts, next) { accounts, next, }; -}; +} export function fetchFollowersFail(id, error) { return { - type: FOLLOWERS_FETCH_FAIL, + type : FOLLOWERS_FETCH_FAIL, id, error, skipNotFound: true, }; -}; +} export function expandFollowers(id) { return (dispatch, getState) => { @@ -387,14 +387,14 @@ export function expandFollowers(id) { dispatch(expandFollowersFail(id, error)); }); }; -}; +} export function expandFollowersRequest(id) { return { type: FOLLOWERS_EXPAND_REQUEST, id, }; -}; +} export function expandFollowersSuccess(id, accounts, next) { return { @@ -403,7 +403,7 @@ export function expandFollowersSuccess(id, accounts, next) { accounts, next, }; -}; +} export function expandFollowersFail(id, error) { return { @@ -411,7 +411,7 @@ export function expandFollowersFail(id, error) { id, error, }; -}; +} export function fetchFollowing(id) { return (dispatch, getState) => { @@ -427,14 +427,14 @@ export function fetchFollowing(id) { dispatch(fetchFollowingFail(id, error)); }); }; -}; +} export function fetchFollowingRequest(id) { return { type: FOLLOWING_FETCH_REQUEST, id, }; -}; +} export function fetchFollowingSuccess(id, accounts, next) { return { @@ -443,16 +443,16 @@ export function fetchFollowingSuccess(id, accounts, next) { accounts, next, }; -}; +} export function fetchFollowingFail(id, error) { return { - type: FOLLOWING_FETCH_FAIL, + type : FOLLOWING_FETCH_FAIL, id, error, skipNotFound: true, }; -}; +} export function expandFollowing(id) { return (dispatch, getState) => { @@ -474,14 +474,14 @@ export function expandFollowing(id) { dispatch(expandFollowingFail(id, error)); }); }; -}; +} export function expandFollowingRequest(id) { return { type: FOLLOWING_EXPAND_REQUEST, id, }; -}; +} export function expandFollowingSuccess(id, accounts, next) { return { @@ -490,7 +490,7 @@ export function expandFollowingSuccess(id, accounts, next) { accounts, next, }; -}; +} export function expandFollowingFail(id, error) { return { @@ -498,7 +498,7 @@ export function expandFollowingFail(id, error) { id, error, }; -}; +} export function fetchRelationships(accountIds) { return (dispatch, getState) => { @@ -517,7 +517,7 @@ export function fetchRelationships(accountIds) { dispatch(fetchRelationshipsFail(error)); }); }; -}; +} export function fetchRelationshipsRequest(ids) { return { @@ -525,7 +525,7 @@ export function fetchRelationshipsRequest(ids) { ids, skipLoading: true, }; -}; +} export function fetchRelationshipsSuccess(relationships) { return { @@ -533,16 +533,16 @@ export function fetchRelationshipsSuccess(relationships) { relationships, skipLoading: true, }; -}; +} export function fetchRelationshipsFail(error) { return { - type: RELATIONSHIPS_FETCH_FAIL, + type : RELATIONSHIPS_FETCH_FAIL, error, - skipLoading: true, + skipLoading : true, skipNotFound: true, }; -}; +} export function fetchFollowRequests() { return (dispatch, getState) => { @@ -554,13 +554,13 @@ export function fetchFollowRequests() { dispatch(fetchFollowRequestsSuccess(response.data, next ? next.uri : null)); }).catch(error => dispatch(fetchFollowRequestsFail(error))); }; -}; +} export function fetchFollowRequestsRequest() { return { type: FOLLOW_REQUESTS_FETCH_REQUEST, }; -}; +} export function fetchFollowRequestsSuccess(accounts, next) { return { @@ -568,14 +568,14 @@ export function fetchFollowRequestsSuccess(accounts, next) { accounts, next, }; -}; +} export function fetchFollowRequestsFail(error) { return { type: FOLLOW_REQUESTS_FETCH_FAIL, error, }; -}; +} export function expandFollowRequests() { return (dispatch, getState) => { @@ -593,13 +593,13 @@ export function expandFollowRequests() { dispatch(expandFollowRequestsSuccess(response.data, next ? next.uri : null)); }).catch(error => dispatch(expandFollowRequestsFail(error))); }; -}; +} export function expandFollowRequestsRequest() { return { type: FOLLOW_REQUESTS_EXPAND_REQUEST, }; -}; +} export function expandFollowRequestsSuccess(accounts, next) { return { @@ -607,14 +607,14 @@ export function expandFollowRequestsSuccess(accounts, next) { accounts, next, }; -}; +} export function expandFollowRequestsFail(error) { return { type: FOLLOW_REQUESTS_EXPAND_FAIL, error, }; -}; +} export function authorizeFollowRequest(id) { return (dispatch, getState) => { @@ -625,21 +625,21 @@ export function authorizeFollowRequest(id) { .then(() => dispatch(authorizeFollowRequestSuccess(id))) .catch(error => dispatch(authorizeFollowRequestFail(id, error))); }; -}; +} export function authorizeFollowRequestRequest(id) { return { type: FOLLOW_REQUEST_AUTHORIZE_REQUEST, id, }; -}; +} export function authorizeFollowRequestSuccess(id) { return { type: FOLLOW_REQUEST_AUTHORIZE_SUCCESS, id, }; -}; +} export function authorizeFollowRequestFail(id, error) { return { @@ -647,7 +647,7 @@ export function authorizeFollowRequestFail(id, error) { id, error, }; -}; +} export function rejectFollowRequest(id) { @@ -659,21 +659,21 @@ export function rejectFollowRequest(id) { .then(() => dispatch(rejectFollowRequestSuccess(id))) .catch(error => dispatch(rejectFollowRequestFail(id, error))); }; -}; +} export function rejectFollowRequestRequest(id) { return { type: FOLLOW_REQUEST_REJECT_REQUEST, id, }; -}; +} export function rejectFollowRequestSuccess(id) { return { type: FOLLOW_REQUEST_REJECT_SUCCESS, id, }; -}; +} export function rejectFollowRequestFail(id, error) { return { @@ -681,7 +681,7 @@ export function rejectFollowRequestFail(id, error) { id, error, }; -}; +} export function pinAccount(id) { return (dispatch, getState) => { @@ -693,7 +693,7 @@ export function pinAccount(id) { dispatch(pinAccountFail(error)); }); }; -}; +} export function unpinAccount(id) { return (dispatch, getState) => { @@ -705,46 +705,46 @@ export function unpinAccount(id) { dispatch(unpinAccountFail(error)); }); }; -}; +} export function pinAccountRequest(id) { return { type: ACCOUNT_PIN_REQUEST, id, }; -}; +} export function pinAccountSuccess(relationship) { return { type: ACCOUNT_PIN_SUCCESS, relationship, }; -}; +} export function pinAccountFail(error) { return { type: ACCOUNT_PIN_FAIL, error, }; -}; +} export function unpinAccountRequest(id) { return { type: ACCOUNT_UNPIN_REQUEST, id, }; -}; +} export function unpinAccountSuccess(relationship) { return { type: ACCOUNT_UNPIN_SUCCESS, relationship, }; -}; +} export function unpinAccountFail(error) { return { type: ACCOUNT_UNPIN_FAIL, error, }; -}; +} diff --git a/app/javascript/mastodon/actions/alerts.js b/app/javascript/mastodon/actions/alerts.js index 1670f9c10..0220b0af5 100644 --- a/app/javascript/mastodon/actions/alerts.js +++ b/app/javascript/mastodon/actions/alerts.js @@ -17,13 +17,13 @@ export function dismissAlert(alert) { type: ALERT_DISMISS, alert, }; -}; +} export function clearAlert() { return { type: ALERT_CLEAR, }; -}; +} export function showAlert(title = messages.unexpectedTitle, message = messages.unexpectedMessage, message_values = undefined) { return { @@ -32,7 +32,7 @@ export function showAlert(title = messages.unexpectedTitle, message = messages.u message, message_values, }; -}; +} export function showAlertForError(error, skipNotFound = false) { if (error.response) { diff --git a/app/javascript/mastodon/actions/announcements.js b/app/javascript/mastodon/actions/announcements.js index 1bdea909f..aec2f94ed 100644 --- a/app/javascript/mastodon/actions/announcements.js +++ b/app/javascript/mastodon/actions/announcements.js @@ -3,21 +3,21 @@ import { normalizeAnnouncement } from './importer/normalizer'; export const ANNOUNCEMENTS_FETCH_REQUEST = 'ANNOUNCEMENTS_FETCH_REQUEST'; export const ANNOUNCEMENTS_FETCH_SUCCESS = 'ANNOUNCEMENTS_FETCH_SUCCESS'; -export const ANNOUNCEMENTS_FETCH_FAIL = 'ANNOUNCEMENTS_FETCH_FAIL'; -export const ANNOUNCEMENTS_UPDATE = 'ANNOUNCEMENTS_UPDATE'; -export const ANNOUNCEMENTS_DELETE = 'ANNOUNCEMENTS_DELETE'; +export const ANNOUNCEMENTS_FETCH_FAIL = 'ANNOUNCEMENTS_FETCH_FAIL'; +export const ANNOUNCEMENTS_UPDATE = 'ANNOUNCEMENTS_UPDATE'; +export const ANNOUNCEMENTS_DELETE = 'ANNOUNCEMENTS_DELETE'; export const ANNOUNCEMENTS_DISMISS_REQUEST = 'ANNOUNCEMENTS_DISMISS_REQUEST'; export const ANNOUNCEMENTS_DISMISS_SUCCESS = 'ANNOUNCEMENTS_DISMISS_SUCCESS'; -export const ANNOUNCEMENTS_DISMISS_FAIL = 'ANNOUNCEMENTS_DISMISS_FAIL'; +export const ANNOUNCEMENTS_DISMISS_FAIL = 'ANNOUNCEMENTS_DISMISS_FAIL'; export const ANNOUNCEMENTS_REACTION_ADD_REQUEST = 'ANNOUNCEMENTS_REACTION_ADD_REQUEST'; export const ANNOUNCEMENTS_REACTION_ADD_SUCCESS = 'ANNOUNCEMENTS_REACTION_ADD_SUCCESS'; -export const ANNOUNCEMENTS_REACTION_ADD_FAIL = 'ANNOUNCEMENTS_REACTION_ADD_FAIL'; +export const ANNOUNCEMENTS_REACTION_ADD_FAIL = 'ANNOUNCEMENTS_REACTION_ADD_FAIL'; export const ANNOUNCEMENTS_REACTION_REMOVE_REQUEST = 'ANNOUNCEMENTS_REACTION_REMOVE_REQUEST'; export const ANNOUNCEMENTS_REACTION_REMOVE_SUCCESS = 'ANNOUNCEMENTS_REACTION_REMOVE_SUCCESS'; -export const ANNOUNCEMENTS_REACTION_REMOVE_FAIL = 'ANNOUNCEMENTS_REACTION_REMOVE_FAIL'; +export const ANNOUNCEMENTS_REACTION_REMOVE_FAIL = 'ANNOUNCEMENTS_REACTION_REMOVE_FAIL'; export const ANNOUNCEMENTS_REACTION_UPDATE = 'ANNOUNCEMENTS_REACTION_UPDATE'; @@ -56,7 +56,7 @@ export const fetchAnnouncementsFail= error => ({ }); export const updateAnnouncements = announcement => ({ - type: ANNOUNCEMENTS_UPDATE, + type : ANNOUNCEMENTS_UPDATE, announcement: normalizeAnnouncement(announcement), }); @@ -72,17 +72,17 @@ export const dismissAnnouncement = announcementId => (dispatch, getState) => { export const dismissAnnouncementRequest = announcementId => ({ type: ANNOUNCEMENTS_DISMISS_REQUEST, - id: announcementId, + id : announcementId, }); export const dismissAnnouncementSuccess = announcementId => ({ type: ANNOUNCEMENTS_DISMISS_SUCCESS, - id: announcementId, + id : announcementId, }); export const dismissAnnouncementFail = (announcementId, error) => ({ type: ANNOUNCEMENTS_DISMISS_FAIL, - id: announcementId, + id : announcementId, error, }); diff --git a/app/javascript/mastodon/actions/compose.js b/app/javascript/mastodon/actions/compose.js index 891403969..6ab8bf1f9 100644 --- a/app/javascript/mastodon/actions/compose.js +++ b/app/javascript/mastodon/actions/compose.js @@ -7,8 +7,7 @@ import { useEmoji } from './emojis'; import resizeImage from '../utils/resize_image'; import { importFetchedAccounts } from './importer'; import { updateTimeline } from './timelines'; -import { showAlertForError } from './alerts'; -import { showAlert } from './alerts'; +import { showAlert, showAlertForError } from './alerts'; import { defineMessages } from 'react-intl'; let cancelFetchComposeSuggestionsAccounts, cancelFetchComposeSuggestionsTags; @@ -81,7 +80,7 @@ export function changeCompose(text) { type: COMPOSE_CHANGE, text: text, }; -}; +} export function replyCompose(status, routerHistory) { return (dispatch, getState) => { @@ -92,19 +91,19 @@ export function replyCompose(status, routerHistory) { ensureComposeIsVisible(getState, routerHistory); }; -}; +} export function cancelReplyCompose() { return { type: COMPOSE_REPLY_CANCEL, }; -}; +} export function resetCompose() { return { type: COMPOSE_RESET, }; -}; +} export function mentionCompose(account, routerHistory) { return (dispatch, getState) => { @@ -115,7 +114,7 @@ export function mentionCompose(account, routerHistory) { ensureComposeIsVisible(getState, routerHistory); }; -}; +} export function directCompose(account, routerHistory) { return (dispatch, getState) => { @@ -126,7 +125,7 @@ export function directCompose(account, routerHistory) { ensureComposeIsVisible(getState, routerHistory); }; -}; +} export function submitCompose(routerHistory) { return function (dispatch, getState) { @@ -182,27 +181,27 @@ export function submitCompose(routerHistory) { dispatch(submitComposeFail(error)); }); }; -}; +} export function submitComposeRequest() { return { type: COMPOSE_SUBMIT_REQUEST, }; -}; +} export function submitComposeSuccess(status) { return { type: COMPOSE_SUBMIT_SUCCESS, status: status, }; -}; +} export function submitComposeFail(error) { return { type: COMPOSE_SUBMIT_FAIL, error: error, }; -}; +} export function uploadCompose(files) { return function (dispatch, getState) { @@ -234,7 +233,7 @@ export function uploadCompose(files) { total += file.size - f.size; return api(getState).post('/api/v2/media', data, { - onUploadProgress: function({ loaded }){ + onUploadProgress: function ({ loaded }) { progress[i] = loaded; dispatch(uploadComposeProgress(progress.reduce((a, v) => a + v, 0), total)); }, @@ -259,9 +258,9 @@ export function uploadCompose(files) { } }); }).catch(error => dispatch(uploadComposeFail(error))); - }; + } }; -}; +} export const uploadThumbnail = (id, file) => (dispatch, getState) => { dispatch(uploadThumbnailRequest()); @@ -316,7 +315,7 @@ export function changeUploadCompose(id, params) { dispatch(changeUploadComposeFail(id, error)); }); }; -}; +} export function changeUploadComposeRequest() { return { @@ -331,7 +330,7 @@ export function changeUploadComposeSuccess(media) { media: media, skipLoading: true, }; -}; +} export function changeUploadComposeFail(error) { return { @@ -339,14 +338,14 @@ export function changeUploadComposeFail(error) { error: error, skipLoading: true, }; -}; +} export function uploadComposeRequest() { return { type: COMPOSE_UPLOAD_REQUEST, skipLoading: true, }; -}; +} export function uploadComposeProgress(loaded, total) { return { @@ -354,7 +353,7 @@ export function uploadComposeProgress(loaded, total) { loaded: loaded, total: total, }; -}; +} export function uploadComposeSuccess(media, file) { return { @@ -363,7 +362,7 @@ export function uploadComposeSuccess(media, file) { file: file, skipLoading: true, }; -}; +} export function uploadComposeFail(error) { return { @@ -371,14 +370,14 @@ export function uploadComposeFail(error) { error: error, skipLoading: true, }; -}; +} export function undoUploadCompose(media_id) { return { type: COMPOSE_UPLOAD_UNDO, media_id: media_id, }; -}; +} export function clearComposeSuggestions() { if (cancelFetchComposeSuggestionsAccounts) { @@ -387,7 +386,7 @@ export function clearComposeSuggestions() { return { type: COMPOSE_SUGGESTIONS_CLEAR, }; -}; +} const fetchComposeSuggestionsAccounts = throttle((dispatch, getState, token) => { if (cancelFetchComposeSuggestionsAccounts) { @@ -461,7 +460,7 @@ export function fetchComposeSuggestions(token) { break; } }; -}; +} export function readyComposeSuggestionsEmojis(token, emojis) { return { @@ -469,7 +468,7 @@ export function readyComposeSuggestionsEmojis(token, emojis) { token, emojis, }; -}; +} export function readyComposeSuggestionsAccounts(token, accounts) { return { @@ -477,7 +476,7 @@ export function readyComposeSuggestionsAccounts(token, accounts) { token, accounts, }; -}; +} export const readyComposeSuggestionsTags = (token, tags) => ({ type: COMPOSE_SUGGESTIONS_READY, @@ -510,7 +509,7 @@ export function selectComposeSuggestion(position, token, suggestion, path) { path, }); }; -}; +} export function updateSuggestionTags(token) { return { @@ -558,39 +557,39 @@ export function mountCompose() { return { type: COMPOSE_MOUNT, }; -}; +} export function unmountCompose() { return { type: COMPOSE_UNMOUNT, }; -}; +} export function changeComposeSensitivity() { return { type: COMPOSE_SENSITIVITY_CHANGE, }; -}; +} export function changeComposeSpoilerness() { return { type: COMPOSE_SPOILERNESS_CHANGE, }; -}; +} export function changeComposeSpoilerText(text) { return { type: COMPOSE_SPOILER_TEXT_CHANGE, text, }; -}; +} export function changeComposeVisibility(value) { return { type: COMPOSE_VISIBILITY_CHANGE, value, }; -}; +} export function insertEmojiCompose(position, emoji, needsSpace) { return { @@ -599,33 +598,33 @@ export function insertEmojiCompose(position, emoji, needsSpace) { emoji, needsSpace, }; -}; +} export function changeComposing(value) { return { type: COMPOSE_COMPOSING_CHANGE, value, }; -}; +} export function addPoll() { return { type: COMPOSE_POLL_ADD, }; -}; +} export function removePoll() { return { type: COMPOSE_POLL_REMOVE, }; -}; +} export function addPollOption(title) { return { type: COMPOSE_POLL_OPTION_ADD, title, }; -}; +} export function changePollOption(index, title) { return { @@ -633,14 +632,14 @@ export function changePollOption(index, title) { index, title, }; -}; +} export function removePollOption(index) { return { type: COMPOSE_POLL_OPTION_REMOVE, index, }; -}; +} export function changePollSettings(expiresIn, isMultiple) { return { @@ -648,4 +647,4 @@ export function changePollSettings(expiresIn, isMultiple) { expiresIn, isMultiple, }; -}; +} diff --git a/app/javascript/mastodon/actions/conversations.js b/app/javascript/mastodon/actions/conversations.js index 4ef654b1f..2027fcb68 100644 --- a/app/javascript/mastodon/actions/conversations.js +++ b/app/javascript/mastodon/actions/conversations.js @@ -1,23 +1,19 @@ import api, { getLinks } from '../api'; -import { - importFetchedAccounts, - importFetchedStatuses, - importFetchedStatus, -} from './importer'; +import { importFetchedAccounts, importFetchedStatus, importFetchedStatuses } from './importer'; -export const CONVERSATIONS_MOUNT = 'CONVERSATIONS_MOUNT'; +export const CONVERSATIONS_MOUNT = 'CONVERSATIONS_MOUNT'; export const CONVERSATIONS_UNMOUNT = 'CONVERSATIONS_UNMOUNT'; export const CONVERSATIONS_FETCH_REQUEST = 'CONVERSATIONS_FETCH_REQUEST'; export const CONVERSATIONS_FETCH_SUCCESS = 'CONVERSATIONS_FETCH_SUCCESS'; -export const CONVERSATIONS_FETCH_FAIL = 'CONVERSATIONS_FETCH_FAIL'; -export const CONVERSATIONS_UPDATE = 'CONVERSATIONS_UPDATE'; +export const CONVERSATIONS_FETCH_FAIL = 'CONVERSATIONS_FETCH_FAIL'; +export const CONVERSATIONS_UPDATE = 'CONVERSATIONS_UPDATE'; export const CONVERSATIONS_READ = 'CONVERSATIONS_READ'; export const CONVERSATIONS_DELETE_REQUEST = 'CONVERSATIONS_DELETE_REQUEST'; export const CONVERSATIONS_DELETE_SUCCESS = 'CONVERSATIONS_DELETE_SUCCESS'; -export const CONVERSATIONS_DELETE_FAIL = 'CONVERSATIONS_DELETE_FAIL'; +export const CONVERSATIONS_DELETE_FAIL = 'CONVERSATIONS_DELETE_FAIL'; export const mountConversations = () => ({ type: CONVERSATIONS_MOUNT, @@ -30,7 +26,7 @@ export const unmountConversations = () => ({ export const markConversationRead = conversationId => (dispatch, getState) => { dispatch({ type: CONVERSATIONS_READ, - id: conversationId, + id : conversationId, }); api(getState).post(`/api/v1/conversations/${conversationId}/read`); diff --git a/app/javascript/mastodon/actions/identity_proofs.js b/app/javascript/mastodon/actions/identity_proofs.js index 103983956..15fdb8c4e 100644 --- a/app/javascript/mastodon/actions/identity_proofs.js +++ b/app/javascript/mastodon/actions/identity_proofs.js @@ -24,7 +24,7 @@ export const fetchAccountIdentityProofsSuccess = (accountId, identity_proofs) => }); export const fetchAccountIdentityProofsFail = (accountId, err) => ({ - type: IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL, + type : IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL, accountId, err, skipNotFound: true, diff --git a/app/javascript/mastodon/actions/statuses.js b/app/javascript/mastodon/actions/statuses.js index 3fc7c0702..ac4125887 100644 --- a/app/javascript/mastodon/actions/statuses.js +++ b/app/javascript/mastodon/actions/statuses.js @@ -6,28 +6,29 @@ import { ensureComposeIsVisible } from './compose'; export const STATUS_FETCH_REQUEST = 'STATUS_FETCH_REQUEST'; export const STATUS_FETCH_SUCCESS = 'STATUS_FETCH_SUCCESS'; -export const STATUS_FETCH_FAIL = 'STATUS_FETCH_FAIL'; +export const STATUS_FETCH_FAIL = 'STATUS_FETCH_FAIL'; export const STATUS_DELETE_REQUEST = 'STATUS_DELETE_REQUEST'; export const STATUS_DELETE_SUCCESS = 'STATUS_DELETE_SUCCESS'; -export const STATUS_DELETE_FAIL = 'STATUS_DELETE_FAIL'; +export const STATUS_DELETE_FAIL = 'STATUS_DELETE_FAIL'; export const CONTEXT_FETCH_REQUEST = 'CONTEXT_FETCH_REQUEST'; export const CONTEXT_FETCH_SUCCESS = 'CONTEXT_FETCH_SUCCESS'; -export const CONTEXT_FETCH_FAIL = 'CONTEXT_FETCH_FAIL'; +export const CONTEXT_FETCH_FAIL = 'CONTEXT_FETCH_FAIL'; export const STATUS_MUTE_REQUEST = 'STATUS_MUTE_REQUEST'; export const STATUS_MUTE_SUCCESS = 'STATUS_MUTE_SUCCESS'; -export const STATUS_MUTE_FAIL = 'STATUS_MUTE_FAIL'; +export const STATUS_MUTE_FAIL = 'STATUS_MUTE_FAIL'; export const STATUS_UNMUTE_REQUEST = 'STATUS_UNMUTE_REQUEST'; export const STATUS_UNMUTE_SUCCESS = 'STATUS_UNMUTE_SUCCESS'; -export const STATUS_UNMUTE_FAIL = 'STATUS_UNMUTE_FAIL'; +export const STATUS_UNMUTE_FAIL = 'STATUS_UNMUTE_FAIL'; -export const STATUS_REVEAL = 'STATUS_REVEAL'; -export const STATUS_HIDE = 'STATUS_HIDE'; +export const STATUS_REVEAL = 'STATUS_REVEAL'; export const STATUS_COLLAPSE = 'STATUS_COLLAPSE'; +export const STATUS_HIDE = 'STATUS_HIDE'; + export const REDRAFT = 'REDRAFT'; export function fetchStatusRequest(id, skipLoading) { @@ -36,7 +37,7 @@ export function fetchStatusRequest(id, skipLoading) { id, skipLoading, }; -}; +} export function fetchStatus(id) { return (dispatch, getState) => { @@ -57,24 +58,24 @@ export function fetchStatus(id) { dispatch(fetchStatusFail(id, error, skipLoading)); }); }; -}; +} export function fetchStatusSuccess(skipLoading) { return { type: STATUS_FETCH_SUCCESS, skipLoading, }; -}; +} export function fetchStatusFail(id, error, skipLoading) { return { - type: STATUS_FETCH_FAIL, + type : STATUS_FETCH_FAIL, id, error, skipLoading, skipAlert: true, }; -}; +} export function redraft(status, raw_text) { return { @@ -82,7 +83,7 @@ export function redraft(status, raw_text) { status, raw_text, }; -}; +} export function deleteStatus(id, routerHistory, withRedraft = false) { return (dispatch, getState) => { @@ -107,36 +108,43 @@ export function deleteStatus(id, routerHistory, withRedraft = false) { dispatch(deleteStatusFail(id, error)); }); }; -}; +} export function deleteStatusRequest(id) { return { type: STATUS_DELETE_REQUEST, - id: id, + id : id, }; -}; +} export function deleteStatusSuccess(id) { return { type: STATUS_DELETE_SUCCESS, - id: id, + id : id, }; -}; +} export function deleteStatusFail(id, error) { return { - type: STATUS_DELETE_FAIL, - id: id, + type : STATUS_DELETE_FAIL, + id : id, error: error, }; -}; +} export function fetchContext(id) { return (dispatch, getState) => { dispatch(fetchContextRequest(id)); api(getState).get(`/api/v1/statuses/${id}/context`).then(response => { - dispatch(importFetchedStatuses(response.data.ancestors.concat(response.data.descendants))); + /** + * TODO + * the goal here is to get a way to have all the status of a conversation somewhere + */ + const statusConcat = response.data.ancestors.concat(response.data.descendants); + console.log('statusConcat', statusConcat); + + dispatch(importFetchedStatuses(statusConcat)); dispatch(fetchContextSuccess(id, response.data.ancestors, response.data.descendants)); }).catch(error => { @@ -147,33 +155,33 @@ export function fetchContext(id) { dispatch(fetchContextFail(id, error)); }); }; -}; +} export function fetchContextRequest(id) { return { type: CONTEXT_FETCH_REQUEST, id, }; -}; +} export function fetchContextSuccess(id, ancestors, descendants) { return { - type: CONTEXT_FETCH_SUCCESS, + type : CONTEXT_FETCH_SUCCESS, id, ancestors, descendants, statuses: ancestors.concat(descendants), }; -}; +} export function fetchContextFail(id, error) { return { - type: CONTEXT_FETCH_FAIL, + type : CONTEXT_FETCH_FAIL, id, error, skipAlert: true, }; -}; +} export function muteStatus(id) { return (dispatch, getState) => { @@ -185,21 +193,21 @@ export function muteStatus(id) { dispatch(muteStatusFail(id, error)); }); }; -}; +} export function muteStatusRequest(id) { return { type: STATUS_MUTE_REQUEST, id, }; -}; +} export function muteStatusSuccess(id) { return { type: STATUS_MUTE_SUCCESS, id, }; -}; +} export function muteStatusFail(id, error) { return { @@ -207,7 +215,7 @@ export function muteStatusFail(id, error) { id, error, }; -}; +} export function unmuteStatus(id) { return (dispatch, getState) => { @@ -219,21 +227,21 @@ export function unmuteStatus(id) { dispatch(unmuteStatusFail(id, error)); }); }; -}; +} export function unmuteStatusRequest(id) { return { type: STATUS_UNMUTE_REQUEST, id, }; -}; +} export function unmuteStatusSuccess(id) { return { type: STATUS_UNMUTE_SUCCESS, id, }; -}; +} export function unmuteStatusFail(id, error) { return { @@ -241,7 +249,7 @@ export function unmuteStatusFail(id, error) { id, error, }; -}; +} export function hideStatus(ids) { if (!Array.isArray(ids)) { @@ -252,7 +260,7 @@ export function hideStatus(ids) { type: STATUS_HIDE, ids, }; -}; +} export function revealStatus(ids) { if (!Array.isArray(ids)) { @@ -263,7 +271,7 @@ export function revealStatus(ids) { type: STATUS_REVEAL, ids, }; -}; +} export function toggleStatusCollapse(id, isCollapsed) { return { diff --git a/app/javascript/mastodon/actions/timelines.js b/app/javascript/mastodon/actions/timelines.js index de1725acf..ea6a6d0ea 100644 --- a/app/javascript/mastodon/actions/timelines.js +++ b/app/javascript/mastodon/actions/timelines.js @@ -1,7 +1,7 @@ import { importFetchedStatus, importFetchedStatuses } from './importer'; import { submitMarkers } from './markers'; import api, { getLinks } from 'mastodon/api'; -import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; +import { List as ImmutableList, Map as ImmutableMap } from 'immutable'; import compareId from 'mastodon/compare_id'; import { usePendingItems as preferPendingItems } from 'mastodon/initial_state'; @@ -42,7 +42,7 @@ export function updateTimeline(timeline, status, accept) { dispatch(submitMarkers()); } }; -}; +} export function deleteFromTimelines(id) { return (dispatch, getState) => { @@ -58,13 +58,13 @@ export function deleteFromTimelines(id) { reblogOf, }); }; -}; +} export function clearTimeline(timeline) { return (dispatch) => { dispatch({ type: TIMELINE_CLEAR, timeline }); }; -}; +} const noOp = () => {}; @@ -113,7 +113,7 @@ export function expandTimeline(timelineId, path, params = {}, done = noOp) { done(); }); }; -}; +} export const expandHomeTimeline = ({ maxId } = {}, done = noOp) => expandTimeline('home', '/api/v1/timelines/home', { max_id: maxId }, done); export const expandPublicTimeline = ({ maxId, onlyMedia, onlyRemote } = {}, done = noOp) => expandTimeline(`public${onlyRemote ? ':remote' : ''}${onlyMedia ? ':media' : ''}`, '/api/v1/timelines/public', { remote: !!onlyRemote, max_id: maxId, only_media: !!onlyMedia }, done); @@ -138,7 +138,7 @@ export function expandTimelineRequest(timeline, isLoadingMore) { timeline, skipLoading: !isLoadingMore, }; -}; +} export function expandTimelineSuccess(timeline, statuses, next, partial, isLoadingRecent, isLoadingMore, usePendingItems) { return { @@ -151,17 +151,17 @@ export function expandTimelineSuccess(timeline, statuses, next, partial, isLoadi usePendingItems, skipLoading: !isLoadingMore, }; -}; +} export function expandTimelineFail(timeline, error, isLoadingMore) { return { - type: TIMELINE_EXPAND_FAIL, + type : TIMELINE_EXPAND_FAIL, timeline, error, - skipLoading: !isLoadingMore, + skipLoading : !isLoadingMore, skipNotFound: timeline.startsWith('account:'), }; -}; +} export function scrollTopTimeline(timeline, top) { return { @@ -169,14 +169,14 @@ export function scrollTopTimeline(timeline, top) { timeline, top, }; -}; +} export function connectTimeline(timeline) { return { type: TIMELINE_CONNECT, timeline, }; -}; +} export const disconnectTimeline = timeline => ({ type: TIMELINE_DISCONNECT, diff --git a/app/javascript/mastodon/common.js b/app/javascript/mastodon/common.js index 6818aa5d5..8f3505303 100644 --- a/app/javascript/mastodon/common.js +++ b/app/javascript/mastodon/common.js @@ -9,4 +9,4 @@ export function start() { } catch (e) { // If called twice } -}; +} diff --git a/app/javascript/mastodon/components/autosuggest_textarea.js b/app/javascript/mastodon/components/autosuggest_textarea.js index 08b9cd80b..ef6d5a4d6 100644 --- a/app/javascript/mastodon/components/autosuggest_textarea.js +++ b/app/javascript/mastodon/components/autosuggest_textarea.js @@ -11,7 +11,7 @@ import classNames from 'classnames'; const textAtCursorMatchesToken = (str, caretPosition) => { let word; - let left = str.slice(0, caretPosition).search(/\S+$/); + let left = str.slice(0, caretPosition).search(/\S+$/); let right = str.slice(caretPosition).search(/\s/); if (right < 0) { @@ -36,34 +36,37 @@ const textAtCursorMatchesToken = (str, caretPosition) => { export default class AutosuggestTextarea extends ImmutablePureComponent { static propTypes = { - value: PropTypes.string, - suggestions: ImmutablePropTypes.list, - disabled: PropTypes.bool, - placeholder: PropTypes.string, - onSuggestionSelected: PropTypes.func.isRequired, + value : PropTypes.string, + suggestions : ImmutablePropTypes.list, + disabled : PropTypes.bool, + placeholder : PropTypes.string, + onSuggestionSelected : PropTypes.func.isRequired, onSuggestionsClearRequested: PropTypes.func.isRequired, onSuggestionsFetchRequested: PropTypes.func.isRequired, - onChange: PropTypes.func.isRequired, - onKeyUp: PropTypes.func, - onKeyDown: PropTypes.func, - onPaste: PropTypes.func.isRequired, - autoFocus: PropTypes.bool, + onChange : PropTypes.func.isRequired, + onKeyUp : PropTypes.func, + onKeyDown : PropTypes.func, + onPaste : PropTypes.func.isRequired, + autoFocus : PropTypes.bool, + directMessage : PropTypes.bool, + directMessageRecipient : PropTypes.string, }; static defaultProps = { - autoFocus: true, + autoFocus : true, + directMessage: false, }; state = { - suggestionsHidden: true, - focused: false, + suggestionsHidden : true, + focused : false, selectedSuggestion: 0, - lastToken: null, - tokenStart: 0, + lastToken : null, + tokenStart : 0, }; onChange = (e) => { - const [ tokenStart, token ] = textAtCursorMatchesToken(e.target.value, e.target.selectionStart); + const [tokenStart, token] = textAtCursorMatchesToken(e.target.value, e.target.selectionStart); if (token !== null && this.state.lastToken !== token) { this.setState({ lastToken: token, selectedSuggestion: 0, tokenStart }); @@ -74,7 +77,7 @@ export default class AutosuggestTextarea extends ImmutablePureComponent { } this.props.onChange(e); - } + }; onKeyDown = (e) => { const { suggestions, disabled } = this.props; @@ -91,7 +94,7 @@ export default class AutosuggestTextarea extends ImmutablePureComponent { return; } - switch(e.key) { + switch (e.key) { case 'Escape': if (suggestions.size === 0 || suggestionsHidden) { document.querySelector('.ui').parentElement.focus(); @@ -123,7 +126,6 @@ export default class AutosuggestTextarea extends ImmutablePureComponent { e.stopPropagation(); this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestions.get(selectedSuggestion)); } - break; } @@ -132,27 +134,27 @@ export default class AutosuggestTextarea extends ImmutablePureComponent { } this.props.onKeyDown(e); - } + }; onBlur = () => { this.setState({ suggestionsHidden: true, focused: false }); - } + }; onFocus = (e) => { this.setState({ focused: true }); if (this.props.onFocus) { this.props.onFocus(e); } - } + }; onSuggestionClick = (e) => { const suggestion = this.props.suggestions.get(e.currentTarget.getAttribute('data-index')); e.preventDefault(); this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestion); this.textarea.focus(); - } + }; - componentWillReceiveProps (nextProps) { + componentWillReceiveProps(nextProps) { if (nextProps.suggestions !== this.props.suggestions && nextProps.suggestions.size > 0 && this.state.suggestionsHidden && this.state.focused) { this.setState({ suggestionsHidden: false }); } @@ -160,14 +162,14 @@ export default class AutosuggestTextarea extends ImmutablePureComponent { setTextarea = (c) => { this.textarea = c; - } + }; onPaste = (e) => { if (e.clipboardData && e.clipboardData.files.length === 1) { this.props.onPaste(e.clipboardData.files); e.preventDefault(); } - } + }; renderSuggestion = (suggestion, i) => { const { selectedSuggestion } = this.state; @@ -175,31 +177,41 @@ export default class AutosuggestTextarea extends ImmutablePureComponent { if (suggestion.type === 'emoji') { inner = ; - key = suggestion.id; + key = suggestion.id; } else if (suggestion.type === 'hashtag') { inner = ; - key = suggestion.name; + key = suggestion.name; } else if (suggestion.type === 'account') { inner = ; - key = suggestion.id; + key = suggestion.id; } return ( -
+
{inner} -
+
); - } + }; - render () { + render() { const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus, children } = this.props; const { suggestionsHidden } = this.state; return [ -
+
-