Skip to content

Commit

Permalink
Fix win95 theme bug (#17)
Browse files Browse the repository at this point in the history
* Bump @babel/preset-react from 7.0.0 to 7.6.3 (mastodon#12315)

Bumps [@babel/preset-react](https://github.com/babel/babel) from 7.0.0 to 7.6.3.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.md)
- [Commits](babel/babel@v7.0.0...v7.6.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump sass from 1.23.1 to 1.23.3 (mastodon#12314)

Bumps [sass](https://github.com/sass/dart-sass) from 1.23.1 to 1.23.3.
- [Release notes](https://github.com/sass/dart-sass/releases)
- [Changelog](https://github.com/sass/dart-sass/blob/master/CHANGELOG.md)
- [Commits](sass/dart-sass@1.23.1...1.23.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump glob from 7.1.4 to 7.1.5 (mastodon#12312)

Bumps [glob](https://github.com/isaacs/node-glob) from 7.1.4 to 7.1.5.
- [Release notes](https://github.com/isaacs/node-glob/releases)
- [Changelog](https://github.com/isaacs/node-glob/blob/master/changelog.md)
- [Commits](isaacs/node-glob@v7.1.4...v7.1.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump tesseract.js from 2.0.0-alpha.16 to 2.0.0-beta.2 (mastodon#12311)

Bumps [tesseract.js](https://github.com/naptha/tesseract.js) from 2.0.0-alpha.16 to 2.0.0-beta.2.
- [Release notes](https://github.com/naptha/tesseract.js/releases)
- [Commits](naptha/tesseract.js@v2.0.0-alpha.16...v2.0.0-beta.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump @babel/preset-env from 7.6.0 to 7.7.1 (mastodon#12318)

Bumps [@babel/preset-env](https://github.com/babel/babel) from 7.6.0 to 7.7.1.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.md)
- [Commits](babel/babel@v7.6.0...v7.7.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump @babel/runtime from 7.6.0 to 7.7.1 (mastodon#12317)

Bumps [@babel/runtime](https://github.com/babel/babel/tree/HEAD/packages/babel-runtime) from 7.6.0 to 7.7.1.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.7.1/packages/babel-runtime)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Bump sass-loader from 7.1.0 to 8.0.0 (mastodon#12027)

* Bump sass-loader from 7.1.0 to 8.0.0

Bumps [sass-loader](https://github.com/webpack-contrib/sass-loader) from 7.1.0 to 8.0.0.
- [Release notes](https://github.com/webpack-contrib/sass-loader/releases)
- [Changelog](https://github.com/webpack-contrib/sass-loader/blob/master/CHANGELOG.md)
- [Commits](webpack-contrib/sass-loader@v7.1.0...v8.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* bump webpack

* Fix various issues with account migration (mastodon#12301)

* Fix being able to follow oneself by moving to an account that was following the old one

* Add specs

* Add spec to catch MoveWorker issue with local followers following both accounts

* Fix move worker breaking when a local account follows both source and target accounts

* Fix migration from remote to local account not sending Undo Follow

* Fix show_reblogs not being preserved for moved account's followers

* Minor improvements to poll composing UI (mastodon#12319)

- Disable the “add option” button instead of hiding it
- Allow poll option inputs to scale to full width

* Fix WebUI allowing to upload more items than the limit (mastodon#12300)

Until this patch, drag'n'drop and copy-paste allowed to start uploading as
long as the number of *finished* uploads was below the limit.

* Fix relationship caches being broken as result of a follow request (mastodon#12299)

* Fix type mismatch (mastodon#12324)

This was [causing an issue with feed regeneartion in tootctl](hometown-fork#24), and @davefp fixed the issue.

* Fix win95 profile page style

* Increase profile page max width

* Revert "Increase profile page max width"

This reverts commit 4b10c37.
  • Loading branch information
umonaca authored and doubanius committed Nov 10, 2019
1 parent 5b4e932 commit 2e839ad
Show file tree
Hide file tree
Showing 15 changed files with 490 additions and 283 deletions.
8 changes: 5 additions & 3 deletions app/javascript/mastodon/actions/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,11 @@ export function uploadCompose(files) {
return function (dispatch, getState) {
const uploadLimit = 4;
const media = getState().getIn(['compose', 'media_attachments']);
const pending = getState().getIn(['compose', 'pending_media_attachments']);
const progress = new Array(files.length).fill(0);
let total = Array.from(files).reduce((a, v) => a + v.size, 0);

if (files.length + media.size > uploadLimit) {
if (files.length + media.size + pending > uploadLimit) {
dispatch(showAlert(undefined, messages.uploadErrorLimit));
return;
}
Expand All @@ -237,7 +238,7 @@ export function uploadCompose(files) {
dispatch(uploadComposeProgress(progress.reduce((a, v) => a + v, 0), total));
},
}).then(({ data }) => dispatch(uploadComposeSuccess(data, f)));
}).catch(error => dispatch(uploadComposeFail(error)));
}).catch(error => dispatch(uploadComposeFail(error, true)));
};
};
};
Expand Down Expand Up @@ -268,10 +269,11 @@ export function changeUploadComposeSuccess(media) {
};
};

export function changeUploadComposeFail(error) {
export function changeUploadComposeFail(error, decrement = false) {
return {
type: COMPOSE_UPLOAD_CHANGE_FAIL,
error: error,
decrement: decrement,
skipLoading: true,
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ class PollForm extends ImmutablePureComponent {
</ul>

<div className='poll__footer'>
{options.size < 4 && (
<button className='button button-secondary' onClick={this.handleAddOption}><Icon id='plus' /> <FormattedMessage {...messages.add_option} /></button>
)}
<button disabled={options.size >= 4} className='button button-secondary' onClick={this.handleAddOption}><Icon id='plus' /> <FormattedMessage {...messages.add_option} /></button>

<select value={expiresIn} onChange={this.handleSelectDuration}>
<option value={300}>{intl.formatMessage(messages.minutes, { number: 5 })}</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import UploadButton from '../components/upload_button';
import { uploadCompose } from '../../../actions/compose';

const mapStateToProps = state => ({
disabled: state.getIn(['compose', 'is_uploading']) || (state.getIn(['compose', 'media_attachments']).size > 3 || state.getIn(['compose', 'media_attachments']).some(m => ['video', 'audio'].includes(m.get('type')))),
disabled: state.getIn(['compose', 'is_uploading']) || (state.getIn(['compose', 'media_attachments']).size + state.getIn(['compose', 'pending_media_attachments']) > 3 || state.getIn(['compose', 'media_attachments']).some(m => ['video', 'audio'].includes(m.get('type')))),
unavailable: state.getIn(['compose', 'poll']) !== null,
resetFileKey: state.getIn(['compose', 'resetFileKey']),
});
Expand Down
6 changes: 4 additions & 2 deletions app/javascript/mastodon/reducers/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const initialState = ImmutableMap({
is_uploading: false,
progress: 0,
media_attachments: ImmutableList(),
pending_media_attachments: 0,
poll: null,
suggestion_token: null,
suggestions: ImmutableList(),
Expand Down Expand Up @@ -118,6 +119,7 @@ function appendMedia(state, media, file) {
map.set('is_uploading', false);
map.set('resetFileKey', Math.floor((Math.random() * 0x10000)));
map.set('idempotencyKey', uuid());
map.update('pending_media_attachments', n => n - 1);

if (prevSize === 0 && (state.get('default_sensitive') || state.get('spoiler'))) {
map.set('sensitive', true);
Expand Down Expand Up @@ -332,11 +334,11 @@ export default function compose(state = initialState, action) {
case COMPOSE_UPLOAD_CHANGE_FAIL:
return state.set('is_changing_upload', false);
case COMPOSE_UPLOAD_REQUEST:
return state.set('is_uploading', true);
return state.set('is_uploading', true).update('pending_media_attachments', n => n + 1);
case COMPOSE_UPLOAD_SUCCESS:
return appendMedia(state, fromJS(action.media), action.file);
case COMPOSE_UPLOAD_FAIL:
return state.set('is_uploading', false);
return state.set('is_uploading', false).update('pending_media_attachments', n => action.decrement ? n - 1 : n);
case COMPOSE_UPLOAD_UNDO:
return removeMedia(state, action.media_id);
case COMPOSE_UPLOAD_PROGRESS:
Expand Down
1 change: 1 addition & 0 deletions app/javascript/styles/mastodon/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@
.autosuggest-input,
.spoiler-input {
position: relative;
width: 100%;
}

.spoiler-input {
Expand Down
4 changes: 4 additions & 0 deletions app/javascript/styles/win95.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2589,3 +2589,7 @@ body {
.layout-single-column .status__wrapper .status {
padding-bottom: 50px;
}

.activity-stream .entry .status {
padding-bottom: 50px;
}
2 changes: 1 addition & 1 deletion app/lib/feed_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def populate_feed(account)
crutches = build_crutches(account.id, statuses)

statuses.each do |status|
next if filter_from_home?(status, account, crutches)
next if filter_from_home?(status, account.id, crutches)

add_to_feed(:home, account.id, status, aggregate)
end
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/account_relationships_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class AccountRelationshipsPresenter
:endorsed

def initialize(account_ids, current_account_id, **options)
@account_ids = account_ids.map { |a| a.is_a?(Account) ? a.id : a }
@account_ids = account_ids.map { |a| a.is_a?(Account) ? a.id : a.to_i }
@current_account_id = current_account_id

@following = cached[:following].merge(Account.following_map(@uncached_account_ids, @current_account_id))
Expand Down
4 changes: 2 additions & 2 deletions app/services/follow_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class FollowService < BaseService
# @param [Account] source_account From which to follow
# @param [String, Account] uri User URI to follow in the form of username@domain (or account record)
# @param [true, false, nil] reblogs Whether or not to show reblogs, defaults to true
def call(source_account, target_account, reblogs: nil)
def call(source_account, target_account, reblogs: nil, bypass_locked: false)
reblogs = true if reblogs.nil?
target_account = ResolveAccountService.new.call(target_account, skip_webfinger: true)

Expand All @@ -30,7 +30,7 @@ def call(source_account, target_account, reblogs: nil)

ActivityTracker.increment('activity:interactions')

if target_account.locked? || source_account.silenced? || target_account.activitypub?
if (target_account.locked? && !bypass_locked) || source_account.silenced? || target_account.activitypub?
request_follow(source_account, target_account, reblogs: reblogs)
elsif target_account.local?
direct_follow(source_account, target_account, reblogs: reblogs)
Expand Down
8 changes: 6 additions & 2 deletions app/workers/move_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def perform(source_account_id, target_account_id)
@source_account = Account.find(source_account_id)
@target_account = Account.find(target_account_id)

if @target_account.local?
if @target_account.local? && @source_account.local?
rewrite_follows!
else
queue_follow_unfollows!
Expand All @@ -21,13 +21,17 @@ def perform(source_account_id, target_account_id)
def rewrite_follows!
@source_account.passive_relationships
.where(account: Account.local)
.where.not(account: @target_account.followers.local)
.where.not(account_id: @target_account.id)
.in_batches
.update_all(target_account_id: @target_account.id)
end

def queue_follow_unfollows!
bypass_locked = @target_account.local?

@source_account.followers.local.select(:id).find_in_batches do |accounts|
UnfollowFollowWorker.push_bulk(accounts.map(&:id)) { |follower_id| [follower_id, @source_account.id, @target_account.id] }
UnfollowFollowWorker.push_bulk(accounts.map(&:id)) { |follower_id| [follower_id, @source_account.id, @target_account.id, bypass_locked] }
end
end
end
7 changes: 5 additions & 2 deletions app/workers/unfollow_follow_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ class UnfollowFollowWorker

sidekiq_options queue: 'pull'

def perform(follower_account_id, old_target_account_id, new_target_account_id)
def perform(follower_account_id, old_target_account_id, new_target_account_id, bypass_locked = false)
follower_account = Account.find(follower_account_id)
old_target_account = Account.find(old_target_account_id)
new_target_account = Account.find(new_target_account_id)

FollowService.new.call(follower_account, new_target_account)
follow = follower_account.active_relationships.find_by(target_account: old_target_account)
reblogs = follow&.show_reblogs?

FollowService.new.call(follower_account, new_target_account, reblogs: reblogs, bypass_locked: bypass_locked)
UnfollowService.new.call(follower_account, old_target_account, skip_unmerge: true)
rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError
true
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@
"@babel/plugin-transform-react-jsx-self": "^7.2.0",
"@babel/plugin-transform-react-jsx-source": "^7.5.0",
"@babel/plugin-transform-runtime": "^7.5.5",
"@babel/preset-env": "^7.6.0",
"@babel/preset-react": "^7.0.0",
"@babel/runtime": "^7.5.4",
"@babel/preset-env": "^7.7.1",
"@babel/preset-react": "^7.6.3",
"@babel/runtime": "^7.7.1",
"@clusterws/cws": "^0.15.2",
"array-includes": "^3.0.3",
"arrow-key-navigation": "^1.0.2",
Expand Down Expand Up @@ -98,7 +98,7 @@
"express": "^4.17.1",
"file-loader": "^4.2.0",
"font-awesome": "^4.7.0",
"glob": "^7.1.1",
"glob": "^7.1.5",
"history": "^4.10.1",
"http-link-header": "^1.0.2",
"immutable": "^3.8.2",
Expand Down Expand Up @@ -153,17 +153,17 @@
"requestidlecallback": "^0.3.0",
"reselect": "^4.0.0",
"rimraf": "^3.0.0",
"sass": "^1.23.1",
"sass-loader": "^7.0.3",
"sass": "^1.23.3",
"sass-loader": "^8.0.0",
"stringz": "^2.0.0",
"substring-trie": "^1.0.2",
"terser-webpack-plugin": "^2.2.1",
"tesseract.js": "^2.0.0-alpha.16",
"tesseract.js": "^2.0.0-beta.2",
"throng": "^4.0.0",
"tiny-queue": "^0.2.1",
"uuid": "^3.1.0",
"wavesurfer.js": "^3.2.0",
"webpack": "^4.35.3",
"webpack": "^4.41.2",
"webpack-assets-manifest": "^3.1.1",
"webpack-bundle-analyzer": "^3.6.0",
"webpack-cli": "^3.3.10",
Expand Down
63 changes: 63 additions & 0 deletions spec/workers/move_worker_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# frozen_string_literal: true

require 'rails_helper'

describe MoveWorker do
let(:local_follower) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob')).account }
let(:source_account) { Fabricate(:account, protocol: :activitypub, domain: 'example.com') }
let(:target_account) { Fabricate(:account, protocol: :activitypub, domain: 'example.com') }

subject { described_class.new }

before do
local_follower.follow!(source_account)
end

context 'both accounts are distant' do
describe 'perform' do
it 'calls UnfollowFollowWorker' do
allow(UnfollowFollowWorker).to receive(:push_bulk)
subject.perform(source_account.id, target_account.id)
expect(UnfollowFollowWorker).to have_received(:push_bulk).with([local_follower.id])
end
end
end

context 'target account is local' do
let(:target_account) { Fabricate(:user, email: 'alice@example.com', account: Fabricate(:account, username: 'alice')).account }

describe 'perform' do
it 'calls UnfollowFollowWorker' do
allow(UnfollowFollowWorker).to receive(:push_bulk)
subject.perform(source_account.id, target_account.id)
expect(UnfollowFollowWorker).to have_received(:push_bulk).with([local_follower.id])
end
end
end

context 'both target and source accounts are local' do
let(:target_account) { Fabricate(:user, email: 'alice@example.com', account: Fabricate(:account, username: 'alice')).account }
let(:source_account) { Fabricate(:user, email: 'alice_@example.com', account: Fabricate(:account, username: 'alice_')).account }

describe 'perform' do
it 'calls makes local followers follow the target account' do
subject.perform(source_account.id, target_account.id)
expect(local_follower.following?(target_account)).to be true
end

it 'does not fail when a local user is already following both accounts' do
double_follower = Fabricate(:user, email: 'eve@example.com', account: Fabricate(:account, username: 'eve')).account
double_follower.follow!(source_account)
double_follower.follow!(target_account)
subject.perform(source_account.id, target_account.id)
expect(local_follower.following?(target_account)).to be true
end

it 'does not allow the moved account to follow themselves' do
source_account.follow!(target_account)
subject.perform(source_account.id, target_account.id)
expect(target_account.following?(target_account)).to be false
end
end
end
end
50 changes: 50 additions & 0 deletions spec/workers/unfollow_follow_worker_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# frozen_string_literal: true

require 'rails_helper'

describe UnfollowFollowWorker do
let(:local_follower) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob')).account }
let(:source_account) { Fabricate(:account) }
let(:target_account) { Fabricate(:account) }
let(:show_reblogs) { true }

subject { described_class.new }

before do
local_follower.follow!(source_account, reblogs: show_reblogs)
end

context 'when show_reblogs is true' do
let(:show_reblogs) { true }

describe 'perform' do
it 'unfollows source account and follows target account' do
subject.perform(local_follower.id, source_account.id, target_account.id)
expect(local_follower.following?(source_account)).to be false
expect(local_follower.following?(target_account)).to be true
end

it 'preserves show_reblogs' do
subject.perform(local_follower.id, source_account.id, target_account.id)
expect(Follow.find_by(account: local_follower, target_account: target_account).show_reblogs?).to be show_reblogs
end
end
end

context 'when show_reblogs is false' do
let(:show_reblogs) { false }

describe 'perform' do
it 'unfollows source account and follows target account' do
subject.perform(local_follower.id, source_account.id, target_account.id)
expect(local_follower.following?(source_account)).to be false
expect(local_follower.following?(target_account)).to be true
end

it 'preserves show_reblogs' do
subject.perform(local_follower.id, source_account.id, target_account.id)
expect(Follow.find_by(account: local_follower, target_account: target_account).show_reblogs?).to be show_reblogs
end
end
end
end
Loading

0 comments on commit 2e839ad

Please sign in to comment.