mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-30 17:11:43 +00:00
Merge branch 'main' into route-data-refactor
This commit is contained in:
commit
72b4d14b47
|
@ -21,7 +21,6 @@ import {
|
||||||
enableNsfw,
|
enableNsfw,
|
||||||
getIdFromString,
|
getIdFromString,
|
||||||
getQueryParams,
|
getQueryParams,
|
||||||
getQueryString,
|
|
||||||
isBrowser,
|
isBrowser,
|
||||||
myAuth,
|
myAuth,
|
||||||
setIsoData,
|
setIsoData,
|
||||||
|
@ -80,7 +79,7 @@ export class CreatePost extends Component<
|
||||||
|
|
||||||
if (communityResponse) {
|
if (communityResponse) {
|
||||||
const communityChoice: Choice = {
|
const communityChoice: Choice = {
|
||||||
label: communityResponse.community_view.community.name,
|
label: communityResponse.community_view.community.title,
|
||||||
value: communityResponse.community_view.community.id.toString(),
|
value: communityResponse.community_view.community.id.toString(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -179,18 +178,21 @@ export class CreatePost extends Component<
|
||||||
updateUrl({ communityId }: Partial<CreatePostProps>) {
|
updateUrl({ communityId }: Partial<CreatePostProps>) {
|
||||||
const { communityId: urlCommunityId } = getCreatePostQueryParams();
|
const { communityId: urlCommunityId } = getCreatePostQueryParams();
|
||||||
|
|
||||||
const queryParams: QueryParams<CreatePostProps> = {
|
|
||||||
communityId: (communityId ?? urlCommunityId)?.toString(),
|
|
||||||
};
|
|
||||||
|
|
||||||
const locationState = this.props.history.location.state as
|
const locationState = this.props.history.location.state as
|
||||||
| PostFormParams
|
| PostFormParams
|
||||||
| undefined;
|
| undefined;
|
||||||
|
|
||||||
this.props.history.replace(
|
const url = new URL(location.href);
|
||||||
`/create_post${getQueryString(queryParams)}`,
|
|
||||||
locationState
|
const newId = (communityId ?? urlCommunityId)?.toString();
|
||||||
);
|
|
||||||
|
if (newId !== undefined) {
|
||||||
|
url.searchParams.set("communityId", newId);
|
||||||
|
} else {
|
||||||
|
url.searchParams.delete("communityId");
|
||||||
|
}
|
||||||
|
|
||||||
|
history.replaceState(locationState, "", url);
|
||||||
|
|
||||||
this.fetchCommunity();
|
this.fetchCommunity();
|
||||||
}
|
}
|
||||||
|
@ -237,12 +239,12 @@ export class CreatePost extends Component<
|
||||||
if (op === UserOperation.GetCommunity) {
|
if (op === UserOperation.GetCommunity) {
|
||||||
const {
|
const {
|
||||||
community_view: {
|
community_view: {
|
||||||
community: { name, id },
|
community: { title, id },
|
||||||
},
|
},
|
||||||
} = wsJsonToRes<GetCommunityResponse>(msg);
|
} = wsJsonToRes<GetCommunityResponse>(msg);
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
selectedCommunityChoice: { label: name, value: id.toString() },
|
selectedCommunityChoice: { label: title, value: id.toString() },
|
||||||
loading: false,
|
loading: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -644,13 +644,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
|
|
||||||
handleCommunitySelect(choice: Choice) {
|
handleCommunitySelect(choice: Choice) {
|
||||||
if (this.props.onSelectCommunity) {
|
if (this.props.onSelectCommunity) {
|
||||||
this.setState({
|
|
||||||
loading: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.props.onSelectCommunity(choice);
|
this.props.onSelectCommunity(choice);
|
||||||
|
|
||||||
this.setState({ loading: false });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue