mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-12-23 11:21:26 +00:00
Fixing an issue with federated search names
This commit is contained in:
parent
a136d064ae
commit
15305f4b29
3 changed files with 20 additions and 19 deletions
|
@ -29,7 +29,6 @@ import {
|
|||
isImage,
|
||||
toast,
|
||||
setupTippy,
|
||||
hostname,
|
||||
pictrsDeleteToast,
|
||||
validTitle,
|
||||
wsSubscribe,
|
||||
|
@ -40,6 +39,7 @@ import {
|
|||
communityToChoice,
|
||||
fetchCommunities,
|
||||
choicesConfig,
|
||||
communitySelectName,
|
||||
} from "../utils";
|
||||
import autosize from "autosize";
|
||||
|
||||
|
@ -302,11 +302,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
|||
<option>{i18n.t("select_a_community")}</option>
|
||||
{this.props.communities.map(cv => (
|
||||
<option value={cv.community.id}>
|
||||
{cv.community.local
|
||||
? cv.community.name
|
||||
: `${hostname(cv.community.actor_id)}/${
|
||||
cv.community.name
|
||||
}`}
|
||||
{communitySelectName(cv)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
|
|
|
@ -44,10 +44,11 @@ import {
|
|||
debounce,
|
||||
fetchCommunities,
|
||||
communityToChoice,
|
||||
hostname,
|
||||
fetchUsers,
|
||||
personToChoice,
|
||||
capitalizeFirstLetter,
|
||||
communitySelectName,
|
||||
personSelectName,
|
||||
} from "../utils";
|
||||
import { PostListing } from "./post-listing";
|
||||
import { HtmlTags } from "./html-tags";
|
||||
|
@ -570,11 +571,7 @@ export class Search extends Component<any, SearchState> {
|
|||
>
|
||||
<option value="0">{i18n.t("all")}</option>
|
||||
{this.state.communities.map(cv => (
|
||||
<option value={cv.community.id}>
|
||||
{cv.community.local
|
||||
? cv.community.name
|
||||
: `${hostname(cv.community.actor_id)}/${cv.community.name}`}
|
||||
</option>
|
||||
<option value={cv.community.id}>{communitySelectName(cv)}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -597,11 +594,7 @@ export class Search extends Component<any, SearchState> {
|
|||
<option value="0">{i18n.t("all")}</option>
|
||||
{this.state.creator && (
|
||||
<option value={this.state.creator.person.id}>
|
||||
{this.state.creator.person.local
|
||||
? this.state.creator.person.name
|
||||
: `${hostname(this.state.creator.person.actor_id)}/${
|
||||
this.state.creator.person.name
|
||||
}`}
|
||||
{personSelectName(this.state.creator)}
|
||||
</option>
|
||||
)}
|
||||
</select>
|
||||
|
|
|
@ -1243,7 +1243,7 @@ interface ChoicesValue {
|
|||
export function communityToChoice(cv: CommunityView): ChoicesValue {
|
||||
let choice: ChoicesValue = {
|
||||
value: cv.community.id.toString(),
|
||||
label: cv.community.name,
|
||||
label: communitySelectName(cv),
|
||||
};
|
||||
return choice;
|
||||
}
|
||||
|
@ -1251,7 +1251,7 @@ export function communityToChoice(cv: CommunityView): ChoicesValue {
|
|||
export function personToChoice(pvs: PersonViewSafe): ChoicesValue {
|
||||
let choice: ChoicesValue = {
|
||||
value: pvs.person.id.toString(),
|
||||
label: pvs.person.name,
|
||||
label: personSelectName(pvs),
|
||||
};
|
||||
return choice;
|
||||
}
|
||||
|
@ -1316,3 +1316,15 @@ export const choicesConfig = {
|
|||
noChoices: "has-no-choices",
|
||||
},
|
||||
};
|
||||
|
||||
export function communitySelectName(cv: CommunityView): string {
|
||||
return cv.community.local
|
||||
? cv.community.name
|
||||
: `${hostname(cv.community.actor_id)}/${cv.community.name}`;
|
||||
}
|
||||
|
||||
export function personSelectName(pvs: PersonViewSafe): string {
|
||||
return pvs.person.local
|
||||
? pvs.person.name
|
||||
: `${hostname(pvs.person.actor_id)}/${pvs.person.name}`;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue