"inferno-server": "^8.1.1",
"isomorphic-cookie": "^1.2.4",
"jwt-decode": "^3.1.2",
- "lemmy-js-client": "0.17.2-rc.15",
+ "lemmy-js-client": "0.17.2-rc.17",
+ "lodash": "^4.17.21",
"markdown-it": "^13.0.1",
"markdown-it-container": "^3.0.0",
"markdown-it-emoji": "^2.0.2",
"sass": "^1.62.1",
"sass-loader": "^13.2.2",
"serialize-javascript": "^6.0.1",
+ "service-worker-webpack": "^1.0.0",
"sharp": "^0.32.1",
"tippy.js": "^6.3.7",
"toastify-js": "^1.12.0",
"prettier-plugin-organize-imports": "^3.2.2",
"prettier-plugin-packagejson": "^2.4.3",
"rimraf": "^5.0.0",
- "service-worker-webpack": "^1.0.0",
"sortpack": "^2.3.4",
"style-loader": "^3.3.2",
"terser": "^5.17.3",
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);
messages: PrivateMessageView[];
combined: ReplyType[];
sort: CommentSortType;
- page: bigint;
+ page: number;
siteRes: GetSiteResponse;
loading: boolean;
}
messages: [],
combined: [],
sort: "New",
- page: 1n,
+ page: 1,
siteRes: this.isoData.site_res,
loading: true,
};
this.handleSortChange = this.handleSortChange.bind(this);
this.handlePageChange = this.handlePageChange.bind(this);
- if (!UserService.Instance.myUserInfo && isBrowser()) {
- toast(i18n.t("not_logged_in"), "danger");
- this.context.router.history.push(`/login`);
- }
-
this.parseMessage = this.parseMessage.bind(this);
this.subscription = wsSubscribe(this.parseMessage);
);
}
- handlePageChange(page: bigint) {
+ handlePageChange(page: number) {
this.setState({ page });
this.refetch();
}
handleUnreadOrAllChange(i: Inbox, event: any) {
- i.setState({ unreadOrAll: Number(event.target.value), page: 1n });
+ i.setState({ unreadOrAll: Number(event.target.value), page: 1 });
i.refetch();
}
handleMessageTypeChange(i: Inbox, event: any) {
- i.setState({ messageType: Number(event.target.value), page: 1n });
+ i.setState({ messageType: Number(event.target.value), page: 1 });
i.refetch();
}
let repliesForm: GetReplies = {
sort: "New",
unread_only: true,
- page: 1n,
+ page: 1,
limit: fetchLimit,
auth,
};
let personMentionsForm: GetPersonMentions = {
sort,
unread_only: true,
- page: 1n,
+ page: 1,
limit: fetchLimit,
auth,
};
let privateMessagesForm: GetPrivateMessages = {
unread_only: true,
- page: 1n,
+ page: 1,
limit: fetchLimit,
auth,
};
}
handleSortChange(val: CommentSortType) {
- this.setState({ sort: val, page: 1n });
+ this.setState({ sort: val, page: 1 });
this.refetch();
}
);
i.setState({ replies: [], mentions: [], messages: [] });
i.setState({ combined: i.buildCombined() });
- UserService.Instance.unreadInboxCountSub.next(0n);
+ UserService.Instance.unreadInboxCountSub.next(0);
window.scrollTo(0, 0);
i.setState(i.state);
}
sendUnreadCount(read: boolean) {
let urcs = UserService.Instance.unreadInboxCountSub;
if (read) {
- urcs.next(urcs.getValue() - 1n);
+ urcs.next(urcs.getValue() - 1);
} else {
- urcs.next(urcs.getValue() + 1n);
+ urcs.next(urcs.getValue() + 1);
}
}
listRegistrationApplicationsResponse?: ListRegistrationApplicationsResponse;
siteRes: GetSiteResponse;
unreadOrAll: UnreadOrAll;
- page: bigint;
+ page: number;
loading: boolean;
}
state: RegistrationApplicationsState = {
siteRes: this.isoData.site_res,
unreadOrAll: UnreadOrAll.Unread,
- page: 1n,
+ page: 1,
loading: true,
};
this.handlePageChange = this.handlePageChange.bind(this);
- if (!UserService.Instance.myUserInfo && isBrowser()) {
- toast(i18n.t("not_logged_in"), "danger");
- this.context.router.history.push(`/login`);
- }
-
this.parseMessage = this.parseMessage.bind(this);
this.subscription = wsSubscribe(this.parseMessage);
}
handleUnreadOrAllChange(i: RegistrationApplications, event: any) {
- i.setState({ unreadOrAll: Number(event.target.value), page: 1n });
+ i.setState({ unreadOrAll: Number(event.target.value), page: 1 });
i.refetch();
}
- handlePageChange(page: bigint) {
+ handlePageChange(page: number) {
this.setState({ page });
this.refetch();
}
if (auth) {
let form: ListRegistrationApplications = {
unread_only: true,
- page: 1n,
+ page: 1,
limit: fetchLimit,
auth,
};
);
let uacs = UserService.Instance.unreadApplicationCountSub;
// Minor bug, where if the application switches from deny to approve, the count will still go down
- uacs.next(uacs.getValue() - 1n);
+ uacs.next(uacs.getValue() - 1);
this.setState(this.state);
}
}
messageType: MessageType;
combined: ItemType[];
siteRes: GetSiteResponse;
- page: bigint;
+ page: number;
loading: boolean;
}
unreadOrAll: UnreadOrAll.Unread,
messageType: MessageType.All,
combined: [],
- page: 1n,
+ page: 1,
siteRes: this.isoData.site_res,
loading: true,
};
this.handlePageChange = this.handlePageChange.bind(this);
- if (!UserService.Instance.myUserInfo && isBrowser()) {
- toast(i18n.t("not_logged_in"), "danger");
- this.context.router.history.push(`/login`);
- }
-
this.parseMessage = this.parseMessage.bind(this);
this.subscription = wsSubscribe(this.parseMessage);
);
}
- handlePageChange(page: bigint) {
+ handlePageChange(page: number) {
this.setState({ page });
this.refetch();
}
handleUnreadOrAllChange(i: Reports, event: any) {
- i.setState({ unreadOrAll: Number(event.target.value), page: 1n });
+ i.setState({ unreadOrAll: Number(event.target.value), page: 1 });
i.refetch();
}
handleMessageTypeChange(i: Reports, event: any) {
- i.setState({ messageType: Number(event.target.value), page: 1n });
+ i.setState({ messageType: Number(event.target.value), page: 1 });
i.refetch();
}
let promises: Promise<any>[] = [];
let unresolved_only = true;
- let page = 1n;
+ let page = 1;
let limit = fetchLimit;
let auth = req.auth;
);
let urcs = UserService.Instance.unreadReportCountSub;
if (data.post_report_view.post_report.resolved) {
- urcs.next(urcs.getValue() - 1n);
+ urcs.next(urcs.getValue() - 1);
} else {
- urcs.next(urcs.getValue() + 1n);
+ urcs.next(urcs.getValue() + 1);
}
this.setState(this.state);
} else if (op == UserOperation.ResolveCommentReport) {
);
let urcs = UserService.Instance.unreadReportCountSub;
if (data.comment_report_view.comment_report.resolved) {
- urcs.next(urcs.getValue() - 1n);
+ urcs.next(urcs.getValue() - 1);
} else {
- urcs.next(urcs.getValue() + 1n);
+ urcs.next(urcs.getValue() + 1);
}
this.setState(this.state);
} else if (op == UserOperation.ResolvePrivateMessageReport) {
);
let urcs = UserService.Instance.unreadReportCountSub;
if (data.private_message_report_view.private_message_report.resolved) {
- urcs.next(urcs.getValue() - 1n);
+ urcs.next(urcs.getValue() - 1);
} else {
- urcs.next(urcs.getValue() + 1n);
+ urcs.next(urcs.getValue() + 1);
}
this.setState(this.state);
}
export const elementUrl = "https://element.io";
export const postRefetchSeconds: number = 60 * 1000;
- export const fetchLimit = 40n;
- export const trendingFetchLimit = 6n;
+ export const fetchLimit = 40;
+ export const trendingFetchLimit = 6;
export const mentionDropdownFetchLimit = 10;
export const commentTreeMaxDepth = 8;
export const markdownFieldCharacterLimit = 50000;
- export const maxUploadImages = 20n;
+ export const maxUploadImages = 20;
export const concurrentImageUpload = 4;
export const relTags = "noopener nofollow";
| "gray"
| "gray-dark";
+export interface ErrorPageData {
+ type: "error";
+ error?: string;
+ adminMatrixIds?: string[];
+}
+
let customEmojis: EmojiMartCategory[] = [];
export let customEmojisLookup: Map<string, CustomEmojiView> = new Map<
string,
return id && id !== "0" && !Number.isNaN(Number(id)) ? Number(id) : undefined;
}
- export function getPageFromString(page?: string): bigint {
- return page && !Number.isNaN(Number(page)) ? BigInt(page) : BigInt(1);
+ export function getPageFromString(page?: string): number {
+ return page && !Number.isNaN(Number(page)) ? Number(page) : 1;
}
export function randomStr(
return hotRank(post_view.counts.score, post_view.post.published);
}
- export function hotRank(score: bigint, timeStr: string): number {
+ export function hotRank(score: number, timeStr: string): number {
// Rank = ScaleFactor * sign(Score) * log(1 + abs(Score)) / (Time + 2)^Gravity
let date: Date = new Date(timeStr + "Z"); // Add Z to convert from UTC date
let now: Date = new Date();
let hoursElapsed: number = (now.getTime() - date.getTime()) / 36e5;
let rank =
- (10000 * Math.log10(Math.max(1, Number(3n + score)))) /
+ (10000 * Math.log10(Math.max(1, 3 + Number(score)))) /
Math.pow(hoursElapsed + 2, 1.8);
// console.log(`Comment: ${comment.content}\nRank: ${rank}\nScore: ${comment.score}\nHours: ${hoursElapsed}`);
return { __html: md.renderInline(text) };
}
- export function getUnixTime(text?: string): bigint | undefined {
- return text ? BigInt(new Date(text).getTime() / 1000) : undefined;
+ export function getUnixTime(text?: string): number | undefined {
+ return text ? new Date(text).getTime() / 1000 : undefined;
}
- export function futureDaysToUnixTime(days?: number): bigint | undefined {
+ export function futureDaysToUnixTime(days?: number): number | undefined {
return days
- ? BigInt(
- Math.trunc(
- new Date(Date.now() + 1000 * 60 * 60 * 24 * days).getTime() / 1000
- )
+ ? Math.trunc(
+ new Date(Date.now() + 1000 * 60 * 60 * 24 * days).getTime() / 1000
)
: undefined;
}
type_: "Communities",
sort: "TopAll",
listing_type: "All",
- page: 1n,
+ page: 1,
limit: fetchLimit,
auth: myAuth(false),
};
type_: "Users",
sort: "TopAll",
listing_type: "All",
- page: 1n,
+ page: 1,
limit: fetchLimit,
auth: myAuth(false),
};
return local ? pName : `${hostname(actor_id)}/${pName}`;
}
-export function initializeSite(site: GetSiteResponse) {
- UserService.Instance.myUserInfo = site.my_user;
+export function initializeSite(site?: GetSiteResponse) {
+ UserService.Instance.myUserInfo = site?.my_user;
i18n.changeLanguage(getLanguages()[0]);
- setupEmojiDataModel(site.custom_emojis);
+ if (site) {
+ setupEmojiDataModel(site.custom_emojis);
+ }
setupMarkdown();
}
compactDisplay: "short",
});
- export function numToSI(value: bigint): string {
+ export function numToSI(value: number): string {
return SHORTNUM_SI_FORMAT.format(value);
}
resolved "https://registry.yarnpkg.com/leac/-/leac-0.6.0.tgz#dcf136e382e666bd2475f44a1096061b70dc0912"
integrity sha512-y+SqErxb8h7nE/fiEX07jsbuhrpO9lL8eca7/Y1nuWV2moNlXhyd59iDGcRf6moVyDMbmTNzL40SUyrFU/yDpg==
- lemmy-js-client@0.17.2-rc.15:
- version "0.17.2-rc.15"
- resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.2-rc.15.tgz#a3b10227913c4dc12fa7b69cdc777e429d030721"
- integrity sha512-hnHW/570mQGoGNdnUaNp20+KVkyUnosaFLmWxlZyyhL7fiSbcIXM+GXsjTCqmc1JEnqASc6MdMMpYuZaBKVQtQ==
+ lemmy-js-client@0.17.2-rc.17:
+ version "0.17.2-rc.17"
+ resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.2-rc.17.tgz#91a167c3b61db39fab2e977685a42a77aeae519a"
+ integrity sha512-DBzQjVRo89co7Wppl72/xlNdJfAnXrUE0UgWZxO3v2I8axK9JUD4XmodpRe33thpfPmsURQ1W7dOUX60rcQPQg==
dependencies:
cross-fetch "^3.1.5"
form-data "^4.0.0"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
integrity sha512-9mDDwqVIma6OZX79ZlDACZl8sBm0TEnkf99zV3iMA4GzkIT/9hiqP5mY0HoT1iNLCrKc/R1HByV+yJfRWVJryQ==
-lodash@^4.17.20:
+lodash@^4.17.20, lodash@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==