import { PictrsImage } from "../common/pictrs-image";
interface NavbarProps {
- siteRes: GetSiteResponse;
+ siteRes?: GetSiteResponse;
}
interface NavbarState {
expanded: boolean;
- unreadInboxCount: bigint;
- unreadReportCount: bigint;
- unreadApplicationCount: bigint;
+ unreadInboxCount: number;
+ unreadReportCount: number;
+ unreadApplicationCount: number;
showDropdown: boolean;
onSiteBanner?(url: string): any;
}
private unreadReportCountSub: Subscription;
private unreadApplicationCountSub: Subscription;
state: NavbarState = {
- unreadInboxCount: 0n,
- unreadReportCount: 0n,
- unreadApplicationCount: 0n,
+ unreadInboxCount: 0,
+ unreadReportCount: 0,
+ unreadApplicationCount: 0,
expanded: false,
showDropdown: false,
};
// TODO class active corresponding to current page
navbar() {
- let siteView = this.props.siteRes.site_view;
+ let siteView = this.props.siteRes?.site_view;
let person = UserService.Instance.myUserInfo?.local_user_view.person;
return (
<nav className="navbar navbar-expand-md navbar-light shadow-sm p-0 px-3">
<NavLink
to="/"
onMouseUp={linkEvent(this, this.handleHideExpandNavbar)}
- title={siteView.site.description ?? siteView.site.name}
+ title={siteView?.site.description ?? siteView?.site.name ?? "Lemmy"}
className="d-flex align-items-center navbar-brand mr-md-3"
>
- {siteView.site.icon && showAvatars() && (
+ {siteView?.site.icon && showAvatars() && (
<PictrsImage src={siteView.site.icon} icon />
)}
- {siteView.site.name}
+ {siteView?.site.name ?? "Lemmy"}
</NavLink>
{UserService.Instance.myUserInfo && (
<>
{i18n.t("create_post")}
</NavLink>
</li>
- {canCreateCommunity(this.props.siteRes) && (
+ {this.props.siteRes && canCreateCommunity(this.props.siteRes) && (
<li className="nav-item">
<NavLink
to="/create_community"
unreadReportCount:
data.post_reports +
data.comment_reports +
- (data.private_message_reports ?? 0n),
+ (data.private_message_reports ?? 0),
});
this.sendReportUnread();
} else if (op == UserOperation.GetUnreadRegistrationApplicationCount) {
data.recipient_ids.includes(mui.local_user_view.local_user.id)
) {
this.setState({
- unreadInboxCount: this.state.unreadInboxCount + 1n,
+ unreadInboxCount: this.state.unreadInboxCount + 1,
});
this.sendUnreadCount();
notifyComment(data.comment_view, this.context.router);
UserService.Instance.myUserInfo?.local_user_view.person.id
) {
this.setState({
- unreadInboxCount: this.state.unreadInboxCount + 1n,
+ unreadInboxCount: this.state.unreadInboxCount + 1,
});
this.sendUnreadCount();
notifyPrivateMessage(data.private_message_view, this.context.router);