import { Component, linkEvent } from "inferno"; import { GetSiteResponse, ListRegistrationApplications, ListRegistrationApplicationsResponse, RegistrationApplicationResponse, UserOperation, wsJsonToRes, wsUserOp, } from "lemmy-js-client"; import { Subscription } from "rxjs"; import { i18n } from "../../i18next"; import { InitialFetchRequest } from "../../interfaces"; import { UserService, WebSocketService } from "../../services"; import { fetchLimit, isBrowser, myAuth, setIsoData, setupTippy, toast, updateRegistrationApplicationRes, wsClient, wsSubscribe, } from "../../utils"; import { HtmlTags } from "../common/html-tags"; import { Spinner } from "../common/icon"; import { Paginator } from "../common/paginator"; import { RegistrationApplication } from "../common/registration-application"; enum UnreadOrAll { Unread, All, } interface RegistrationApplicationsState { listRegistrationApplicationsResponse?: ListRegistrationApplicationsResponse; siteRes: GetSiteResponse; unreadOrAll: UnreadOrAll; page: number; loading: boolean; } export class RegistrationApplications extends Component< any, RegistrationApplicationsState > { private isoData = setIsoData(this.context); private subscription?: Subscription; state: RegistrationApplicationsState = { siteRes: this.isoData.site_res, unreadOrAll: UnreadOrAll.Unread, page: 1, loading: true, }; constructor(props: any, context: any) { super(props, context); this.handlePageChange = this.handlePageChange.bind(this); this.parseMessage = this.parseMessage.bind(this); this.subscription = wsSubscribe(this.parseMessage); // Only fetch the data if coming from another route if (this.isoData.path == this.context.router.route.match.url) { this.state = { ...this.state, listRegistrationApplicationsResponse: this.isoData .routeData[0] as ListRegistrationApplicationsResponse, loading: false, }; } else { this.refetch(); } } componentDidMount() { setupTippy(); } componentWillUnmount() { if (isBrowser()) { this.subscription?.unsubscribe(); } } get documentTitle(): string { const mui = UserService.Instance.myUserInfo; return mui ? `@${mui.local_user_view.person.name} ${i18n.t( "registration_applications" )} - ${this.state.siteRes.site_view.site.name}` : ""; } render() { return (