parent
a6cd0711b0
commit
cbfa28b9cc
@ -0,0 +1,11 @@
|
||||
import Avatar from '../../../components/avatar';
|
||||
import DisplayName from '../../../components/display_name';
|
||||
|
||||
const AutosuggestAccount = ({ account }) => (
|
||||
<div style={{ overflow: 'hidden' }}>
|
||||
<div style={{ float: 'left', marginRight: '5px' }}><Avatar src={account.get('avatar')} size={18} /></div>
|
||||
<DisplayName account={account} />
|
||||
</div>
|
||||
);
|
||||
|
||||
export default AutosuggestAccount;
|
@ -0,0 +1,15 @@
|
||||
import { connect } from 'react-redux';
|
||||
import AutosuggestAccount from '../components/autosuggest_account';
|
||||
import { makeGetAccount } from '../../../selectors';
|
||||
|
||||
const makeMapStateToProps = () => {
|
||||
const getAccount = makeGetAccount();
|
||||
|
||||
const mapStateToProps = (state, { id }) => ({
|
||||
account: getAccount(state, id)
|
||||
});
|
||||
|
||||
return mapStateToProps;
|
||||
};
|
||||
|
||||
export default connect(makeMapStateToProps)(AutosuggestAccount);
|
@ -0,0 +1,25 @@
|
||||
class SearchService < BaseService
|
||||
def call(query, resolve = false)
|
||||
return if query.blank?
|
||||
|
||||
username, domain = query.split('@')
|
||||
|
||||
if domain.nil?
|
||||
search_all(username)
|
||||
else
|
||||
search_or_resolve(username, domain, resolve)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def search_all(username)
|
||||
Account.search_for(username)
|
||||
end
|
||||
|
||||
def search_or_resolve(username, domain, resolve)
|
||||
results = Account.search_for("#{username} #{domain}")
|
||||
return [FollowRemoteAccountService.new.call("#{username}@#{domain}")] if results.empty? && resolve
|
||||
results
|
||||
end
|
||||
end
|
Loading…
Reference in new issue