diff --git a/app/javascript/flavours/glitch/actions/accounts.js b/app/javascript/flavours/glitch/actions/accounts.js
index f5871beb3..750740879 100644
--- a/app/javascript/flavours/glitch/actions/accounts.js
+++ b/app/javascript/flavours/glitch/actions/accounts.js
@@ -553,10 +553,12 @@ export function expandFollowingFail(id, error) {
export function fetchRelationships(accountIds) {
return (dispatch, getState) => {
- const loadedRelationships = getState().get('relationships');
+ const state = getState();
+ const loadedRelationships = state.get('relationships');
const newAccountIds = accountIds.filter(id => loadedRelationships.get(id, null) === null);
+ const signedIn = !!state.getIn(['meta', 'me']);
- if (newAccountIds.length === 0) {
+ if (!signedIn || newAccountIds.length === 0) {
return;
}
diff --git a/app/javascript/flavours/glitch/actions/markers.js b/app/javascript/flavours/glitch/actions/markers.js
index a086def97..6a0549f7f 100644
--- a/app/javascript/flavours/glitch/actions/markers.js
+++ b/app/javascript/flavours/glitch/actions/markers.js
@@ -1,6 +1,7 @@
import api from 'flavours/glitch/util/api';
import { debounce } from 'lodash';
import compareId from 'flavours/glitch/util/compare_id';
+import { List as ImmutableList } from 'immutable';
export const MARKERS_FETCH_REQUEST = 'MARKERS_FETCH_REQUEST';
export const MARKERS_FETCH_SUCCESS = 'MARKERS_FETCH_SUCCESS';
@@ -11,7 +12,7 @@ export const synchronouslySubmitMarkers = () => (dispatch, getState) => {
const accessToken = getState().getIn(['meta', 'access_token'], '');
const params = _buildParams(getState());
- if (Object.keys(params).length === 0) {
+ if (Object.keys(params).length === 0 || accessToken === '') {
return;
}
@@ -63,7 +64,7 @@ export const synchronouslySubmitMarkers = () => (dispatch, getState) => {
const _buildParams = (state) => {
const params = {};
- const lastHomeId = state.getIn(['timelines', 'home', 'items']).find(item => item !== null);
+ const lastHomeId = state.getIn(['timelines', 'home', 'items'], ImmutableList()).find(item => item !== null);
const lastNotificationId = state.getIn(['notifications', 'lastReadId']);
if (lastHomeId && compareId(lastHomeId, state.getIn(['markers', 'home'])) > 0) {
@@ -82,9 +83,10 @@ const _buildParams = (state) => {
};
const debouncedSubmitMarkers = debounce((dispatch, getState) => {
- const params = _buildParams(getState());
+ const accessToken = getState().getIn(['meta', 'access_token'], '');
+ const params = _buildParams(getState());
- if (Object.keys(params).length === 0) {
+ if (Object.keys(params).length === 0 || accessToken === '') {
return;
}
diff --git a/app/javascript/flavours/glitch/containers/mastodon.js b/app/javascript/flavours/glitch/containers/mastodon.js
index d07b2b3d0..a6ec5845d 100644
--- a/app/javascript/flavours/glitch/containers/mastodon.js
+++ b/app/javascript/flavours/glitch/containers/mastodon.js
@@ -31,7 +31,7 @@ const createIdentityContext = state => ({
signedIn: !!state.meta.me,
accountId: state.meta.me,
accessToken: state.meta.access_token,
- permissions: state.role.permissions,
+ permissions: state.role ? state.role.permissions : 0,
});
export default class Mastodon extends React.PureComponent {
diff --git a/app/javascript/flavours/glitch/features/account/components/header.js b/app/javascript/flavours/glitch/features/account/components/header.js
index cc2a7d4d4..866122cbd 100644
--- a/app/javascript/flavours/glitch/features/account/components/header.js
+++ b/app/javascript/flavours/glitch/features/account/components/header.js
@@ -124,6 +124,7 @@ class Header extends ImmutablePureComponent {
render () {
const { account, hidden, intl, domain } = this.props;
+ const { signedIn } = this.context.identity;
if (!account) {
return null;
@@ -157,12 +158,12 @@ class Header extends ImmutablePureComponent {
}
if (me !== account.get('id')) {
- if (!account.get('relationship')) { // Wait until the relationship is loaded
+ if (signedIn && !account.get('relationship')) { // Wait until the relationship is loaded
actionBtn = '';
} else if (account.getIn(['relationship', 'requested'])) {
actionBtn = ;
} else if (!account.getIn(['relationship', 'blocking'])) {
- actionBtn = ;
+ actionBtn = ;
} else if (account.getIn(['relationship', 'blocking'])) {
actionBtn = ;
}
@@ -182,7 +183,7 @@ class Header extends ImmutablePureComponent {
lockedIcon = ;
}
- if (account.get('id') !== me && !suspended) {
+ if (signedIn && account.get('id') !== me && !suspended) {
menu.push({ text: intl.formatMessage(messages.mention, { name: account.get('username') }), action: this.props.onMention });
menu.push({ text: intl.formatMessage(messages.direct, { name: account.get('username') }), action: this.props.onDirect });
menu.push(null);
@@ -209,7 +210,7 @@ class Header extends ImmutablePureComponent {
menu.push({ text: intl.formatMessage(messages.mutes), to: '/mutes' });
menu.push({ text: intl.formatMessage(messages.blocks), to: '/blocks' });
menu.push({ text: intl.formatMessage(messages.domain_blocks), to: '/domain_blocks' });
- } else {
+ } else if (signedIn) {
if (account.getIn(['relationship', 'following'])) {
if (!account.getIn(['relationship', 'muting'])) {
if (account.getIn(['relationship', 'showing_reblogs'])) {
@@ -242,7 +243,7 @@ class Header extends ImmutablePureComponent {
menu.push({ text: intl.formatMessage(messages.report, { name: account.get('username') }), action: this.props.onReport });
}
- if (account.get('acct') !== account.get('username')) {
+ if (signedIn && account.get('acct') !== account.get('username')) {
const domain = account.get('acct').split('@')[1];
menu.push(null);
@@ -301,7 +302,7 @@ class Header extends ImmutablePureComponent {
)}
-
+
)}
@@ -313,7 +314,7 @@ class Header extends ImmutablePureComponent {
-
+ {signedIn && }
{!(suspended || hidden) && (
diff --git a/app/javascript/flavours/glitch/features/explore/results.js b/app/javascript/flavours/glitch/features/explore/results.js
index 8eac63c2c..b50ca5465 100644
--- a/app/javascript/flavours/glitch/features/explore/results.js
+++ b/app/javascript/flavours/glitch/features/explore/results.js
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
-import { FormattedMessage } from 'react-intl';
+import { injectIntl, defineMessages, FormattedMessage } from 'react-intl';
import { connect } from 'react-redux';
import { expandSearch } from 'flavours/glitch/actions/search';
import Account from 'flavours/glitch/containers/account_container';
@@ -11,9 +11,14 @@ import { List as ImmutableList } from 'immutable';
import LoadMore from 'flavours/glitch/components/load_more';
import LoadingIndicator from 'flavours/glitch/components/loading_indicator';
+const messages = defineMessages({
+ title: { id: 'search_results.title', defaultMessage: 'Search for {q}' },
+});
+
const mapStateToProps = state => ({
isLoading: state.getIn(['search', 'isLoading']),
results: state.getIn(['search', 'results']),
+ q: state.getIn(['search', 'searchTerm']),
});
const appendLoadMore = (id, list, onLoadMore) => {
@@ -37,6 +42,7 @@ const renderStatuses = (results, onLoadMore) => appendLoadMore('statuses', resul
)), onLoadMore);
export default @connect(mapStateToProps)
+@injectIntl
class Results extends React.PureComponent {
static propTypes = {
@@ -44,6 +50,8 @@ class Results extends React.PureComponent {
isLoading: PropTypes.bool,
multiColumn: PropTypes.bool,
dispatch: PropTypes.func.isRequired,
+ q: PropTypes.string,
+ intl: PropTypes.object,
};
state = {
@@ -64,7 +72,7 @@ class Results extends React.PureComponent {
}
render () {
- const { isLoading, results } = this.props;
+ const { intl, isLoading, q, results } = this.props;
const { type } = this.state;
let filteredResults = ImmutableList();
diff --git a/app/javascript/flavours/glitch/features/hashtag_timeline/index.js b/app/javascript/flavours/glitch/features/hashtag_timeline/index.js
index 87a52b269..1b73f4b8a 100644
--- a/app/javascript/flavours/glitch/features/hashtag_timeline/index.js
+++ b/app/javascript/flavours/glitch/features/hashtag_timeline/index.js
@@ -31,6 +31,10 @@ class HashtagTimeline extends React.PureComponent {
disconnects = [];
+ static contextTypes = {
+ identity: PropTypes.object,
+ };
+
static propTypes = {
params: PropTypes.object.isRequired,
columnId: PropTypes.string,
@@ -158,6 +162,11 @@ class HashtagTimeline extends React.PureComponent {
handleFollow = () => {
const { dispatch, params, tag } = this.props;
const { id } = params;
+ const { signedIn } = this.context.identity;
+
+ if (!signedIn) {
+ return;
+ }
if (tag.get('following')) {
dispatch(unfollowHashtag(id));
@@ -170,6 +179,7 @@ class HashtagTimeline extends React.PureComponent {
const { hasUnread, columnId, multiColumn, tag, intl } = this.props;
const { id, local } = this.props.params;
const pinned = !!columnId;
+ const { signedIn } = this.context.identity;
let followButton;
@@ -177,7 +187,7 @@ class HashtagTimeline extends React.PureComponent {
const following = tag.get('following');
followButton = (
-