Fix reworked search

This commit is contained in:
Eugen Rochko 2017-03-31 22:44:12 +02:00
parent 7ddda65269
commit d93d6f5124
8 changed files with 30 additions and 23 deletions

View File

@ -25,6 +25,10 @@ export function submitSearch() {
return (dispatch, getState) => { return (dispatch, getState) => {
const value = getState().getIn(['search', 'value']); const value = getState().getIn(['search', 'value']);
if (value.length === 0) {
return;
}
dispatch(fetchSearchRequest()); dispatch(fetchSearchRequest());
api(getState).get('/api/v1/search', { api(getState).get('/api/v1/search', {

View File

@ -10,6 +10,7 @@ const Search = React.createClass({
propTypes: { propTypes: {
value: React.PropTypes.string.isRequired, value: React.PropTypes.string.isRequired,
submitted: React.PropTypes.bool,
onChange: React.PropTypes.func.isRequired, onChange: React.PropTypes.func.isRequired,
onSubmit: React.PropTypes.func.isRequired, onSubmit: React.PropTypes.func.isRequired,
onClear: React.PropTypes.func.isRequired, onClear: React.PropTypes.func.isRequired,
@ -40,8 +41,8 @@ const Search = React.createClass({
}, },
render () { render () {
const { intl, value } = this.props; const { intl, value, submitted } = this.props;
const hasValue = value.length > 0; const hasValue = value.length > 0 || submitted;
return ( return (
<div className='search'> <div className='search'>

View File

@ -8,7 +8,8 @@ import {
import Search from '../components/search'; import Search from '../components/search';
const mapStateToProps = state => ({ const mapStateToProps = state => ({
value: state.getIn(['search', 'value']) value: state.getIn(['search', 'value']),
submitted: state.getIn(['search', 'submitted'])
}); });
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({

View File

@ -70,9 +70,9 @@ const Compose = React.createClass({
<ComposeFormContainer /> <ComposeFormContainer />
</div> </div>
<Motion defaultStyle={{ x: -300 }} style={{ x: spring(showSearch ? 0 : -300, { stiffness: 210, damping: 20 }) }}> <Motion defaultStyle={{ x: -100 }} style={{ x: spring(showSearch ? 0 : -100, { stiffness: 210, damping: 20 }) }}>
{({ x }) => {({ x }) =>
<div className='drawer__inner darker' style={{ transform: `translateX(${x}px)` }}> <div className='drawer__inner darker' style={{ transform: `translateX(${x}%)` }}>
<SearchResultsContainer /> <SearchResultsContainer />
</div> </div>
} }

View File

@ -43,8 +43,6 @@ const GettingStarted = ({ intl, me }) => {
<div className='scrollable optionally-scrollable' style={{ display: 'flex', flexDirection: 'column' }}> <div className='scrollable optionally-scrollable' style={{ display: 'flex', flexDirection: 'column' }}>
<div className='static-content getting-started'> <div className='static-content getting-started'>
<p><FormattedMessage id='getting_started.about_addressing' defaultMessage='You can follow people if you know their username and the domain they are on by entering an e-mail-esque address into the form at the top of the sidebar.' /></p>
<p><FormattedMessage id='getting_started.about_shortcuts' defaultMessage='If the target user is on the same domain as you, just the username will work. The same rule applies to mentioning people in statuses.' /></p>
<p><FormattedMessage id='getting_started.open_source_notice' defaultMessage='Mastodon is open source software. You can contribute or report issues on github at {github}. {apps}.' values={{ github: <a href="https://github.com/tootsuite/mastodon" target="_blank">tootsuite/mastodon</a>, apps: <a href="https://github.com/tootsuite/mastodon/blob/master/docs/Using-Mastodon/Apps.md" target="_blank"><FormattedMessage id='getting_started.apps' defaultMessage='Various apps are available' /></a> }} /></p> <p><FormattedMessage id='getting_started.open_source_notice' defaultMessage='Mastodon is open source software. You can contribute or report issues on github at {github}. {apps}.' values={{ github: <a href="https://github.com/tootsuite/mastodon" target="_blank">tootsuite/mastodon</a>, apps: <a href="https://github.com/tootsuite/mastodon/blob/master/docs/Using-Mastodon/Apps.md" target="_blank"><FormattedMessage id='getting_started.apps' defaultMessage='Various apps are available' /></a> }} /></p>
</div> </div>
</div> </div>

View File

@ -23,16 +23,16 @@ const initialState = Immutable.Map();
export default function relationships(state = initialState, action) { export default function relationships(state = initialState, action) {
switch(action.type) { switch(action.type) {
case ACCOUNT_FOLLOW_SUCCESS: case ACCOUNT_FOLLOW_SUCCESS:
case ACCOUNT_UNFOLLOW_SUCCESS: case ACCOUNT_UNFOLLOW_SUCCESS:
case ACCOUNT_BLOCK_SUCCESS: case ACCOUNT_BLOCK_SUCCESS:
case ACCOUNT_UNBLOCK_SUCCESS: case ACCOUNT_UNBLOCK_SUCCESS:
case ACCOUNT_MUTE_SUCCESS: case ACCOUNT_MUTE_SUCCESS:
case ACCOUNT_UNMUTE_SUCCESS: case ACCOUNT_UNMUTE_SUCCESS:
return normalizeRelationship(state, action.relationship); return normalizeRelationship(state, action.relationship);
case RELATIONSHIPS_FETCH_SUCCESS: case RELATIONSHIPS_FETCH_SUCCESS:
return normalizeRelationships(state, action.relationships); return normalizeRelationships(state, action.relationships);
default: default:
return state; return state;
} }
}; };

View File

@ -1120,9 +1120,8 @@ a.status__content__spoiler-link {
box-sizing: border-box; box-sizing: border-box;
overflow-y: auto; overflow-y: auto;
padding-bottom: 235px; padding-bottom: 235px;
background: image-url('mastodon-getting-started.png') no-repeat bottom left; background: image-url('mastodon-getting-started.png') no-repeat 0 100% local;
height: auto; height: 100%;
min-height: 100%;
p { p {
color: $color2; color: $color2;
@ -1793,6 +1792,10 @@ button.active i.fa-retweet {
&.active { &.active {
transform: translateZ(0) rotate(90deg); transform: translateZ(0) rotate(90deg);
} }
&:hover {
color: $color5;
}
} }
} }

View File

@ -2,10 +2,10 @@
class SearchService < BaseService class SearchService < BaseService
def call(query, limit, resolve = false, account = nil) def call(query, limit, resolve = false, account = nil)
return if query.blank?
results = { accounts: [], hashtags: [], statuses: [] } results = { accounts: [], hashtags: [], statuses: [] }
return results if query.blank?
if query =~ /\Ahttps?:\/\// if query =~ /\Ahttps?:\/\//
resource = FetchRemoteResourceService.new.call(query) resource = FetchRemoteResourceService.new.call(query)