isImage,
toast,
setupTippy,
- hostname,
pictrsDeleteToast,
validTitle,
wsSubscribe,
communityToChoice,
fetchCommunities,
choicesConfig,
+ communitySelectName,
} from "../utils";
import autosize from "autosize";
<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>
debounce,
fetchCommunities,
communityToChoice,
- hostname,
fetchUsers,
personToChoice,
capitalizeFirstLetter,
+ communitySelectName,
+ personSelectName,
} from "../utils";
import { PostListing } from "./post-listing";
import { HtmlTags } from "./html-tags";
>
<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>
<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>
export function communityToChoice(cv: CommunityView): ChoicesValue {
let choice: ChoicesValue = {
value: cv.community.id.toString(),
- label: cv.community.name,
+ label: communitySelectName(cv),
};
return choice;
}
export function personToChoice(pvs: PersonViewSafe): ChoicesValue {
let choice: ChoicesValue = {
value: pvs.person.id.toString(),
- label: pvs.person.name,
+ label: personSelectName(pvs),
};
return choice;
}
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}`;
+}