Switch front end to use lemmy-js-client. Fixes #1090
This commit is contained in:
parent
e007006daf
commit
6b938415a0
45 changed files with 292 additions and 1307 deletions
1
README.md
vendored
1
README.md
vendored
|
@ -112,6 +112,7 @@ Each Lemmy server can set its own moderation policy; appointing site-wide admins
|
||||||
|
|
||||||
### Libraries
|
### Libraries
|
||||||
|
|
||||||
|
- [lemmy-js-client](https://github.com/LemmyNet/lemmy-js-client)
|
||||||
- [Kotlin API ( under development )](https://github.com/eiknat/lemmy-client)
|
- [Kotlin API ( under development )](https://github.com/eiknat/lemmy-client)
|
||||||
|
|
||||||
## Support / Donate
|
## Support / Donate
|
||||||
|
|
1
ui/package.json
vendored
1
ui/package.json
vendored
|
@ -37,6 +37,7 @@
|
||||||
"inferno-router": "^7.4.2",
|
"inferno-router": "^7.4.2",
|
||||||
"js-cookie": "^2.2.0",
|
"js-cookie": "^2.2.0",
|
||||||
"jwt-decode": "^2.2.0",
|
"jwt-decode": "^2.2.0",
|
||||||
|
"lemmy-js-client": "^1.0.2",
|
||||||
"markdown-it": "^11.0.0",
|
"markdown-it": "^11.0.0",
|
||||||
"markdown-it-container": "^3.0.0",
|
"markdown-it-container": "^3.0.0",
|
||||||
"markdown-it-emoji": "^1.4.0",
|
"markdown-it-emoji": "^1.4.0",
|
||||||
|
|
2
ui/src/api_tests/comment.spec.ts
vendored
2
ui/src/api_tests/comment.spec.ts
vendored
|
@ -21,7 +21,7 @@ import {
|
||||||
API,
|
API,
|
||||||
} from './shared';
|
} from './shared';
|
||||||
|
|
||||||
import { PostResponse } from '../interfaces';
|
import { PostResponse } from 'lemmy-js-client';
|
||||||
|
|
||||||
let postRes: PostResponse;
|
let postRes: PostResponse;
|
||||||
|
|
||||||
|
|
6
ui/src/api_tests/shared.ts
vendored
6
ui/src/api_tests/shared.ts
vendored
|
@ -36,7 +36,7 @@ import {
|
||||||
SortType,
|
SortType,
|
||||||
ListingType,
|
ListingType,
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
|
|
||||||
export interface API {
|
export interface API {
|
||||||
url: string;
|
url: string;
|
||||||
|
@ -668,8 +668,8 @@ export async function saveUserSettingsBio(
|
||||||
let form: UserSettingsForm = {
|
let form: UserSettingsForm = {
|
||||||
show_nsfw: true,
|
show_nsfw: true,
|
||||||
theme: 'darkly',
|
theme: 'darkly',
|
||||||
default_sort_type: SortType.Active,
|
default_sort_type: Object.keys(SortType).indexOf(SortType.Active),
|
||||||
default_listing_type: ListingType.All,
|
default_listing_type: Object.keys(ListingType).indexOf(ListingType.All),
|
||||||
lang: 'en',
|
lang: 'en',
|
||||||
show_avatars: true,
|
show_avatars: true,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
|
|
2
ui/src/components/admin-settings.tsx
vendored
2
ui/src/components/admin-settings.tsx
vendored
|
@ -9,7 +9,7 @@ import {
|
||||||
SiteConfigForm,
|
SiteConfigForm,
|
||||||
GetSiteConfigResponse,
|
GetSiteConfigResponse,
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { WebSocketService } from '../services';
|
import { WebSocketService } from '../services';
|
||||||
import { wsJsonToRes, capitalizeFirstLetter, toast, randomStr } from '../utils';
|
import { wsJsonToRes, capitalizeFirstLetter, toast, randomStr } from '../utils';
|
||||||
import autosize from 'autosize';
|
import autosize from 'autosize';
|
||||||
|
|
2
ui/src/components/comment-form.tsx
vendored
2
ui/src/components/comment-form.tsx
vendored
|
@ -8,7 +8,7 @@ import {
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
UserOperation,
|
UserOperation,
|
||||||
CommentResponse,
|
CommentResponse,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { capitalizeFirstLetter, wsJsonToRes } from '../utils';
|
import { capitalizeFirstLetter, wsJsonToRes } from '../utils';
|
||||||
import { WebSocketService, UserService } from '../services';
|
import { WebSocketService, UserService } from '../services';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
5
ui/src/components/comment-node.tsx
vendored
5
ui/src/components/comment-node.tsx
vendored
|
@ -16,10 +16,9 @@ import {
|
||||||
AddAdminForm,
|
AddAdminForm,
|
||||||
TransferCommunityForm,
|
TransferCommunityForm,
|
||||||
TransferSiteForm,
|
TransferSiteForm,
|
||||||
BanType,
|
|
||||||
CommentSortType,
|
|
||||||
SortType,
|
SortType,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
|
import { CommentSortType, BanType } from '../interfaces';
|
||||||
import { WebSocketService, UserService } from '../services';
|
import { WebSocketService, UserService } from '../services';
|
||||||
import {
|
import {
|
||||||
mdToHtml,
|
mdToHtml,
|
||||||
|
|
4
ui/src/components/comment-nodes.tsx
vendored
4
ui/src/components/comment-nodes.tsx
vendored
|
@ -1,11 +1,11 @@
|
||||||
import { Component } from 'inferno';
|
import { Component } from 'inferno';
|
||||||
|
import { CommentSortType } from '../interfaces';
|
||||||
import {
|
import {
|
||||||
CommentNode as CommentNodeI,
|
CommentNode as CommentNodeI,
|
||||||
CommunityUser,
|
CommunityUser,
|
||||||
UserView,
|
UserView,
|
||||||
CommentSortType,
|
|
||||||
SortType,
|
SortType,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { commentSort, commentSortSortType } from '../utils';
|
import { commentSort, commentSortSortType } from '../utils';
|
||||||
import { CommentNode } from './comment-node';
|
import { CommentNode } from './comment-node';
|
||||||
|
|
||||||
|
|
4
ui/src/components/communities.tsx
vendored
4
ui/src/components/communities.tsx
vendored
|
@ -13,7 +13,7 @@ import {
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
Site,
|
Site,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { WebSocketService } from '../services';
|
import { WebSocketService } from '../services';
|
||||||
import { wsJsonToRes, toast, getPageFromProps } from '../utils';
|
import { wsJsonToRes, toast, getPageFromProps } from '../utils';
|
||||||
import { CommunityLink } from './community-link';
|
import { CommunityLink } from './community-link';
|
||||||
|
@ -218,7 +218,7 @@ export class Communities extends Component<any, CommunitiesState> {
|
||||||
|
|
||||||
refetch() {
|
refetch() {
|
||||||
let listCommunitiesForm: ListCommunitiesForm = {
|
let listCommunitiesForm: ListCommunitiesForm = {
|
||||||
sort: SortType[SortType.TopAll],
|
sort: SortType.TopAll,
|
||||||
limit: communityLimit,
|
limit: communityLimit,
|
||||||
page: this.state.page,
|
page: this.state.page,
|
||||||
};
|
};
|
||||||
|
|
4
ui/src/components/community-form.tsx
vendored
4
ui/src/components/community-form.tsx
vendored
|
@ -9,12 +9,12 @@ import {
|
||||||
ListCategoriesResponse,
|
ListCategoriesResponse,
|
||||||
CommunityResponse,
|
CommunityResponse,
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
} from '../interfaces';
|
Community,
|
||||||
|
} from 'lemmy-js-client';
|
||||||
import { WebSocketService } from '../services';
|
import { WebSocketService } from '../services';
|
||||||
import { wsJsonToRes, capitalizeFirstLetter, toast, randomStr } from '../utils';
|
import { wsJsonToRes, capitalizeFirstLetter, toast, randomStr } from '../utils';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
||||||
import { Community } from '../interfaces';
|
|
||||||
import { MarkdownTextArea } from './markdown-textarea';
|
import { MarkdownTextArea } from './markdown-textarea';
|
||||||
import { ImageUploadForm } from './image-upload-form';
|
import { ImageUploadForm } from './image-upload-form';
|
||||||
|
|
||||||
|
|
2
ui/src/components/community-link.tsx
vendored
2
ui/src/components/community-link.tsx
vendored
|
@ -1,6 +1,6 @@
|
||||||
import { Component } from 'inferno';
|
import { Component } from 'inferno';
|
||||||
import { Link } from 'inferno-router';
|
import { Link } from 'inferno-router';
|
||||||
import { Community } from '../interfaces';
|
import { Community } from 'lemmy-js-client';
|
||||||
import { hostname, pictrsAvatarThumbnail, showAvatars } from '../utils';
|
import { hostname, pictrsAvatarThumbnail, showAvatars } from '../utils';
|
||||||
|
|
||||||
interface CommunityOther {
|
interface CommunityOther {
|
||||||
|
|
28
ui/src/components/community.tsx
vendored
28
ui/src/components/community.tsx
vendored
|
@ -2,6 +2,7 @@ import { Component, linkEvent } from 'inferno';
|
||||||
import { Helmet } from 'inferno-helmet';
|
import { Helmet } from 'inferno-helmet';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { retryWhen, delay, take } from 'rxjs/operators';
|
import { retryWhen, delay, take } from 'rxjs/operators';
|
||||||
|
import { DataType } from '../interfaces';
|
||||||
import {
|
import {
|
||||||
UserOperation,
|
UserOperation,
|
||||||
Community as CommunityI,
|
Community as CommunityI,
|
||||||
|
@ -14,7 +15,6 @@ import {
|
||||||
GetPostsForm,
|
GetPostsForm,
|
||||||
GetCommunityForm,
|
GetCommunityForm,
|
||||||
ListingType,
|
ListingType,
|
||||||
DataType,
|
|
||||||
GetPostsResponse,
|
GetPostsResponse,
|
||||||
PostResponse,
|
PostResponse,
|
||||||
AddModToCommunityResponse,
|
AddModToCommunityResponse,
|
||||||
|
@ -26,7 +26,7 @@ import {
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
Site,
|
Site,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { WebSocketService } from '../services';
|
import { WebSocketService } from '../services';
|
||||||
import { PostListings } from './post-listings';
|
import { PostListings } from './post-listings';
|
||||||
import { CommentNodes } from './comment-nodes';
|
import { CommentNodes } from './comment-nodes';
|
||||||
|
@ -78,7 +78,7 @@ interface CommunityProps {
|
||||||
|
|
||||||
interface UrlParams {
|
interface UrlParams {
|
||||||
dataType?: string;
|
dataType?: string;
|
||||||
sort?: string;
|
sort?: SortType;
|
||||||
page?: number;
|
page?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,9 +287,7 @@ export class Community extends Component<any, State> {
|
||||||
<SortSelect sort={this.state.sort} onChange={this.handleSortChange} />
|
<SortSelect sort={this.state.sort} onChange={this.handleSortChange} />
|
||||||
</span>
|
</span>
|
||||||
<a
|
<a
|
||||||
href={`/feeds/c/${this.state.communityName}.xml?sort=${
|
href={`/feeds/c/${this.state.communityName}.xml?sort=${this.state.sort}`}
|
||||||
SortType[this.state.sort]
|
|
||||||
}`}
|
|
||||||
target="_blank"
|
target="_blank"
|
||||||
title="RSS"
|
title="RSS"
|
||||||
rel="noopener"
|
rel="noopener"
|
||||||
|
@ -336,20 +334,18 @@ export class Community extends Component<any, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSortChange(val: SortType) {
|
handleSortChange(val: SortType) {
|
||||||
this.updateUrl({ sort: SortType[val].toLowerCase(), page: 1 });
|
this.updateUrl({ sort: val, page: 1 });
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleDataTypeChange(val: DataType) {
|
handleDataTypeChange(val: DataType) {
|
||||||
this.updateUrl({ dataType: DataType[val].toLowerCase(), page: 1 });
|
this.updateUrl({ dataType: DataType[val], page: 1 });
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateUrl(paramUpdates: UrlParams) {
|
updateUrl(paramUpdates: UrlParams) {
|
||||||
const dataTypeStr =
|
const dataTypeStr = paramUpdates.dataType || DataType[this.state.dataType];
|
||||||
paramUpdates.dataType || DataType[this.state.dataType].toLowerCase();
|
const sortStr = paramUpdates.sort || this.state.sort;
|
||||||
const sortStr =
|
|
||||||
paramUpdates.sort || SortType[this.state.sort].toLowerCase();
|
|
||||||
const page = paramUpdates.page || this.state.page;
|
const page = paramUpdates.page || this.state.page;
|
||||||
this.props.history.push(
|
this.props.history.push(
|
||||||
`/c/${this.state.community.name}/data_type/${dataTypeStr}/sort/${sortStr}/page/${page}`
|
`/c/${this.state.community.name}/data_type/${dataTypeStr}/sort/${sortStr}/page/${page}`
|
||||||
|
@ -361,8 +357,8 @@ export class Community extends Component<any, State> {
|
||||||
let getPostsForm: GetPostsForm = {
|
let getPostsForm: GetPostsForm = {
|
||||||
page: this.state.page,
|
page: this.state.page,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
sort: SortType[this.state.sort],
|
sort: this.state.sort,
|
||||||
type_: ListingType[ListingType.Community],
|
type_: ListingType.Community,
|
||||||
community_id: this.state.community.id,
|
community_id: this.state.community.id,
|
||||||
};
|
};
|
||||||
WebSocketService.Instance.getPosts(getPostsForm);
|
WebSocketService.Instance.getPosts(getPostsForm);
|
||||||
|
@ -370,8 +366,8 @@ export class Community extends Component<any, State> {
|
||||||
let getCommentsForm: GetCommentsForm = {
|
let getCommentsForm: GetCommentsForm = {
|
||||||
page: this.state.page,
|
page: this.state.page,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
sort: SortType[this.state.sort],
|
sort: this.state.sort,
|
||||||
type_: ListingType[ListingType.Community],
|
type_: ListingType.Community,
|
||||||
community_id: this.state.community.id,
|
community_id: this.state.community.id,
|
||||||
};
|
};
|
||||||
WebSocketService.Instance.getComments(getCommentsForm);
|
WebSocketService.Instance.getComments(getCommentsForm);
|
||||||
|
|
2
ui/src/components/create-community.tsx
vendored
2
ui/src/components/create-community.tsx
vendored
|
@ -9,7 +9,7 @@ import {
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
Site,
|
Site,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { toast, wsJsonToRes } from '../utils';
|
import { toast, wsJsonToRes } from '../utils';
|
||||||
import { WebSocketService, UserService } from '../services';
|
import { WebSocketService, UserService } from '../services';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
2
ui/src/components/create-post.tsx
vendored
2
ui/src/components/create-post.tsx
vendored
|
@ -11,7 +11,7 @@ import {
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
Site,
|
Site,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
||||||
interface CreatePostState {
|
interface CreatePostState {
|
||||||
|
|
2
ui/src/components/create-private-message.tsx
vendored
2
ui/src/components/create-private-message.tsx
vendored
|
@ -10,7 +10,7 @@ import {
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
Site,
|
Site,
|
||||||
PrivateMessageFormParams,
|
PrivateMessageFormParams,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { toast, wsJsonToRes } from '../utils';
|
import { toast, wsJsonToRes } from '../utils';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
||||||
|
|
2
ui/src/components/footer.tsx
vendored
2
ui/src/components/footer.tsx
vendored
|
@ -9,7 +9,7 @@ import {
|
||||||
UserOperation,
|
UserOperation,
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
|
|
||||||
interface FooterState {
|
interface FooterState {
|
||||||
version: string;
|
version: string;
|
||||||
|
|
2
ui/src/components/iframely-card.tsx
vendored
2
ui/src/components/iframely-card.tsx
vendored
|
@ -1,5 +1,5 @@
|
||||||
import { Component, linkEvent } from 'inferno';
|
import { Component, linkEvent } from 'inferno';
|
||||||
import { Post } from '../interfaces';
|
import { Post } from 'lemmy-js-client';
|
||||||
import { mdToHtml } from '../utils';
|
import { mdToHtml } from '../utils';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
||||||
|
|
6
ui/src/components/inbox.tsx
vendored
6
ui/src/components/inbox.tsx
vendored
|
@ -19,7 +19,7 @@ import {
|
||||||
PrivateMessageResponse,
|
PrivateMessageResponse,
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
Site,
|
Site,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { WebSocketService, UserService } from '../services';
|
import { WebSocketService, UserService } from '../services';
|
||||||
import {
|
import {
|
||||||
wsJsonToRes,
|
wsJsonToRes,
|
||||||
|
@ -399,7 +399,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
|
|
||||||
refetch() {
|
refetch() {
|
||||||
let repliesForm: GetRepliesForm = {
|
let repliesForm: GetRepliesForm = {
|
||||||
sort: SortType[this.state.sort],
|
sort: this.state.sort,
|
||||||
unread_only: this.state.unreadOrAll == UnreadOrAll.Unread,
|
unread_only: this.state.unreadOrAll == UnreadOrAll.Unread,
|
||||||
page: this.state.page,
|
page: this.state.page,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
|
@ -407,7 +407,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
WebSocketService.Instance.getReplies(repliesForm);
|
WebSocketService.Instance.getReplies(repliesForm);
|
||||||
|
|
||||||
let userMentionsForm: GetUserMentionsForm = {
|
let userMentionsForm: GetUserMentionsForm = {
|
||||||
sort: SortType[this.state.sort],
|
sort: this.state.sort,
|
||||||
unread_only: this.state.unreadOrAll == UnreadOrAll.Unread,
|
unread_only: this.state.unreadOrAll == UnreadOrAll.Unread,
|
||||||
page: this.state.page,
|
page: this.state.page,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
|
|
2
ui/src/components/instances.tsx
vendored
2
ui/src/components/instances.tsx
vendored
|
@ -6,7 +6,7 @@ import {
|
||||||
UserOperation,
|
UserOperation,
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { WebSocketService } from '../services';
|
import { WebSocketService } from '../services';
|
||||||
import { wsJsonToRes, toast } from '../utils';
|
import { wsJsonToRes, toast } from '../utils';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
10
ui/src/components/listing-type-select.tsx
vendored
10
ui/src/components/listing-type-select.tsx
vendored
|
@ -1,7 +1,7 @@
|
||||||
import { Component, linkEvent } from 'inferno';
|
import { Component, linkEvent } from 'inferno';
|
||||||
import { ListingType } from '../interfaces';
|
import { ListingType } from 'lemmy-js-client';
|
||||||
import { UserService } from '../services';
|
import { UserService } from '../services';
|
||||||
|
import { randomStr } from '../utils';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
||||||
interface ListingTypeSelectProps {
|
interface ListingTypeSelectProps {
|
||||||
|
@ -17,6 +17,8 @@ export class ListingTypeSelect extends Component<
|
||||||
ListingTypeSelectProps,
|
ListingTypeSelectProps,
|
||||||
ListingTypeSelectState
|
ListingTypeSelectState
|
||||||
> {
|
> {
|
||||||
|
private id = `listing-type-input-${randomStr()}`;
|
||||||
|
|
||||||
private emptyState: ListingTypeSelectState = {
|
private emptyState: ListingTypeSelectState = {
|
||||||
type_: this.props.type_,
|
type_: this.props.type_,
|
||||||
};
|
};
|
||||||
|
@ -42,6 +44,7 @@ export class ListingTypeSelect extends Component<
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
|
id={`${this.id}-subscribed`}
|
||||||
type="radio"
|
type="radio"
|
||||||
value={ListingType.Subscribed}
|
value={ListingType.Subscribed}
|
||||||
checked={this.state.type_ == ListingType.Subscribed}
|
checked={this.state.type_ == ListingType.Subscribed}
|
||||||
|
@ -56,6 +59,7 @@ export class ListingTypeSelect extends Component<
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
|
id={`${this.id}-all`}
|
||||||
type="radio"
|
type="radio"
|
||||||
value={ListingType.All}
|
value={ListingType.All}
|
||||||
checked={this.state.type_ == ListingType.All}
|
checked={this.state.type_ == ListingType.All}
|
||||||
|
@ -68,6 +72,6 @@ export class ListingTypeSelect extends Component<
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTypeChange(i: ListingTypeSelect, event: any) {
|
handleTypeChange(i: ListingTypeSelect, event: any) {
|
||||||
i.props.onChange(Number(event.target.value));
|
i.props.onChange(event.target.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
ui/src/components/login.tsx
vendored
2
ui/src/components/login.tsx
vendored
|
@ -12,7 +12,7 @@ import {
|
||||||
GetCaptchaResponse,
|
GetCaptchaResponse,
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
Site,
|
Site,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { WebSocketService, UserService } from '../services';
|
import { WebSocketService, UserService } from '../services';
|
||||||
import { wsJsonToRes, validEmail, toast } from '../utils';
|
import { wsJsonToRes, validEmail, toast } from '../utils';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
40
ui/src/components/main.tsx
vendored
40
ui/src/components/main.tsx
vendored
|
@ -13,7 +13,6 @@ import {
|
||||||
SortType,
|
SortType,
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
ListingType,
|
ListingType,
|
||||||
DataType,
|
|
||||||
SiteResponse,
|
SiteResponse,
|
||||||
GetPostsResponse,
|
GetPostsResponse,
|
||||||
PostResponse,
|
PostResponse,
|
||||||
|
@ -26,7 +25,8 @@ import {
|
||||||
AddAdminResponse,
|
AddAdminResponse,
|
||||||
BanUserResponse,
|
BanUserResponse,
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
|
import { DataType } from '../interfaces';
|
||||||
import { WebSocketService, UserService } from '../services';
|
import { WebSocketService, UserService } from '../services';
|
||||||
import { PostListings } from './post-listings';
|
import { PostListings } from './post-listings';
|
||||||
import { CommentNodes } from './comment-nodes';
|
import { CommentNodes } from './comment-nodes';
|
||||||
|
@ -82,9 +82,9 @@ interface MainProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UrlParams {
|
interface UrlParams {
|
||||||
listingType?: string;
|
listingType?: ListingType;
|
||||||
dataType?: string;
|
dataType?: string;
|
||||||
sort?: string;
|
sort?: SortType;
|
||||||
page?: number;
|
page?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ export class Main extends Component<any, MainState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let listCommunitiesForm: ListCommunitiesForm = {
|
let listCommunitiesForm: ListCommunitiesForm = {
|
||||||
sort: SortType[SortType.Hot],
|
sort: SortType.Hot,
|
||||||
limit: 6,
|
limit: 6,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -334,13 +334,9 @@ export class Main extends Component<any, MainState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateUrl(paramUpdates: UrlParams) {
|
updateUrl(paramUpdates: UrlParams) {
|
||||||
const listingTypeStr =
|
const listingTypeStr = paramUpdates.listingType || this.state.listingType;
|
||||||
paramUpdates.listingType ||
|
const dataTypeStr = paramUpdates.dataType || DataType[this.state.dataType];
|
||||||
ListingType[this.state.listingType].toLowerCase();
|
const sortStr = paramUpdates.sort || this.state.sort;
|
||||||
const dataTypeStr =
|
|
||||||
paramUpdates.dataType || DataType[this.state.dataType].toLowerCase();
|
|
||||||
const sortStr =
|
|
||||||
paramUpdates.sort || SortType[this.state.sort].toLowerCase();
|
|
||||||
const page = paramUpdates.page || this.state.page;
|
const page = paramUpdates.page || this.state.page;
|
||||||
this.props.history.push(
|
this.props.history.push(
|
||||||
`/home/data_type/${dataTypeStr}/listing_type/${listingTypeStr}/sort/${sortStr}/page/${page}`
|
`/home/data_type/${dataTypeStr}/listing_type/${listingTypeStr}/sort/${sortStr}/page/${page}`
|
||||||
|
@ -549,7 +545,7 @@ export class Main extends Component<any, MainState> {
|
||||||
</span>
|
</span>
|
||||||
{this.state.listingType == ListingType.All && (
|
{this.state.listingType == ListingType.All && (
|
||||||
<a
|
<a
|
||||||
href={`/feeds/all.xml?sort=${SortType[this.state.sort]}`}
|
href={`/feeds/all.xml?sort=${this.state.sort}`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener"
|
rel="noopener"
|
||||||
title="RSS"
|
title="RSS"
|
||||||
|
@ -562,9 +558,7 @@ export class Main extends Component<any, MainState> {
|
||||||
{UserService.Instance.user &&
|
{UserService.Instance.user &&
|
||||||
this.state.listingType == ListingType.Subscribed && (
|
this.state.listingType == ListingType.Subscribed && (
|
||||||
<a
|
<a
|
||||||
href={`/feeds/front/${UserService.Instance.auth}.xml?sort=${
|
href={`/feeds/front/${UserService.Instance.auth}.xml?sort=${this.state.sort}`}
|
||||||
SortType[this.state.sort]
|
|
||||||
}`}
|
|
||||||
target="_blank"
|
target="_blank"
|
||||||
title="RSS"
|
title="RSS"
|
||||||
rel="noopener"
|
rel="noopener"
|
||||||
|
@ -631,17 +625,17 @@ export class Main extends Component<any, MainState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSortChange(val: SortType) {
|
handleSortChange(val: SortType) {
|
||||||
this.updateUrl({ sort: SortType[val].toLowerCase(), page: 1 });
|
this.updateUrl({ sort: val, page: 1 });
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleListingTypeChange(val: ListingType) {
|
handleListingTypeChange(val: ListingType) {
|
||||||
this.updateUrl({ listingType: ListingType[val].toLowerCase(), page: 1 });
|
this.updateUrl({ listingType: val, page: 1 });
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleDataTypeChange(val: DataType) {
|
handleDataTypeChange(val: DataType) {
|
||||||
this.updateUrl({ dataType: DataType[val].toLowerCase(), page: 1 });
|
this.updateUrl({ dataType: DataType[val], page: 1 });
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,16 +644,16 @@ export class Main extends Component<any, MainState> {
|
||||||
let getPostsForm: GetPostsForm = {
|
let getPostsForm: GetPostsForm = {
|
||||||
page: this.state.page,
|
page: this.state.page,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
sort: SortType[this.state.sort],
|
sort: this.state.sort,
|
||||||
type_: ListingType[this.state.listingType],
|
type_: this.state.listingType,
|
||||||
};
|
};
|
||||||
WebSocketService.Instance.getPosts(getPostsForm);
|
WebSocketService.Instance.getPosts(getPostsForm);
|
||||||
} else {
|
} else {
|
||||||
let getCommentsForm: GetCommentsForm = {
|
let getCommentsForm: GetCommentsForm = {
|
||||||
page: this.state.page,
|
page: this.state.page,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
sort: SortType[this.state.sort],
|
sort: this.state.sort,
|
||||||
type_: ListingType[this.state.listingType],
|
type_: this.state.listingType,
|
||||||
};
|
};
|
||||||
WebSocketService.Instance.getComments(getCommentsForm);
|
WebSocketService.Instance.getComments(getCommentsForm);
|
||||||
}
|
}
|
||||||
|
|
2
ui/src/components/modlog.tsx
vendored
2
ui/src/components/modlog.tsx
vendored
|
@ -19,7 +19,7 @@ import {
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
Site,
|
Site,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { WebSocketService } from '../services';
|
import { WebSocketService } from '../services';
|
||||||
import { wsJsonToRes, addTypeInfo, fetchLimit, toast } from '../utils';
|
import { wsJsonToRes, addTypeInfo, fetchLimit, toast } from '../utils';
|
||||||
import { MomentTime } from './moment-time';
|
import { MomentTime } from './moment-time';
|
||||||
|
|
8
ui/src/components/navbar.tsx
vendored
8
ui/src/components/navbar.tsx
vendored
|
@ -18,7 +18,7 @@ import {
|
||||||
PrivateMessage,
|
PrivateMessage,
|
||||||
PrivateMessageResponse,
|
PrivateMessageResponse,
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import {
|
import {
|
||||||
wsJsonToRes,
|
wsJsonToRes,
|
||||||
pictrsAvatarThumbnail,
|
pictrsAvatarThumbnail,
|
||||||
|
@ -137,7 +137,7 @@ export class Navbar extends Component<any, NavbarState> {
|
||||||
this.context.router.history.push(`/search/`);
|
this.context.router.history.push(`/search/`);
|
||||||
} else {
|
} else {
|
||||||
this.context.router.history.push(
|
this.context.router.history.push(
|
||||||
`/search/q/${searchParam}/type/all/sort/topall/page/1`
|
`/search/q/${searchParam}/type/All/sort/TopAll/page/1`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -477,14 +477,14 @@ export class Navbar extends Component<any, NavbarState> {
|
||||||
fetchUnreads() {
|
fetchUnreads() {
|
||||||
console.log('Fetching unreads...');
|
console.log('Fetching unreads...');
|
||||||
let repliesForm: GetRepliesForm = {
|
let repliesForm: GetRepliesForm = {
|
||||||
sort: SortType[SortType.New],
|
sort: SortType.New,
|
||||||
unread_only: true,
|
unread_only: true,
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
};
|
};
|
||||||
|
|
||||||
let userMentionsForm: GetUserMentionsForm = {
|
let userMentionsForm: GetUserMentionsForm = {
|
||||||
sort: SortType[SortType.New],
|
sort: SortType.New,
|
||||||
unread_only: true,
|
unread_only: true,
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
|
|
2
ui/src/components/password_change.tsx
vendored
2
ui/src/components/password_change.tsx
vendored
|
@ -9,7 +9,7 @@ import {
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
Site,
|
Site,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { WebSocketService, UserService } from '../services';
|
import { WebSocketService, UserService } from '../services';
|
||||||
import { wsJsonToRes, capitalizeFirstLetter, toast } from '../utils';
|
import { wsJsonToRes, capitalizeFirstLetter, toast } from '../utils';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
12
ui/src/components/post-form.tsx
vendored
12
ui/src/components/post-form.tsx
vendored
|
@ -18,7 +18,7 @@ import {
|
||||||
SearchType,
|
SearchType,
|
||||||
SearchResponse,
|
SearchResponse,
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { WebSocketService, UserService } from '../services';
|
import { WebSocketService, UserService } from '../services';
|
||||||
import {
|
import {
|
||||||
wsJsonToRes,
|
wsJsonToRes,
|
||||||
|
@ -121,7 +121,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
);
|
);
|
||||||
|
|
||||||
let listCommunitiesForm: ListCommunitiesForm = {
|
let listCommunitiesForm: ListCommunitiesForm = {
|
||||||
sort: SortType[SortType.TopAll],
|
sort: SortType.TopAll,
|
||||||
limit: 9999,
|
limit: 9999,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -405,8 +405,8 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
if (validURL(this.state.postForm.url)) {
|
if (validURL(this.state.postForm.url)) {
|
||||||
let form: SearchForm = {
|
let form: SearchForm = {
|
||||||
q: this.state.postForm.url,
|
q: this.state.postForm.url,
|
||||||
type_: SearchType[SearchType.Url],
|
type_: SearchType.Url,
|
||||||
sort: SortType[SortType.TopAll],
|
sort: SortType.TopAll,
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: 6,
|
limit: 6,
|
||||||
};
|
};
|
||||||
|
@ -433,8 +433,8 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
fetchSimilarPosts() {
|
fetchSimilarPosts() {
|
||||||
let form: SearchForm = {
|
let form: SearchForm = {
|
||||||
q: this.state.postForm.name,
|
q: this.state.postForm.name,
|
||||||
type_: SearchType[SearchType.Posts],
|
type_: SearchType.Posts,
|
||||||
sort: SortType[SortType.TopAll],
|
sort: SortType.TopAll,
|
||||||
community_id: this.state.postForm.community_id,
|
community_id: this.state.postForm.community_id,
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: 6,
|
limit: 6,
|
||||||
|
|
4
ui/src/components/post-listing.tsx
vendored
4
ui/src/components/post-listing.tsx
vendored
|
@ -11,14 +11,14 @@ import {
|
||||||
SavePostForm,
|
SavePostForm,
|
||||||
CommunityUser,
|
CommunityUser,
|
||||||
UserView,
|
UserView,
|
||||||
BanType,
|
|
||||||
BanFromCommunityForm,
|
BanFromCommunityForm,
|
||||||
BanUserForm,
|
BanUserForm,
|
||||||
AddModToCommunityForm,
|
AddModToCommunityForm,
|
||||||
AddAdminForm,
|
AddAdminForm,
|
||||||
TransferSiteForm,
|
TransferSiteForm,
|
||||||
TransferCommunityForm,
|
TransferCommunityForm,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
|
import { BanType } from '../interfaces';
|
||||||
import { MomentTime } from './moment-time';
|
import { MomentTime } from './moment-time';
|
||||||
import { PostForm } from './post-form';
|
import { PostForm } from './post-form';
|
||||||
import { IFramelyCard } from './iframely-card';
|
import { IFramelyCard } from './iframely-card';
|
||||||
|
|
2
ui/src/components/post-listings.tsx
vendored
2
ui/src/components/post-listings.tsx
vendored
|
@ -1,6 +1,6 @@
|
||||||
import { Component } from 'inferno';
|
import { Component } from 'inferno';
|
||||||
import { Link } from 'inferno-router';
|
import { Link } from 'inferno-router';
|
||||||
import { Post, SortType } from '../interfaces';
|
import { Post, SortType } from 'lemmy-js-client';
|
||||||
import { postSort } from '../utils';
|
import { postSort } from '../utils';
|
||||||
import { PostListing } from './post-listing';
|
import { PostListing } from './post-listing';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
9
ui/src/components/post.tsx
vendored
9
ui/src/components/post.tsx
vendored
|
@ -11,8 +11,6 @@ import {
|
||||||
Comment,
|
Comment,
|
||||||
MarkCommentAsReadForm,
|
MarkCommentAsReadForm,
|
||||||
CommentResponse,
|
CommentResponse,
|
||||||
CommentSortType,
|
|
||||||
CommentViewType,
|
|
||||||
CommunityUser,
|
CommunityUser,
|
||||||
CommunityResponse,
|
CommunityResponse,
|
||||||
CommentNode as CommentNodeI,
|
CommentNode as CommentNodeI,
|
||||||
|
@ -28,7 +26,8 @@ import {
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
GetCommunityResponse,
|
GetCommunityResponse,
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
|
import { CommentSortType, CommentViewType } from '../interfaces';
|
||||||
import { WebSocketService, UserService } from '../services';
|
import { WebSocketService, UserService } from '../services';
|
||||||
import {
|
import {
|
||||||
wsJsonToRes,
|
wsJsonToRes,
|
||||||
|
@ -439,8 +438,8 @@ export class Post extends Component<any, PostState> {
|
||||||
if (this.state.post.url) {
|
if (this.state.post.url) {
|
||||||
let form: SearchForm = {
|
let form: SearchForm = {
|
||||||
q: this.state.post.url,
|
q: this.state.post.url,
|
||||||
type_: SearchType[SearchType.Url],
|
type_: SearchType.Url,
|
||||||
sort: SortType[SortType.TopAll],
|
sort: SortType.TopAll,
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: 6,
|
limit: 6,
|
||||||
};
|
};
|
||||||
|
|
4
ui/src/components/private-message-form.tsx
vendored
4
ui/src/components/private-message-form.tsx
vendored
|
@ -14,7 +14,7 @@ import {
|
||||||
GetUserDetailsForm,
|
GetUserDetailsForm,
|
||||||
SortType,
|
SortType,
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { WebSocketService } from '../services';
|
import { WebSocketService } from '../services';
|
||||||
import {
|
import {
|
||||||
capitalizeFirstLetter,
|
capitalizeFirstLetter,
|
||||||
|
@ -77,7 +77,7 @@ export class PrivateMessageForm extends Component<
|
||||||
this.state.privateMessageForm.recipient_id = this.props.params.recipient_id;
|
this.state.privateMessageForm.recipient_id = this.props.params.recipient_id;
|
||||||
let form: GetUserDetailsForm = {
|
let form: GetUserDetailsForm = {
|
||||||
user_id: this.state.privateMessageForm.recipient_id,
|
user_id: this.state.privateMessageForm.recipient_id,
|
||||||
sort: SortType[SortType.New],
|
sort: SortType.New,
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
};
|
};
|
||||||
WebSocketService.Instance.getUserDetails(form);
|
WebSocketService.Instance.getUserDetails(form);
|
||||||
|
|
2
ui/src/components/private-message.tsx
vendored
2
ui/src/components/private-message.tsx
vendored
|
@ -4,7 +4,7 @@ import {
|
||||||
PrivateMessage as PrivateMessageI,
|
PrivateMessage as PrivateMessageI,
|
||||||
DeletePrivateMessageForm,
|
DeletePrivateMessageForm,
|
||||||
MarkPrivateMessageAsReadForm,
|
MarkPrivateMessageAsReadForm,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { WebSocketService, UserService } from '../services';
|
import { WebSocketService, UserService } from '../services';
|
||||||
import { mdToHtml, pictrsAvatarThumbnail, showAvatars, toast } from '../utils';
|
import { mdToHtml, pictrsAvatarThumbnail, showAvatars, toast } from '../utils';
|
||||||
import { MomentTime } from './moment-time';
|
import { MomentTime } from './moment-time';
|
||||||
|
|
24
ui/src/components/search.tsx
vendored
24
ui/src/components/search.tsx
vendored
|
@ -17,7 +17,7 @@ import {
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
Site,
|
Site,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { WebSocketService } from '../services';
|
import { WebSocketService } from '../services';
|
||||||
import {
|
import {
|
||||||
wsJsonToRes,
|
wsJsonToRes,
|
||||||
|
@ -57,8 +57,8 @@ interface SearchProps {
|
||||||
|
|
||||||
interface UrlParams {
|
interface UrlParams {
|
||||||
q?: string;
|
q?: string;
|
||||||
type_?: string;
|
type_?: SearchType;
|
||||||
sort?: string;
|
sort?: SortType;
|
||||||
page?: number;
|
page?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -461,8 +461,8 @@ export class Search extends Component<any, SearchState> {
|
||||||
search() {
|
search() {
|
||||||
let form: SearchForm = {
|
let form: SearchForm = {
|
||||||
q: this.state.q,
|
q: this.state.q,
|
||||||
type_: SearchType[this.state.type_],
|
type_: this.state.type_,
|
||||||
sort: SortType[this.state.sort],
|
sort: this.state.sort,
|
||||||
page: this.state.page,
|
page: this.state.page,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
};
|
};
|
||||||
|
@ -473,12 +473,12 @@ export class Search extends Component<any, SearchState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSortChange(val: SortType) {
|
handleSortChange(val: SortType) {
|
||||||
this.updateUrl({ sort: SortType[val].toLowerCase(), page: 1 });
|
this.updateUrl({ sort: val, page: 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTypeChange(i: Search, event: any) {
|
handleTypeChange(i: Search, event: any) {
|
||||||
i.updateUrl({
|
i.updateUrl({
|
||||||
type_: SearchType[Number(event.target.value)].toLowerCase(),
|
type_: SearchType[event.target.value],
|
||||||
page: 1,
|
page: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -487,8 +487,8 @@ export class Search extends Component<any, SearchState> {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
i.updateUrl({
|
i.updateUrl({
|
||||||
q: i.state.searchText,
|
q: i.state.searchText,
|
||||||
type_: SearchType[i.state.type_].toLowerCase(),
|
type_: i.state.type_,
|
||||||
sort: SortType[i.state.sort].toLowerCase(),
|
sort: i.state.sort,
|
||||||
page: i.state.page,
|
page: i.state.page,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -499,10 +499,8 @@ export class Search extends Component<any, SearchState> {
|
||||||
|
|
||||||
updateUrl(paramUpdates: UrlParams) {
|
updateUrl(paramUpdates: UrlParams) {
|
||||||
const qStr = paramUpdates.q || this.state.q;
|
const qStr = paramUpdates.q || this.state.q;
|
||||||
const typeStr =
|
const typeStr = paramUpdates.type_ || this.state.type_;
|
||||||
paramUpdates.type_ || SearchType[this.state.type_].toLowerCase();
|
const sortStr = paramUpdates.sort || this.state.sort;
|
||||||
const sortStr =
|
|
||||||
paramUpdates.sort || SortType[this.state.sort].toLowerCase();
|
|
||||||
const page = paramUpdates.page || this.state.page;
|
const page = paramUpdates.page || this.state.page;
|
||||||
this.props.history.push(
|
this.props.history.push(
|
||||||
`/search/q/${qStr}/type/${typeStr}/sort/${sortStr}/page/${page}`
|
`/search/q/${qStr}/type/${typeStr}/sort/${sortStr}/page/${page}`
|
||||||
|
|
2
ui/src/components/setup.tsx
vendored
2
ui/src/components/setup.tsx
vendored
|
@ -7,7 +7,7 @@ import {
|
||||||
LoginResponse,
|
LoginResponse,
|
||||||
UserOperation,
|
UserOperation,
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { WebSocketService, UserService } from '../services';
|
import { WebSocketService, UserService } from '../services';
|
||||||
import { wsJsonToRes, toast } from '../utils';
|
import { wsJsonToRes, toast } from '../utils';
|
||||||
import { SiteForm } from './site-form';
|
import { SiteForm } from './site-form';
|
||||||
|
|
2
ui/src/components/sidebar.tsx
vendored
2
ui/src/components/sidebar.tsx
vendored
|
@ -8,7 +8,7 @@ import {
|
||||||
RemoveCommunityForm,
|
RemoveCommunityForm,
|
||||||
UserView,
|
UserView,
|
||||||
AddModToCommunityForm,
|
AddModToCommunityForm,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { WebSocketService, UserService } from '../services';
|
import { WebSocketService, UserService } from '../services';
|
||||||
import { mdToHtml, getUnixTime } from '../utils';
|
import { mdToHtml, getUnixTime } from '../utils';
|
||||||
import { CommunityForm } from './community-form';
|
import { CommunityForm } from './community-form';
|
||||||
|
|
2
ui/src/components/site-form.tsx
vendored
2
ui/src/components/site-form.tsx
vendored
|
@ -2,7 +2,7 @@ import { Component, linkEvent } from 'inferno';
|
||||||
import { Prompt } from 'inferno-router';
|
import { Prompt } from 'inferno-router';
|
||||||
import { MarkdownTextArea } from './markdown-textarea';
|
import { MarkdownTextArea } from './markdown-textarea';
|
||||||
import { ImageUploadForm } from './image-upload-form';
|
import { ImageUploadForm } from './image-upload-form';
|
||||||
import { Site, SiteForm as SiteFormI } from '../interfaces';
|
import { Site, SiteForm as SiteFormI } from 'lemmy-js-client';
|
||||||
import { WebSocketService } from '../services';
|
import { WebSocketService } from '../services';
|
||||||
import { capitalizeFirstLetter, randomStr } from '../utils';
|
import { capitalizeFirstLetter, randomStr } from '../utils';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
9
ui/src/components/sort-select.tsx
vendored
9
ui/src/components/sort-select.tsx
vendored
|
@ -1,6 +1,6 @@
|
||||||
import { Component, linkEvent } from 'inferno';
|
import { Component, linkEvent } from 'inferno';
|
||||||
import { SortType } from '../interfaces';
|
import { SortType } from 'lemmy-js-client';
|
||||||
import { sortingHelpUrl } from '../utils';
|
import { sortingHelpUrl, randomStr } from '../utils';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
||||||
interface SortSelectProps {
|
interface SortSelectProps {
|
||||||
|
@ -14,6 +14,7 @@ interface SortSelectState {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SortSelect extends Component<SortSelectProps, SortSelectState> {
|
export class SortSelect extends Component<SortSelectProps, SortSelectState> {
|
||||||
|
private id = `sort-select-${randomStr()}`;
|
||||||
private emptyState: SortSelectState = {
|
private emptyState: SortSelectState = {
|
||||||
sort: this.props.sort,
|
sort: this.props.sort,
|
||||||
};
|
};
|
||||||
|
@ -33,6 +34,8 @@ export class SortSelect extends Component<SortSelectProps, SortSelectState> {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<select
|
<select
|
||||||
|
id={this.id}
|
||||||
|
name={this.id}
|
||||||
value={this.state.sort}
|
value={this.state.sort}
|
||||||
onChange={linkEvent(this, this.handleSortChange)}
|
onChange={linkEvent(this, this.handleSortChange)}
|
||||||
class="custom-select w-auto mr-2 mb-2"
|
class="custom-select w-auto mr-2 mb-2"
|
||||||
|
@ -68,6 +71,6 @@ export class SortSelect extends Component<SortSelectProps, SortSelectState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSortChange(i: SortSelect, event: any) {
|
handleSortChange(i: SortSelect, event: any) {
|
||||||
i.props.onChange(Number(event.target.value));
|
i.props.onChange(event.target.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
ui/src/components/sponsors.tsx
vendored
2
ui/src/components/sponsors.tsx
vendored
|
@ -8,7 +8,7 @@ import {
|
||||||
Site,
|
Site,
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
UserOperation,
|
UserOperation,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
import { T } from 'inferno-i18next';
|
import { T } from 'inferno-i18next';
|
||||||
import { repoUrl, wsJsonToRes, toast } from '../utils';
|
import { repoUrl, wsJsonToRes, toast } from '../utils';
|
||||||
|
|
8
ui/src/components/user-details.tsx
vendored
8
ui/src/components/user-details.tsx
vendored
|
@ -12,11 +12,11 @@ import {
|
||||||
UserDetailsResponse,
|
UserDetailsResponse,
|
||||||
UserView,
|
UserView,
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
UserDetailsView,
|
|
||||||
CommentResponse,
|
CommentResponse,
|
||||||
BanUserResponse,
|
BanUserResponse,
|
||||||
PostResponse,
|
PostResponse,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
|
import { UserDetailsView } from '../interfaces';
|
||||||
import {
|
import {
|
||||||
wsJsonToRes,
|
wsJsonToRes,
|
||||||
toast,
|
toast,
|
||||||
|
@ -35,7 +35,7 @@ interface UserDetailsProps {
|
||||||
user_id?: number;
|
user_id?: number;
|
||||||
page: number;
|
page: number;
|
||||||
limit: number;
|
limit: number;
|
||||||
sort: string;
|
sort: SortType;
|
||||||
enableDownvotes: boolean;
|
enableDownvotes: boolean;
|
||||||
enableNsfw: boolean;
|
enableNsfw: boolean;
|
||||||
view: UserDetailsView;
|
view: UserDetailsView;
|
||||||
|
@ -137,7 +137,7 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
|
||||||
];
|
];
|
||||||
|
|
||||||
// Sort it
|
// Sort it
|
||||||
if (SortType[this.props.sort] === SortType.New) {
|
if (this.props.sort === SortType.New) {
|
||||||
combined.sort((a, b) => b.data.published.localeCompare(a.data.published));
|
combined.sort((a, b) => b.data.published.localeCompare(a.data.published));
|
||||||
} else {
|
} else {
|
||||||
combined.sort((a, b) => b.data.score - a.data.score);
|
combined.sort((a, b) => b.data.score - a.data.score);
|
||||||
|
|
2
ui/src/components/user-listing.tsx
vendored
2
ui/src/components/user-listing.tsx
vendored
|
@ -1,6 +1,6 @@
|
||||||
import { Component } from 'inferno';
|
import { Component } from 'inferno';
|
||||||
import { Link } from 'inferno-router';
|
import { Link } from 'inferno-router';
|
||||||
import { UserView } from '../interfaces';
|
import { UserView } from 'lemmy-js-client';
|
||||||
import {
|
import {
|
||||||
pictrsAvatarThumbnail,
|
pictrsAvatarThumbnail,
|
||||||
showAvatars,
|
showAvatars,
|
||||||
|
|
52
ui/src/components/user.tsx
vendored
52
ui/src/components/user.tsx
vendored
|
@ -14,10 +14,10 @@ import {
|
||||||
DeleteAccountForm,
|
DeleteAccountForm,
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
UserDetailsView,
|
|
||||||
UserDetailsResponse,
|
UserDetailsResponse,
|
||||||
AddAdminResponse,
|
AddAdminResponse,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
|
import { UserDetailsView } from '../interfaces';
|
||||||
import { WebSocketService, UserService } from '../services';
|
import { WebSocketService, UserService } from '../services';
|
||||||
import {
|
import {
|
||||||
wsJsonToRes,
|
wsJsonToRes,
|
||||||
|
@ -73,7 +73,7 @@ interface UserProps {
|
||||||
|
|
||||||
interface UrlParams {
|
interface UrlParams {
|
||||||
view?: string;
|
view?: string;
|
||||||
sort?: string;
|
sort?: SortType;
|
||||||
page?: number;
|
page?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,17 +190,15 @@ export class User extends Component<any, UserState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getViewFromProps(view: any): UserDetailsView {
|
static getViewFromProps(view: string): UserDetailsView {
|
||||||
return view
|
return view ? UserDetailsView[view] : UserDetailsView.Overview;
|
||||||
? UserDetailsView[capitalizeFirstLetter(view)]
|
|
||||||
: UserDetailsView.Overview;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static getSortTypeFromProps(sort: any): SortType {
|
static getSortTypeFromProps(sort: string): SortType {
|
||||||
return sort ? routeSortTypeToEnum(sort) : SortType.New;
|
return sort ? routeSortTypeToEnum(sort) : SortType.New;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getPageFromProps(page: any): number {
|
static getPageFromProps(page: number): number {
|
||||||
return page ? Number(page) : 1;
|
return page ? Number(page) : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +270,7 @@ export class User extends Component<any, UserState> {
|
||||||
<UserDetails
|
<UserDetails
|
||||||
user_id={this.state.user_id}
|
user_id={this.state.user_id}
|
||||||
username={this.state.username}
|
username={this.state.username}
|
||||||
sort={SortType[this.state.sort]}
|
sort={this.state.sort}
|
||||||
page={this.state.page}
|
page={this.state.page}
|
||||||
limit={fetchLimit}
|
limit={fetchLimit}
|
||||||
enableDownvotes={this.state.siteRes.site.enable_downvotes}
|
enableDownvotes={this.state.siteRes.site.enable_downvotes}
|
||||||
|
@ -364,9 +362,7 @@ export class User extends Component<any, UserState> {
|
||||||
hideHot
|
hideHot
|
||||||
/>
|
/>
|
||||||
<a
|
<a
|
||||||
href={`/feeds/u/${this.state.username}.xml?sort=${
|
href={`/feeds/u/${this.state.username}.xml?sort=${this.state.sort}`}
|
||||||
SortType[this.state.sort]
|
|
||||||
}`}
|
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener"
|
rel="noopener"
|
||||||
title="RSS"
|
title="RSS"
|
||||||
|
@ -538,7 +534,11 @@ export class User extends Component<any, UserState> {
|
||||||
<div class="mr-2">{i18n.t('sort_type')}</div>
|
<div class="mr-2">{i18n.t('sort_type')}</div>
|
||||||
</label>
|
</label>
|
||||||
<ListingTypeSelect
|
<ListingTypeSelect
|
||||||
type_={this.state.userSettingsForm.default_listing_type}
|
type_={
|
||||||
|
Object.values(ListingType)[
|
||||||
|
this.state.userSettingsForm.default_listing_type
|
||||||
|
]
|
||||||
|
}
|
||||||
onChange={this.handleUserSettingsListingTypeChange}
|
onChange={this.handleUserSettingsListingTypeChange}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
|
@ -547,7 +547,11 @@ export class User extends Component<any, UserState> {
|
||||||
<div class="mr-2">{i18n.t('type')}</div>
|
<div class="mr-2">{i18n.t('type')}</div>
|
||||||
</label>
|
</label>
|
||||||
<SortSelect
|
<SortSelect
|
||||||
sort={this.state.userSettingsForm.default_sort_type}
|
sort={
|
||||||
|
Object.values(SortType)[
|
||||||
|
this.state.userSettingsForm.default_sort_type
|
||||||
|
]
|
||||||
|
}
|
||||||
onChange={this.handleUserSettingsSortTypeChange}
|
onChange={this.handleUserSettingsSortTypeChange}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
|
@ -859,10 +863,8 @@ export class User extends Component<any, UserState> {
|
||||||
|
|
||||||
updateUrl(paramUpdates: UrlParams) {
|
updateUrl(paramUpdates: UrlParams) {
|
||||||
const page = paramUpdates.page || this.state.page;
|
const page = paramUpdates.page || this.state.page;
|
||||||
const viewStr =
|
const viewStr = paramUpdates.view || UserDetailsView[this.state.view];
|
||||||
paramUpdates.view || UserDetailsView[this.state.view].toLowerCase();
|
const sortStr = paramUpdates.sort || this.state.sort;
|
||||||
const sortStr =
|
|
||||||
paramUpdates.sort || SortType[this.state.sort].toLowerCase();
|
|
||||||
this.props.history.push(
|
this.props.history.push(
|
||||||
`/u/${this.state.username}/view/${viewStr}/sort/${sortStr}/page/${page}`
|
`/u/${this.state.username}/view/${viewStr}/sort/${sortStr}/page/${page}`
|
||||||
);
|
);
|
||||||
|
@ -873,12 +875,12 @@ export class User extends Component<any, UserState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSortChange(val: SortType) {
|
handleSortChange(val: SortType) {
|
||||||
this.updateUrl({ sort: SortType[val].toLowerCase(), page: 1 });
|
this.updateUrl({ sort: val, page: 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
handleViewChange(i: User, event: any) {
|
handleViewChange(i: User, event: any) {
|
||||||
i.updateUrl({
|
i.updateUrl({
|
||||||
view: UserDetailsView[Number(event.target.value)].toLowerCase(),
|
view: UserDetailsView[Number(event.target.value)],
|
||||||
page: 1,
|
page: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -912,12 +914,16 @@ export class User extends Component<any, UserState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleUserSettingsSortTypeChange(val: SortType) {
|
handleUserSettingsSortTypeChange(val: SortType) {
|
||||||
this.state.userSettingsForm.default_sort_type = val;
|
this.state.userSettingsForm.default_sort_type = Object.keys(
|
||||||
|
SortType
|
||||||
|
).indexOf(val);
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleUserSettingsListingTypeChange(val: ListingType) {
|
handleUserSettingsListingTypeChange(val: ListingType) {
|
||||||
this.state.userSettingsForm.default_listing_type = val;
|
this.state.userSettingsForm.default_listing_type = Object.keys(
|
||||||
|
ListingType
|
||||||
|
).indexOf(val);
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1052
ui/src/interfaces.ts
vendored
1052
ui/src/interfaces.ts
vendored
File diff suppressed because it is too large
Load diff
7
ui/src/services/UserService.ts
vendored
7
ui/src/services/UserService.ts
vendored
|
@ -1,9 +1,14 @@
|
||||||
import Cookies from 'js-cookie';
|
import Cookies from 'js-cookie';
|
||||||
import { User, Claims, LoginResponse } from '../interfaces';
|
import { User, LoginResponse } from 'lemmy-js-client';
|
||||||
import { setTheme } from '../utils';
|
import { setTheme } from '../utils';
|
||||||
import jwt_decode from 'jwt-decode';
|
import jwt_decode from 'jwt-decode';
|
||||||
import { Subject, BehaviorSubject } from 'rxjs';
|
import { Subject, BehaviorSubject } from 'rxjs';
|
||||||
|
|
||||||
|
interface Claims {
|
||||||
|
id: number;
|
||||||
|
iss: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class UserService {
|
export class UserService {
|
||||||
private static _instance: UserService;
|
private static _instance: UserService;
|
||||||
public user: User;
|
public user: User;
|
||||||
|
|
218
ui/src/services/WebSocketService.ts
vendored
218
ui/src/services/WebSocketService.ts
vendored
|
@ -1,8 +1,65 @@
|
||||||
import { wsUri } from '../env';
|
import { wsUri } from '../env';
|
||||||
import {
|
import {
|
||||||
|
wsSendSearch,
|
||||||
|
wsSendGetPost,
|
||||||
|
wsSendBanUser,
|
||||||
|
wsSendGetSite,
|
||||||
|
wsSendUserJoin,
|
||||||
|
wsSendRegister,
|
||||||
|
wsSendLogin,
|
||||||
|
wsSendGetPosts,
|
||||||
|
wsSendLikePost,
|
||||||
|
wsSendEditPost,
|
||||||
|
wsSendLockPost,
|
||||||
|
wsSendSavePost,
|
||||||
|
wsSendAddAdmin,
|
||||||
|
wsSendEditSite,
|
||||||
|
wsSendGetModlog,
|
||||||
|
wsSendGetCaptcha,
|
||||||
|
wsSendCreatePost,
|
||||||
|
wsSendDeletePost,
|
||||||
|
wsSendRemovePost,
|
||||||
|
wsSendStickyPost,
|
||||||
|
wsSendGetReplies,
|
||||||
|
wsSendCreateSite,
|
||||||
|
wsSendEditComment,
|
||||||
|
wsSendLikeComment,
|
||||||
|
wsSendSaveComment,
|
||||||
|
wsSendGetComments,
|
||||||
|
wsSendGetCommunity,
|
||||||
|
wsSendTransferSite,
|
||||||
|
wsSendEditCommunity,
|
||||||
|
wsSendCreateComment,
|
||||||
|
wsSendDeleteComment,
|
||||||
|
wsSendRemoveComment,
|
||||||
|
wsSendGetSiteConfig,
|
||||||
|
wsSendMarkAllAsRead,
|
||||||
|
wsSendDeleteAccount,
|
||||||
|
wsSendPasswordReset,
|
||||||
|
wsSendPasswordChange,
|
||||||
|
wsSendListCategories,
|
||||||
|
wsSendGetUserDetails,
|
||||||
|
wsSendGetUserMentions,
|
||||||
|
wsSendSaveSiteConfig,
|
||||||
|
wsSendDeleteCommunity,
|
||||||
|
wsSendCreateCommunity,
|
||||||
|
wsSendRemoveCommunity,
|
||||||
|
wsSendFollowCommunity,
|
||||||
|
wsSendListCommunities,
|
||||||
|
wsSendBanFromCommunity,
|
||||||
|
wsSendSaveUserSettings,
|
||||||
|
wsSendMarkCommentAsRead,
|
||||||
|
wsSendGetFollowedCommunities,
|
||||||
|
wsSendAddModToCommunity,
|
||||||
|
wsSendTransferCommunity,
|
||||||
|
wsSendMarkUserMentionAsRead,
|
||||||
|
wsSendDeletePrivateMessage,
|
||||||
|
wsSendEditPrivateMessage,
|
||||||
|
wsSendGetPrivateMessages,
|
||||||
|
wsSendCreatePrivateMessage,
|
||||||
|
wsSendMarkPrivateMessageAsRead,
|
||||||
LoginForm,
|
LoginForm,
|
||||||
RegisterForm,
|
RegisterForm,
|
||||||
UserOperation,
|
|
||||||
CommunityForm,
|
CommunityForm,
|
||||||
DeleteCommunityForm,
|
DeleteCommunityForm,
|
||||||
RemoveCommunityForm,
|
RemoveCommunityForm,
|
||||||
|
@ -53,9 +110,8 @@ import {
|
||||||
GetSiteConfig,
|
GetSiteConfig,
|
||||||
GetSiteForm,
|
GetSiteForm,
|
||||||
SiteConfigForm,
|
SiteConfigForm,
|
||||||
MessageType,
|
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
} from '../interfaces';
|
} from 'lemmy-js-client';
|
||||||
import { UserService } from './';
|
import { UserService } from './';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
import { toast } from '../utils';
|
import { toast } from '../utils';
|
||||||
|
@ -100,301 +156,287 @@ export class WebSocketService {
|
||||||
|
|
||||||
public userJoin() {
|
public userJoin() {
|
||||||
let form: UserJoinForm = { auth: UserService.Instance.auth };
|
let form: UserJoinForm = { auth: UserService.Instance.auth };
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.UserJoin, form));
|
this.ws.send(wsSendUserJoin(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public login(loginForm: LoginForm) {
|
public login(form: LoginForm) {
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.Login, loginForm));
|
this.ws.send(wsSendLogin(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public register(registerForm: RegisterForm) {
|
public register(form: RegisterForm) {
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.Register, registerForm));
|
this.ws.send(wsSendRegister(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCaptcha() {
|
public getCaptcha() {
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.GetCaptcha, {}));
|
this.ws.send(wsSendGetCaptcha());
|
||||||
}
|
}
|
||||||
|
|
||||||
public createCommunity(form: CommunityForm) {
|
public createCommunity(form: CommunityForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form); // TODO all these setauths at some point would be good to make required
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.CreateCommunity, form));
|
this.ws.send(wsSendCreateCommunity(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public editCommunity(form: CommunityForm) {
|
public editCommunity(form: CommunityForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.EditCommunity, form));
|
this.ws.send(wsSendEditCommunity(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public deleteCommunity(form: DeleteCommunityForm) {
|
public deleteCommunity(form: DeleteCommunityForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.DeleteCommunity, form));
|
this.ws.send(wsSendDeleteCommunity(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public removeCommunity(form: RemoveCommunityForm) {
|
public removeCommunity(form: RemoveCommunityForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.RemoveCommunity, form));
|
this.ws.send(wsSendRemoveCommunity(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public followCommunity(followCommunityForm: FollowCommunityForm) {
|
public followCommunity(form: FollowCommunityForm) {
|
||||||
this.setAuth(followCommunityForm);
|
this.setAuth(form);
|
||||||
this.ws.send(
|
this.ws.send(wsSendFollowCommunity(form));
|
||||||
this.wsSendWrapper(UserOperation.FollowCommunity, followCommunityForm)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public listCommunities(form: ListCommunitiesForm) {
|
public listCommunities(form: ListCommunitiesForm) {
|
||||||
this.setAuth(form, false);
|
this.setAuth(form, false);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.ListCommunities, form));
|
this.ws.send(wsSendListCommunities(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getFollowedCommunities() {
|
public getFollowedCommunities() {
|
||||||
let form: GetFollowedCommunitiesForm = { auth: UserService.Instance.auth };
|
let form: GetFollowedCommunitiesForm = { auth: UserService.Instance.auth };
|
||||||
this.ws.send(
|
this.ws.send(wsSendGetFollowedCommunities(form));
|
||||||
this.wsSendWrapper(UserOperation.GetFollowedCommunities, form)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public listCategories() {
|
public listCategories() {
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.ListCategories, {}));
|
this.ws.send(wsSendListCategories());
|
||||||
}
|
}
|
||||||
|
|
||||||
public createPost(form: PostForm) {
|
public createPost(form: PostForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.CreatePost, form));
|
this.ws.send(wsSendCreatePost(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPost(form: GetPostForm) {
|
public getPost(form: GetPostForm) {
|
||||||
this.setAuth(form, false);
|
this.setAuth(form, false);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.GetPost, form));
|
this.ws.send(wsSendGetPost(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCommunity(form: GetCommunityForm) {
|
public getCommunity(form: GetCommunityForm) {
|
||||||
this.setAuth(form, false);
|
this.setAuth(form, false);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.GetCommunity, form));
|
this.ws.send(wsSendGetCommunity(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public createComment(form: CommentForm) {
|
public createComment(form: CommentForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.CreateComment, form));
|
this.ws.send(wsSendCreateComment(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public editComment(form: CommentForm) {
|
public editComment(form: CommentForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.EditComment, form));
|
this.ws.send(wsSendEditComment(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public deleteComment(form: DeleteCommentForm) {
|
public deleteComment(form: DeleteCommentForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.DeleteComment, form));
|
this.ws.send(wsSendDeleteComment(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public removeComment(form: RemoveCommentForm) {
|
public removeComment(form: RemoveCommentForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.RemoveComment, form));
|
this.ws.send(wsSendRemoveComment(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public markCommentAsRead(form: MarkCommentAsReadForm) {
|
public markCommentAsRead(form: MarkCommentAsReadForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.MarkCommentAsRead, form));
|
this.ws.send(wsSendMarkCommentAsRead(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public likeComment(form: CommentLikeForm) {
|
public likeComment(form: CommentLikeForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.CreateCommentLike, form));
|
this.ws.send(wsSendLikeComment(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public saveComment(form: SaveCommentForm) {
|
public saveComment(form: SaveCommentForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.SaveComment, form));
|
this.ws.send(wsSendSaveComment(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPosts(form: GetPostsForm) {
|
public getPosts(form: GetPostsForm) {
|
||||||
this.setAuth(form, false);
|
this.setAuth(form, false);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.GetPosts, form));
|
this.ws.send(wsSendGetPosts(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getComments(form: GetCommentsForm) {
|
public getComments(form: GetCommentsForm) {
|
||||||
this.setAuth(form, false);
|
this.setAuth(form, false);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.GetComments, form));
|
this.ws.send(wsSendGetComments(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public likePost(form: CreatePostLikeForm) {
|
public likePost(form: CreatePostLikeForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.CreatePostLike, form));
|
this.ws.send(wsSendLikePost(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public editPost(form: PostForm) {
|
public editPost(form: PostForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.EditPost, form));
|
this.ws.send(wsSendEditPost(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public deletePost(form: DeletePostForm) {
|
public deletePost(form: DeletePostForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.DeletePost, form));
|
this.ws.send(wsSendDeletePost(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public removePost(form: RemovePostForm) {
|
public removePost(form: RemovePostForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.RemovePost, form));
|
this.ws.send(wsSendRemovePost(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public lockPost(form: LockPostForm) {
|
public lockPost(form: LockPostForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.LockPost, form));
|
this.ws.send(wsSendLockPost(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public stickyPost(form: StickyPostForm) {
|
public stickyPost(form: StickyPostForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.StickyPost, form));
|
this.ws.send(wsSendStickyPost(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public savePost(form: SavePostForm) {
|
public savePost(form: SavePostForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.SavePost, form));
|
this.ws.send(wsSendSavePost(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public banFromCommunity(form: BanFromCommunityForm) {
|
public banFromCommunity(form: BanFromCommunityForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.BanFromCommunity, form));
|
this.ws.send(wsSendBanFromCommunity(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public addModToCommunity(form: AddModToCommunityForm) {
|
public addModToCommunity(form: AddModToCommunityForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.AddModToCommunity, form));
|
this.ws.send(wsSendAddModToCommunity(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public transferCommunity(form: TransferCommunityForm) {
|
public transferCommunity(form: TransferCommunityForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.TransferCommunity, form));
|
this.ws.send(wsSendTransferCommunity(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public transferSite(form: TransferSiteForm) {
|
public transferSite(form: TransferSiteForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.TransferSite, form));
|
this.ws.send(wsSendTransferSite(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public banUser(form: BanUserForm) {
|
public banUser(form: BanUserForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.BanUser, form));
|
this.ws.send(wsSendBanUser(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public addAdmin(form: AddAdminForm) {
|
public addAdmin(form: AddAdminForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.AddAdmin, form));
|
this.ws.send(wsSendAddAdmin(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getUserDetails(form: GetUserDetailsForm) {
|
public getUserDetails(form: GetUserDetailsForm) {
|
||||||
this.setAuth(form, false);
|
this.setAuth(form, false);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.GetUserDetails, form));
|
this.ws.send(wsSendGetUserDetails(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getReplies(form: GetRepliesForm) {
|
public getReplies(form: GetRepliesForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.GetReplies, form));
|
this.ws.send(wsSendGetReplies(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getUserMentions(form: GetUserMentionsForm) {
|
public getUserMentions(form: GetUserMentionsForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.GetUserMentions, form));
|
this.ws.send(wsSendGetUserMentions(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public markUserMentionAsRead(form: MarkUserMentionAsReadForm) {
|
public markUserMentionAsRead(form: MarkUserMentionAsReadForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.MarkUserMentionAsRead, form));
|
this.ws.send(wsSendMarkUserMentionAsRead(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getModlog(form: GetModlogForm) {
|
public getModlog(form: GetModlogForm) {
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.GetModlog, form));
|
this.ws.send(wsSendGetModlog(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public createSite(siteForm: SiteForm) {
|
public createSite(form: SiteForm) {
|
||||||
this.setAuth(siteForm);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.CreateSite, siteForm));
|
this.ws.send(wsSendCreateSite(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public editSite(siteForm: SiteForm) {
|
public editSite(form: SiteForm) {
|
||||||
this.setAuth(siteForm);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.EditSite, siteForm));
|
this.ws.send(wsSendEditSite(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSite(form: GetSiteForm = {}) {
|
public getSite(form: GetSiteForm = {}) {
|
||||||
this.setAuth(form, false);
|
this.setAuth(form, false);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.GetSite, form));
|
this.ws.send(wsSendGetSite(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSiteConfig() {
|
public getSiteConfig() {
|
||||||
let siteConfig: GetSiteConfig = {};
|
let form: GetSiteConfig = {};
|
||||||
this.setAuth(siteConfig);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.GetSiteConfig, siteConfig));
|
this.ws.send(wsSendGetSiteConfig(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public search(form: SearchForm) {
|
public search(form: SearchForm) {
|
||||||
this.setAuth(form, false);
|
this.setAuth(form, false);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.Search, form));
|
this.ws.send(wsSendSearch(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public markAllAsRead() {
|
public markAllAsRead() {
|
||||||
let form = {};
|
let form = {};
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.MarkAllAsRead, form));
|
this.ws.send(wsSendMarkAllAsRead(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public saveUserSettings(userSettingsForm: UserSettingsForm) {
|
public saveUserSettings(form: UserSettingsForm) {
|
||||||
this.setAuth(userSettingsForm);
|
this.setAuth(form);
|
||||||
this.ws.send(
|
this.ws.send(wsSendSaveUserSettings(form));
|
||||||
this.wsSendWrapper(UserOperation.SaveUserSettings, userSettingsForm)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public deleteAccount(form: DeleteAccountForm) {
|
public deleteAccount(form: DeleteAccountForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.DeleteAccount, form));
|
this.ws.send(wsSendDeleteAccount(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public passwordReset(form: PasswordResetForm) {
|
public passwordReset(form: PasswordResetForm) {
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.PasswordReset, form));
|
this.ws.send(wsSendPasswordReset(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public passwordChange(form: PasswordChangeForm) {
|
public passwordChange(form: PasswordChangeForm) {
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.PasswordChange, form));
|
this.ws.send(wsSendPasswordChange(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public createPrivateMessage(form: PrivateMessageForm) {
|
public createPrivateMessage(form: PrivateMessageForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.CreatePrivateMessage, form));
|
this.ws.send(wsSendCreatePrivateMessage(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public editPrivateMessage(form: EditPrivateMessageForm) {
|
public editPrivateMessage(form: EditPrivateMessageForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.EditPrivateMessage, form));
|
this.ws.send(wsSendEditPrivateMessage(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public deletePrivateMessage(form: DeletePrivateMessageForm) {
|
public deletePrivateMessage(form: DeletePrivateMessageForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.DeletePrivateMessage, form));
|
this.ws.send(wsSendDeletePrivateMessage(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public markPrivateMessageAsRead(form: MarkPrivateMessageAsReadForm) {
|
public markPrivateMessageAsRead(form: MarkPrivateMessageAsReadForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(
|
this.ws.send(wsSendMarkPrivateMessageAsRead(form));
|
||||||
this.wsSendWrapper(UserOperation.MarkPrivateMessageAsRead, form)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPrivateMessages(form: GetPrivateMessagesForm) {
|
public getPrivateMessages(form: GetPrivateMessagesForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.GetPrivateMessages, form));
|
this.ws.send(wsSendGetPrivateMessages(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public saveSiteConfig(form: SiteConfigForm) {
|
public saveSiteConfig(form: SiteConfigForm) {
|
||||||
this.setAuth(form);
|
this.setAuth(form);
|
||||||
this.ws.send(this.wsSendWrapper(UserOperation.SaveSiteConfig, form));
|
this.ws.send(wsSendSaveSiteConfig(form));
|
||||||
}
|
|
||||||
|
|
||||||
private wsSendWrapper(op: UserOperation, data: MessageType) {
|
|
||||||
let send = { op: UserOperation[op], data: data };
|
|
||||||
console.log(send);
|
|
||||||
return JSON.stringify(send);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private setAuth(obj: any, throwErr: boolean = true) {
|
private setAuth(obj: any, throwErr: boolean = true) {
|
||||||
|
|
38
ui/src/utils.ts
vendored
38
ui/src/utils.ts
vendored
|
@ -34,9 +34,7 @@ import {
|
||||||
PrivateMessage,
|
PrivateMessage,
|
||||||
User,
|
User,
|
||||||
SortType,
|
SortType,
|
||||||
CommentSortType,
|
|
||||||
ListingType,
|
ListingType,
|
||||||
DataType,
|
|
||||||
SearchType,
|
SearchType,
|
||||||
WebSocketResponse,
|
WebSocketResponse,
|
||||||
WebSocketJsonResponse,
|
WebSocketJsonResponse,
|
||||||
|
@ -44,7 +42,9 @@ import {
|
||||||
SearchResponse,
|
SearchResponse,
|
||||||
CommentResponse,
|
CommentResponse,
|
||||||
PostResponse,
|
PostResponse,
|
||||||
} from './interfaces';
|
} from 'lemmy-js-client';
|
||||||
|
|
||||||
|
import { CommentSortType, DataType } from './interfaces';
|
||||||
import { UserService, WebSocketService } from './services';
|
import { UserService, WebSocketService } from './services';
|
||||||
|
|
||||||
import Tribute from 'tributejs/src/Tribute.js';
|
import Tribute from 'tributejs/src/Tribute.js';
|
||||||
|
@ -273,27 +273,11 @@ export function capitalizeFirstLetter(str: string): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function routeSortTypeToEnum(sort: string): SortType {
|
export function routeSortTypeToEnum(sort: string): SortType {
|
||||||
if (sort == 'new') {
|
return SortType[sort];
|
||||||
return SortType.New;
|
|
||||||
} else if (sort == 'hot') {
|
|
||||||
return SortType.Hot;
|
|
||||||
} else if (sort == 'active') {
|
|
||||||
return SortType.Active;
|
|
||||||
} else if (sort == 'topday') {
|
|
||||||
return SortType.TopDay;
|
|
||||||
} else if (sort == 'topweek') {
|
|
||||||
return SortType.TopWeek;
|
|
||||||
} else if (sort == 'topmonth') {
|
|
||||||
return SortType.TopMonth;
|
|
||||||
} else if (sort == 'topyear') {
|
|
||||||
return SortType.TopYear;
|
|
||||||
} else if (sort == 'topall') {
|
|
||||||
return SortType.TopAll;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function routeListingTypeToEnum(type: string): ListingType {
|
export function routeListingTypeToEnum(type: string): ListingType {
|
||||||
return ListingType[capitalizeFirstLetter(type)];
|
return ListingType[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function routeDataTypeToEnum(type: string): DataType {
|
export function routeDataTypeToEnum(type: string): DataType {
|
||||||
|
@ -730,8 +714,8 @@ function userSearch(text: string, cb: any) {
|
||||||
if (text) {
|
if (text) {
|
||||||
let form: SearchForm = {
|
let form: SearchForm = {
|
||||||
q: text,
|
q: text,
|
||||||
type_: SearchType[SearchType.Users],
|
type_: SearchType.Users,
|
||||||
sort: SortType[SortType.TopAll],
|
sort: SortType.TopAll,
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: mentionDropdownFetchLimit,
|
limit: mentionDropdownFetchLimit,
|
||||||
};
|
};
|
||||||
|
@ -767,8 +751,8 @@ function communitySearch(text: string, cb: any) {
|
||||||
if (text) {
|
if (text) {
|
||||||
let form: SearchForm = {
|
let form: SearchForm = {
|
||||||
q: text,
|
q: text,
|
||||||
type_: SearchType[SearchType.Communities],
|
type_: SearchType.Communities,
|
||||||
sort: SortType[SortType.TopAll],
|
sort: SortType.TopAll,
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: mentionDropdownFetchLimit,
|
limit: mentionDropdownFetchLimit,
|
||||||
};
|
};
|
||||||
|
@ -804,7 +788,7 @@ export function getListingTypeFromProps(props: any): ListingType {
|
||||||
return props.match.params.listing_type
|
return props.match.params.listing_type
|
||||||
? routeListingTypeToEnum(props.match.params.listing_type)
|
? routeListingTypeToEnum(props.match.params.listing_type)
|
||||||
: UserService.Instance.user
|
: UserService.Instance.user
|
||||||
? UserService.Instance.user.default_listing_type
|
? Object.values(ListingType)[UserService.Instance.user.default_listing_type]
|
||||||
: ListingType.All;
|
: ListingType.All;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -819,7 +803,7 @@ export function getSortTypeFromProps(props: any): SortType {
|
||||||
return props.match.params.sort
|
return props.match.params.sort
|
||||||
? routeSortTypeToEnum(props.match.params.sort)
|
? routeSortTypeToEnum(props.match.params.sort)
|
||||||
: UserService.Instance.user
|
: UserService.Instance.user
|
||||||
? UserService.Instance.user.default_sort_type
|
? Object.values(SortType)[UserService.Instance.user.default_sort_type]
|
||||||
: SortType.Active;
|
: SortType.Active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
ui/yarn.lock
vendored
5
ui/yarn.lock
vendored
|
@ -4938,6 +4938,11 @@ lego-api@^1.0.7:
|
||||||
dependencies:
|
dependencies:
|
||||||
chain-able "^3.0.0"
|
chain-able "^3.0.0"
|
||||||
|
|
||||||
|
lemmy-js-client@^1.0.2:
|
||||||
|
version "1.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-1.0.2.tgz#6345a40ebc9218d4ad9a32cdbafdd29140e3768a"
|
||||||
|
integrity sha512-m4ZayBvyOF/v7M+MzPNROtrc54OHAL9+7qtxkF0lbsiGwx2vDcPDCd1Nw/tg+i3qheCvldYAdIGP4tD/zwiMgg==
|
||||||
|
|
||||||
leven@^3.1.0:
|
leven@^3.1.0:
|
||||||
version "3.1.0"
|
version "3.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2"
|
resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2"
|
||||||
|
|
Loading…
Reference in a new issue