mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-22 06:06:45 +00:00
Fixes website not loading for unlogged users (#27698)
This commit is contained in:
parent
3bf2a7296e
commit
6712bf86cd
|
@ -41,32 +41,34 @@ const normalizeAccounts = (
|
||||||
return state;
|
return state;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const accountsReducer: Reducer<typeof initialState> = (
|
function getCurrentUser() {
|
||||||
state = initialState,
|
if (!me)
|
||||||
action,
|
|
||||||
) => {
|
|
||||||
const currentUserId = me;
|
|
||||||
|
|
||||||
if (!currentUserId)
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'No current user (me) defined when calling `accountsReducer`',
|
'No current user (me) defined when calling `accountsReducer`',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return me;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const accountsReducer: Reducer<typeof initialState> = (
|
||||||
|
state = initialState,
|
||||||
|
action,
|
||||||
|
) => {
|
||||||
if (revealAccount.match(action))
|
if (revealAccount.match(action))
|
||||||
return state.setIn([action.payload.id, 'hidden'], false);
|
return state.setIn([action.payload.id, 'hidden'], false);
|
||||||
else if (importAccounts.match(action))
|
else if (importAccounts.match(action))
|
||||||
return normalizeAccounts(state, action.payload.accounts);
|
return normalizeAccounts(state, action.payload.accounts);
|
||||||
else if (followAccountSuccess.match(action))
|
else if (followAccountSuccess.match(action)) {
|
||||||
return state
|
return state
|
||||||
.update(
|
.update(
|
||||||
action.payload.relationship.id,
|
action.payload.relationship.id,
|
||||||
(account) => account?.update('followers_count', (n) => n + 1),
|
(account) => account?.update('followers_count', (n) => n + 1),
|
||||||
)
|
)
|
||||||
.update(
|
.update(
|
||||||
currentUserId,
|
getCurrentUser(),
|
||||||
(account) => account?.update('following_count', (n) => n + 1),
|
(account) => account?.update('following_count', (n) => n + 1),
|
||||||
);
|
);
|
||||||
else if (unfollowAccountSuccess.match(action))
|
} else if (unfollowAccountSuccess.match(action))
|
||||||
return state
|
return state
|
||||||
.update(
|
.update(
|
||||||
action.payload.relationship.id,
|
action.payload.relationship.id,
|
||||||
|
@ -74,7 +76,7 @@ export const accountsReducer: Reducer<typeof initialState> = (
|
||||||
account?.update('followers_count', (n) => Math.max(0, n - 1)),
|
account?.update('followers_count', (n) => Math.max(0, n - 1)),
|
||||||
)
|
)
|
||||||
.update(
|
.update(
|
||||||
currentUserId,
|
getCurrentUser(),
|
||||||
(account) =>
|
(account) =>
|
||||||
account?.update('following_count', (n) => Math.max(0, n - 1)),
|
account?.update('following_count', (n) => Math.max(0, n - 1)),
|
||||||
);
|
);
|
||||||
|
|
17
spec/system/unlogged_spec.rb
Normal file
17
spec/system/unlogged_spec.rb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
describe 'UnloggedBrowsing' do
|
||||||
|
subject { page }
|
||||||
|
|
||||||
|
before do
|
||||||
|
visit root_path
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'loads the home page' do
|
||||||
|
expect(subject).to have_css('div.app-holder')
|
||||||
|
|
||||||
|
expect(subject).to have_css('div.columns-area__panels__main')
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue