mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-12-23 03:11:25 +00:00
Changing all bigints to numbers
This commit is contained in:
parent
6ac5435fe9
commit
3143788d19
24 changed files with 175 additions and 194 deletions
|
@ -60,7 +60,7 @@
|
||||||
"inferno-server": "^8.1.1",
|
"inferno-server": "^8.1.1",
|
||||||
"isomorphic-cookie": "^1.2.4",
|
"isomorphic-cookie": "^1.2.4",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
"lemmy-js-client": "0.17.2-rc.16",
|
"lemmy-js-client": "0.17.2-rc.17",
|
||||||
"markdown-it": "^13.0.1",
|
"markdown-it": "^13.0.1",
|
||||||
"markdown-it-container": "^3.0.0",
|
"markdown-it-container": "^3.0.0",
|
||||||
"markdown-it-emoji": "^2.0.2",
|
"markdown-it-emoji": "^2.0.2",
|
||||||
|
|
|
@ -40,9 +40,9 @@ interface NavbarProps {
|
||||||
|
|
||||||
interface NavbarState {
|
interface NavbarState {
|
||||||
expanded: boolean;
|
expanded: boolean;
|
||||||
unreadInboxCount: bigint;
|
unreadInboxCount: number;
|
||||||
unreadReportCount: bigint;
|
unreadReportCount: number;
|
||||||
unreadApplicationCount: bigint;
|
unreadApplicationCount: number;
|
||||||
showDropdown: boolean;
|
showDropdown: boolean;
|
||||||
onSiteBanner?(url: string): any;
|
onSiteBanner?(url: string): any;
|
||||||
}
|
}
|
||||||
|
@ -54,9 +54,9 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
|
||||||
private unreadReportCountSub: Subscription;
|
private unreadReportCountSub: Subscription;
|
||||||
private unreadApplicationCountSub: Subscription;
|
private unreadApplicationCountSub: Subscription;
|
||||||
state: NavbarState = {
|
state: NavbarState = {
|
||||||
unreadInboxCount: 0n,
|
unreadInboxCount: 0,
|
||||||
unreadReportCount: 0n,
|
unreadReportCount: 0,
|
||||||
unreadApplicationCount: 0n,
|
unreadApplicationCount: 0,
|
||||||
expanded: false,
|
expanded: false,
|
||||||
showDropdown: false,
|
showDropdown: false,
|
||||||
};
|
};
|
||||||
|
@ -512,7 +512,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
|
||||||
unreadReportCount:
|
unreadReportCount:
|
||||||
data.post_reports +
|
data.post_reports +
|
||||||
data.comment_reports +
|
data.comment_reports +
|
||||||
(data.private_message_reports ?? 0n),
|
(data.private_message_reports ?? 0),
|
||||||
});
|
});
|
||||||
this.sendReportUnread();
|
this.sendReportUnread();
|
||||||
} else if (op == UserOperation.GetUnreadRegistrationApplicationCount) {
|
} else if (op == UserOperation.GetUnreadRegistrationApplicationCount) {
|
||||||
|
@ -528,7 +528,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
|
||||||
data.recipient_ids.includes(mui.local_user_view.local_user.id)
|
data.recipient_ids.includes(mui.local_user_view.local_user.id)
|
||||||
) {
|
) {
|
||||||
this.setState({
|
this.setState({
|
||||||
unreadInboxCount: this.state.unreadInboxCount + 1n,
|
unreadInboxCount: this.state.unreadInboxCount + 1,
|
||||||
});
|
});
|
||||||
this.sendUnreadCount();
|
this.sendUnreadCount();
|
||||||
notifyComment(data.comment_view, this.context.router);
|
notifyComment(data.comment_view, this.context.router);
|
||||||
|
@ -541,7 +541,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
|
||||||
UserService.Instance.myUserInfo?.local_user_view.person.id
|
UserService.Instance.myUserInfo?.local_user_view.person.id
|
||||||
) {
|
) {
|
||||||
this.setState({
|
this.setState({
|
||||||
unreadInboxCount: this.state.unreadInboxCount + 1n,
|
unreadInboxCount: this.state.unreadInboxCount + 1,
|
||||||
});
|
});
|
||||||
this.sendUnreadCount();
|
this.sendUnreadCount();
|
||||||
notifyPrivateMessage(data.private_message_view, this.context.router);
|
notifyPrivateMessage(data.private_message_view, this.context.router);
|
||||||
|
|
|
@ -84,9 +84,9 @@ interface CommentNodeState {
|
||||||
showReportDialog: boolean;
|
showReportDialog: boolean;
|
||||||
reportReason?: string;
|
reportReason?: string;
|
||||||
my_vote?: number;
|
my_vote?: number;
|
||||||
score: bigint;
|
score: number;
|
||||||
upvotes: bigint;
|
upvotes: number;
|
||||||
downvotes: bigint;
|
downvotes: number;
|
||||||
readLoading: boolean;
|
readLoading: boolean;
|
||||||
saveLoading: boolean;
|
saveLoading: boolean;
|
||||||
}
|
}
|
||||||
|
@ -833,9 +833,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
>
|
>
|
||||||
{i18n.t("x_more_replies", {
|
{i18n.t("x_more_replies", {
|
||||||
count: node.comment_view.counts.child_count,
|
count: node.comment_view.counts.child_count,
|
||||||
formattedCount: numToSI(
|
formattedCount: numToSI(node.comment_view.counts.child_count),
|
||||||
BigInt(node.comment_view.counts.child_count)
|
|
||||||
),
|
|
||||||
})}{" "}
|
})}{" "}
|
||||||
➔
|
➔
|
||||||
</button>
|
</button>
|
||||||
|
@ -1152,19 +1150,19 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
|
|
||||||
if (myVote == 1) {
|
if (myVote == 1) {
|
||||||
this.setState({
|
this.setState({
|
||||||
score: this.state.score - 1n,
|
score: this.state.score - 1,
|
||||||
upvotes: this.state.upvotes - 1n,
|
upvotes: this.state.upvotes - 1,
|
||||||
});
|
});
|
||||||
} else if (myVote == -1) {
|
} else if (myVote == -1) {
|
||||||
this.setState({
|
this.setState({
|
||||||
downvotes: this.state.downvotes - 1n,
|
downvotes: this.state.downvotes - 1,
|
||||||
upvotes: this.state.upvotes + 1n,
|
upvotes: this.state.upvotes + 1,
|
||||||
score: this.state.score + 2n,
|
score: this.state.score + 2,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
score: this.state.score + 1n,
|
score: this.state.score + 1,
|
||||||
upvotes: this.state.upvotes + 1n,
|
upvotes: this.state.upvotes + 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1189,19 +1187,19 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
|
|
||||||
if (myVote == 1) {
|
if (myVote == 1) {
|
||||||
this.setState({
|
this.setState({
|
||||||
downvotes: this.state.downvotes + 1n,
|
downvotes: this.state.downvotes + 1,
|
||||||
upvotes: this.state.upvotes - 1n,
|
upvotes: this.state.upvotes - 1,
|
||||||
score: this.state.score - 2n,
|
score: this.state.score - 2,
|
||||||
});
|
});
|
||||||
} else if (myVote == -1) {
|
} else if (myVote == -1) {
|
||||||
this.setState({
|
this.setState({
|
||||||
downvotes: this.state.downvotes - 1n,
|
downvotes: this.state.downvotes - 1,
|
||||||
score: this.state.score + 1n,
|
score: this.state.score + 1,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
downvotes: this.state.downvotes + 1n,
|
downvotes: this.state.downvotes + 1,
|
||||||
score: this.state.score - 1n,
|
score: this.state.score - 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1542,7 +1540,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
post_id: i.props.node.comment_view.post.id,
|
post_id: i.props.node.comment_view.post.id,
|
||||||
parent_id: i.props.node.comment_view.comment.id,
|
parent_id: i.props.node.comment_view.comment.id,
|
||||||
max_depth: commentTreeMaxDepth,
|
max_depth: commentTreeMaxDepth,
|
||||||
limit: 999n, // TODO
|
limit: 999, // TODO
|
||||||
type_: "All",
|
type_: "All",
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
auth: myAuth(false),
|
auth: myAuth(false),
|
||||||
|
|
|
@ -2,8 +2,8 @@ import { Component, linkEvent } from "inferno";
|
||||||
import { i18n } from "../../i18next";
|
import { i18n } from "../../i18next";
|
||||||
|
|
||||||
interface PaginatorProps {
|
interface PaginatorProps {
|
||||||
page: bigint;
|
page: number;
|
||||||
onChange(val: bigint): any;
|
onChange(val: number): any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Paginator extends Component<PaginatorProps, any> {
|
export class Paginator extends Component<PaginatorProps, any> {
|
||||||
|
@ -15,7 +15,7 @@ export class Paginator extends Component<PaginatorProps, any> {
|
||||||
<div className="my-2">
|
<div className="my-2">
|
||||||
<button
|
<button
|
||||||
className="btn btn-secondary mr-2"
|
className="btn btn-secondary mr-2"
|
||||||
disabled={this.props.page == 1n}
|
disabled={this.props.page == 1}
|
||||||
onClick={linkEvent(this, this.handlePrev)}
|
onClick={linkEvent(this, this.handlePrev)}
|
||||||
>
|
>
|
||||||
{i18n.t("prev")}
|
{i18n.t("prev")}
|
||||||
|
@ -31,10 +31,10 @@ export class Paginator extends Component<PaginatorProps, any> {
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePrev(i: Paginator) {
|
handlePrev(i: Paginator) {
|
||||||
i.props.onChange(i.props.page - 1n);
|
i.props.onChange(i.props.page - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleNext(i: Paginator) {
|
handleNext(i: Paginator) {
|
||||||
i.props.onChange(i.props.page + 1n);
|
i.props.onChange(i.props.page + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import { ListingTypeSelect } from "../common/listing-type-select";
|
||||||
import { Paginator } from "../common/paginator";
|
import { Paginator } from "../common/paginator";
|
||||||
import { CommunityLink } from "./community-link";
|
import { CommunityLink } from "./community-link";
|
||||||
|
|
||||||
const communityLimit = 50n;
|
const communityLimit = 50;
|
||||||
|
|
||||||
interface CommunitiesState {
|
interface CommunitiesState {
|
||||||
listCommunitiesResponse?: ListCommunitiesResponse;
|
listCommunitiesResponse?: ListCommunitiesResponse;
|
||||||
|
@ -45,7 +45,7 @@ interface CommunitiesState {
|
||||||
|
|
||||||
interface CommunitiesProps {
|
interface CommunitiesProps {
|
||||||
listingType: ListingType;
|
listingType: ListingType;
|
||||||
page: bigint;
|
page: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCommunitiesQueryParams() {
|
function getCommunitiesQueryParams() {
|
||||||
|
@ -280,14 +280,14 @@ export class Communities extends Component<any, CommunitiesState> {
|
||||||
refetch();
|
refetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePageChange(page: bigint) {
|
handlePageChange(page: number) {
|
||||||
this.updateUrl({ page });
|
this.updateUrl({ page });
|
||||||
}
|
}
|
||||||
|
|
||||||
handleListingTypeChange(val: ListingType) {
|
handleListingTypeChange(val: ListingType) {
|
||||||
this.updateUrl({
|
this.updateUrl({
|
||||||
listingType: val,
|
listingType: val,
|
||||||
page: 1n,
|
page: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ interface State {
|
||||||
interface CommunityProps {
|
interface CommunityProps {
|
||||||
dataType: DataType;
|
dataType: DataType;
|
||||||
sort: SortType;
|
sort: SortType;
|
||||||
page: bigint;
|
page: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCommunityQueryParams() {
|
function getCommunityQueryParams() {
|
||||||
|
@ -427,18 +427,18 @@ export class Community extends Component<
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePageChange(page: bigint) {
|
handlePageChange(page: number) {
|
||||||
this.updateUrl({ page });
|
this.updateUrl({ page });
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSortChange(sort: SortType) {
|
handleSortChange(sort: SortType) {
|
||||||
this.updateUrl({ sort, page: 1n });
|
this.updateUrl({ sort, page: 1 });
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleDataTypeChange(dataType: DataType) {
|
handleDataTypeChange(dataType: DataType) {
|
||||||
this.updateUrl({ dataType, page: 1n });
|
this.updateUrl({ dataType, page: 1 });
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,11 +606,7 @@ export class Community extends Component<
|
||||||
.show_new_post_notifs;
|
.show_new_post_notifs;
|
||||||
|
|
||||||
// Only push these if you're on the first page, you pass the nsfw check, and it isn't blocked
|
// Only push these if you're on the first page, you pass the nsfw check, and it isn't blocked
|
||||||
if (
|
if (page === 1 && nsfwCheck(post_view) && !isPostBlocked(post_view)) {
|
||||||
page === 1n &&
|
|
||||||
nsfwCheck(post_view) &&
|
|
||||||
!isPostBlocked(post_view)
|
|
||||||
) {
|
|
||||||
this.state.posts.unshift(post_view);
|
this.state.posts.unshift(post_view);
|
||||||
if (showPostNotifs) {
|
if (showPostNotifs) {
|
||||||
notifyPost(post_view, this.context.router);
|
notifyPost(post_view, this.context.router);
|
||||||
|
|
|
@ -185,7 +185,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
<li className="list-inline-item badge badge-secondary">
|
<li className="list-inline-item badge badge-secondary">
|
||||||
{i18n.t("number_online", {
|
{i18n.t("number_online", {
|
||||||
count: this.props.online,
|
count: this.props.online,
|
||||||
formattedCount: numToSI(BigInt(this.props.online)),
|
formattedCount: numToSI(this.props.online),
|
||||||
})}
|
})}
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
|
|
|
@ -35,7 +35,7 @@ interface EmojiFormState {
|
||||||
siteRes: GetSiteResponse;
|
siteRes: GetSiteResponse;
|
||||||
customEmojis: CustomEmojiViewForm[];
|
customEmojis: CustomEmojiViewForm[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
page: bigint;
|
page: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CustomEmojiViewForm {
|
interface CustomEmojiViewForm {
|
||||||
|
@ -46,7 +46,7 @@ interface CustomEmojiViewForm {
|
||||||
alt_text: string;
|
alt_text: string;
|
||||||
keywords: string;
|
keywords: string;
|
||||||
changed: boolean;
|
changed: boolean;
|
||||||
page: bigint;
|
page: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class EmojiForm extends Component<any, EmojiFormState> {
|
export class EmojiForm extends Component<any, EmojiFormState> {
|
||||||
|
@ -64,9 +64,9 @@ export class EmojiForm extends Component<any, EmojiFormState> {
|
||||||
alt_text: x.custom_emoji.alt_text,
|
alt_text: x.custom_emoji.alt_text,
|
||||||
keywords: x.keywords.map(x => x.keyword).join(" "),
|
keywords: x.keywords.map(x => x.keyword).join(" "),
|
||||||
changed: false,
|
changed: false,
|
||||||
page: BigInt(1 + Math.floor(index / this.itemsPerPage)),
|
page: 1 + Math.floor(index / this.itemsPerPage),
|
||||||
})),
|
})),
|
||||||
page: 1n,
|
page: 1,
|
||||||
};
|
};
|
||||||
state: EmojiFormState;
|
state: EmojiFormState;
|
||||||
private scrollRef: any = {};
|
private scrollRef: any = {};
|
||||||
|
@ -125,10 +125,10 @@ export class EmojiForm extends Component<any, EmojiFormState> {
|
||||||
<tbody>
|
<tbody>
|
||||||
{this.state.customEmojis
|
{this.state.customEmojis
|
||||||
.slice(
|
.slice(
|
||||||
Number((this.state.page - 1n) * BigInt(this.itemsPerPage)),
|
Number((this.state.page - 1) * this.itemsPerPage),
|
||||||
Number(
|
Number(
|
||||||
(this.state.page - 1n) * BigInt(this.itemsPerPage) +
|
(this.state.page - 1) * this.itemsPerPage +
|
||||||
BigInt(this.itemsPerPage)
|
this.itemsPerPage
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.map((cv, index) => (
|
.map((cv, index) => (
|
||||||
|
@ -304,7 +304,7 @@ export class EmojiForm extends Component<any, EmojiFormState> {
|
||||||
else return i18n.t("custom_emoji_save_validation");
|
else return i18n.t("custom_emoji_save_validation");
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePageChange(page: bigint) {
|
handlePageChange(page: number) {
|
||||||
this.setState({ page: page });
|
this.setState({ page: page });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,10 +327,9 @@ export class EmojiForm extends Component<any, EmojiFormState> {
|
||||||
) {
|
) {
|
||||||
let custom_emojis = [...props.form.state.customEmojis];
|
let custom_emojis = [...props.form.state.customEmojis];
|
||||||
let pagedIndex =
|
let pagedIndex =
|
||||||
(props.form.state.page - 1n) * BigInt(props.form.itemsPerPage) +
|
(props.form.state.page - 1) * props.form.itemsPerPage + props.index;
|
||||||
BigInt(props.index);
|
|
||||||
let item = {
|
let item = {
|
||||||
...props.form.state.customEmojis[Number(pagedIndex)],
|
...props.form.state.customEmojis[pagedIndex],
|
||||||
category: event.target.value,
|
category: event.target.value,
|
||||||
changed: true,
|
changed: true,
|
||||||
};
|
};
|
||||||
|
@ -344,10 +343,9 @@ export class EmojiForm extends Component<any, EmojiFormState> {
|
||||||
) {
|
) {
|
||||||
let custom_emojis = [...props.form.state.customEmojis];
|
let custom_emojis = [...props.form.state.customEmojis];
|
||||||
let pagedIndex =
|
let pagedIndex =
|
||||||
(props.form.state.page - 1n) * BigInt(props.form.itemsPerPage) +
|
(props.form.state.page - 1) * props.form.itemsPerPage + props.index;
|
||||||
BigInt(props.index);
|
|
||||||
let item = {
|
let item = {
|
||||||
...props.form.state.customEmojis[Number(pagedIndex)],
|
...props.form.state.customEmojis[pagedIndex],
|
||||||
shortcode: event.target.value,
|
shortcode: event.target.value,
|
||||||
changed: true,
|
changed: true,
|
||||||
};
|
};
|
||||||
|
@ -361,10 +359,9 @@ export class EmojiForm extends Component<any, EmojiFormState> {
|
||||||
) {
|
) {
|
||||||
let custom_emojis = [...props.form.state.customEmojis];
|
let custom_emojis = [...props.form.state.customEmojis];
|
||||||
let pagedIndex =
|
let pagedIndex =
|
||||||
(props.form.state.page - 1n) * BigInt(props.form.itemsPerPage) +
|
(props.form.state.page - 1) * props.form.itemsPerPage + props.index;
|
||||||
BigInt(props.index);
|
|
||||||
let item = {
|
let item = {
|
||||||
...props.form.state.customEmojis[Number(pagedIndex)],
|
...props.form.state.customEmojis[pagedIndex],
|
||||||
image_url: props.overrideValue ?? event.target.value,
|
image_url: props.overrideValue ?? event.target.value,
|
||||||
changed: true,
|
changed: true,
|
||||||
};
|
};
|
||||||
|
@ -378,10 +375,9 @@ export class EmojiForm extends Component<any, EmojiFormState> {
|
||||||
) {
|
) {
|
||||||
let custom_emojis = [...props.form.state.customEmojis];
|
let custom_emojis = [...props.form.state.customEmojis];
|
||||||
let pagedIndex =
|
let pagedIndex =
|
||||||
(props.form.state.page - 1n) * BigInt(props.form.itemsPerPage) +
|
(props.form.state.page - 1) * props.form.itemsPerPage + props.index;
|
||||||
BigInt(props.index);
|
|
||||||
let item = {
|
let item = {
|
||||||
...props.form.state.customEmojis[Number(pagedIndex)],
|
...props.form.state.customEmojis[pagedIndex],
|
||||||
alt_text: event.target.value,
|
alt_text: event.target.value,
|
||||||
changed: true,
|
changed: true,
|
||||||
};
|
};
|
||||||
|
@ -395,10 +391,9 @@ export class EmojiForm extends Component<any, EmojiFormState> {
|
||||||
) {
|
) {
|
||||||
let custom_emojis = [...props.form.state.customEmojis];
|
let custom_emojis = [...props.form.state.customEmojis];
|
||||||
let pagedIndex =
|
let pagedIndex =
|
||||||
(props.form.state.page - 1n) * BigInt(props.form.itemsPerPage) +
|
(props.form.state.page - 1) * props.form.itemsPerPage + props.index;
|
||||||
BigInt(props.index);
|
|
||||||
let item = {
|
let item = {
|
||||||
...props.form.state.customEmojis[Number(pagedIndex)],
|
...props.form.state.customEmojis[pagedIndex],
|
||||||
keywords: event.target.value,
|
keywords: event.target.value,
|
||||||
changed: true,
|
changed: true,
|
||||||
};
|
};
|
||||||
|
@ -412,8 +407,7 @@ export class EmojiForm extends Component<any, EmojiFormState> {
|
||||||
cv: CustomEmojiViewForm;
|
cv: CustomEmojiViewForm;
|
||||||
}) {
|
}) {
|
||||||
let pagedIndex =
|
let pagedIndex =
|
||||||
(props.form.state.page - 1n) * BigInt(props.form.itemsPerPage) +
|
(props.form.state.page - 1) * props.form.itemsPerPage + props.index;
|
||||||
BigInt(props.index);
|
|
||||||
if (props.cv.id != 0) {
|
if (props.cv.id != 0) {
|
||||||
const deleteForm: DeleteCustomEmoji = {
|
const deleteForm: DeleteCustomEmoji = {
|
||||||
id: props.cv.id,
|
id: props.cv.id,
|
||||||
|
@ -458,9 +452,8 @@ export class EmojiForm extends Component<any, EmojiFormState> {
|
||||||
handleAddEmojiClick(form: EmojiForm, event: any) {
|
handleAddEmojiClick(form: EmojiForm, event: any) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
let custom_emojis = [...form.state.customEmojis];
|
let custom_emojis = [...form.state.customEmojis];
|
||||||
const page = BigInt(
|
const page =
|
||||||
1 + Math.floor(form.state.customEmojis.length / form.itemsPerPage)
|
1 + Math.floor(form.state.customEmojis.length / form.itemsPerPage);
|
||||||
);
|
|
||||||
let item: CustomEmojiViewForm = {
|
let item: CustomEmojiViewForm = {
|
||||||
id: 0,
|
id: 0,
|
||||||
shortcode: "",
|
shortcode: "",
|
||||||
|
|
|
@ -100,7 +100,7 @@ interface HomeProps {
|
||||||
listingType: ListingType;
|
listingType: ListingType;
|
||||||
dataType: DataType;
|
dataType: DataType;
|
||||||
sort: SortType;
|
sort: SortType;
|
||||||
page: bigint;
|
page: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDataTypeFromQuery(type?: string): DataType {
|
function getDataTypeFromQuery(type?: string): DataType {
|
||||||
|
@ -324,7 +324,7 @@ export class Home extends Component<any, HomeState> {
|
||||||
const type_ = getListingTypeFromQuery(listingType);
|
const type_ = getListingTypeFromQuery(listingType);
|
||||||
const sort = getSortTypeFromQuery(urlSort);
|
const sort = getSortTypeFromQuery(urlSort);
|
||||||
|
|
||||||
const page = urlPage ? BigInt(urlPage) : 1n;
|
const page = urlPage ? Number(urlPage) : 1;
|
||||||
|
|
||||||
const promises: Promise<any>[] = [];
|
const promises: Promise<any>[] = [];
|
||||||
|
|
||||||
|
@ -700,23 +700,23 @@ export class Home extends Component<any, HomeState> {
|
||||||
i.setState({ subscribedCollapsed: !i.state.subscribedCollapsed });
|
i.setState({ subscribedCollapsed: !i.state.subscribedCollapsed });
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePageChange(page: bigint) {
|
handlePageChange(page: number) {
|
||||||
this.updateUrl({ page });
|
this.updateUrl({ page });
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSortChange(val: SortType) {
|
handleSortChange(val: SortType) {
|
||||||
this.updateUrl({ sort: val, page: 1n });
|
this.updateUrl({ sort: val, page: 1 });
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleListingTypeChange(val: ListingType) {
|
handleListingTypeChange(val: ListingType) {
|
||||||
this.updateUrl({ listingType: val, page: 1n });
|
this.updateUrl({ listingType: val, page: 1 });
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleDataTypeChange(val: DataType) {
|
handleDataTypeChange(val: DataType) {
|
||||||
this.updateUrl({ dataType: val, page: 1n });
|
this.updateUrl({ dataType: val, page: 1 });
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -765,11 +765,7 @@ export class Home extends Component<any, HomeState> {
|
||||||
const { post_view } = wsJsonToRes<PostResponse>(msg);
|
const { post_view } = wsJsonToRes<PostResponse>(msg);
|
||||||
|
|
||||||
// Only push these if you're on the first page, you pass the nsfw check, and it isn't blocked
|
// Only push these if you're on the first page, you pass the nsfw check, and it isn't blocked
|
||||||
if (
|
if (page === 1 && nsfwCheck(post_view) && !isPostBlocked(post_view)) {
|
||||||
page === 1n &&
|
|
||||||
nsfwCheck(post_view) &&
|
|
||||||
!isPostBlocked(post_view)
|
|
||||||
) {
|
|
||||||
const mui = UserService.Instance.myUserInfo;
|
const mui = UserService.Instance.myUserInfo;
|
||||||
const showPostNotifs =
|
const showPostNotifs =
|
||||||
mui?.local_user_view.local_user.show_new_post_notifs;
|
mui?.local_user_view.local_user.show_new_post_notifs;
|
||||||
|
|
|
@ -105,7 +105,7 @@ export class SiteSidebar extends Component<SiteSidebarProps, SiteSidebarState> {
|
||||||
<li className="list-inline-item badge badge-secondary">
|
<li className="list-inline-item badge badge-secondary">
|
||||||
{i18n.t("number_online", {
|
{i18n.t("number_online", {
|
||||||
count: online,
|
count: online,
|
||||||
formattedCount: numToSI(BigInt(online)),
|
formattedCount: numToSI(online),
|
||||||
})}
|
})}
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
|
|
|
@ -111,7 +111,7 @@ interface ModlogState {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ModlogProps {
|
interface ModlogProps {
|
||||||
page: bigint;
|
page: number;
|
||||||
userId?: number | null;
|
userId?: number | null;
|
||||||
modId?: number | null;
|
modId?: number | null;
|
||||||
actionType: ModlogActionType;
|
actionType: ModlogActionType;
|
||||||
|
@ -868,20 +868,20 @@ export class Modlog extends Component<
|
||||||
handleFilterActionChange(i: Modlog, event: any) {
|
handleFilterActionChange(i: Modlog, event: any) {
|
||||||
i.updateUrl({
|
i.updateUrl({
|
||||||
actionType: event.target.value as ModlogActionType,
|
actionType: event.target.value as ModlogActionType,
|
||||||
page: 1n,
|
page: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePageChange(page: bigint) {
|
handlePageChange(page: number) {
|
||||||
this.updateUrl({ page });
|
this.updateUrl({ page });
|
||||||
}
|
}
|
||||||
|
|
||||||
handleUserChange(option: Choice) {
|
handleUserChange(option: Choice) {
|
||||||
this.updateUrl({ userId: getIdFromString(option.value) ?? null, page: 1n });
|
this.updateUrl({ userId: getIdFromString(option.value) ?? null, page: 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
handleModChange(option: Choice) {
|
handleModChange(option: Choice) {
|
||||||
this.updateUrl({ modId: getIdFromString(option.value) ?? null, page: 1n });
|
this.updateUrl({ modId: getIdFromString(option.value) ?? null, page: 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSearchUsers = debounce(async (text: string) => {
|
handleSearchUsers = debounce(async (text: string) => {
|
||||||
|
|
|
@ -84,7 +84,7 @@ interface InboxState {
|
||||||
messages: PrivateMessageView[];
|
messages: PrivateMessageView[];
|
||||||
combined: ReplyType[];
|
combined: ReplyType[];
|
||||||
sort: CommentSortType;
|
sort: CommentSortType;
|
||||||
page: bigint;
|
page: number;
|
||||||
siteRes: GetSiteResponse;
|
siteRes: GetSiteResponse;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
messages: [],
|
messages: [],
|
||||||
combined: [],
|
combined: [],
|
||||||
sort: "New",
|
sort: "New",
|
||||||
page: 1n,
|
page: 1,
|
||||||
siteRes: this.isoData.site_res,
|
siteRes: this.isoData.site_res,
|
||||||
loading: true,
|
loading: true,
|
||||||
};
|
};
|
||||||
|
@ -471,18 +471,18 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePageChange(page: bigint) {
|
handlePageChange(page: number) {
|
||||||
this.setState({ page });
|
this.setState({ page });
|
||||||
this.refetch();
|
this.refetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleUnreadOrAllChange(i: Inbox, event: any) {
|
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();
|
i.refetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMessageTypeChange(i: Inbox, event: any) {
|
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();
|
i.refetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,7 +497,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
let repliesForm: GetReplies = {
|
let repliesForm: GetReplies = {
|
||||||
sort: "New",
|
sort: "New",
|
||||||
unread_only: true,
|
unread_only: true,
|
||||||
page: 1n,
|
page: 1,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
auth,
|
auth,
|
||||||
};
|
};
|
||||||
|
@ -506,7 +506,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
let personMentionsForm: GetPersonMentions = {
|
let personMentionsForm: GetPersonMentions = {
|
||||||
sort,
|
sort,
|
||||||
unread_only: true,
|
unread_only: true,
|
||||||
page: 1n,
|
page: 1,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
auth,
|
auth,
|
||||||
};
|
};
|
||||||
|
@ -514,7 +514,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
|
|
||||||
let privateMessagesForm: GetPrivateMessages = {
|
let privateMessagesForm: GetPrivateMessages = {
|
||||||
unread_only: true,
|
unread_only: true,
|
||||||
page: 1n,
|
page: 1,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
auth,
|
auth,
|
||||||
};
|
};
|
||||||
|
@ -565,7 +565,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSortChange(val: CommentSortType) {
|
handleSortChange(val: CommentSortType) {
|
||||||
this.setState({ sort: val, page: 1n });
|
this.setState({ sort: val, page: 1 });
|
||||||
this.refetch();
|
this.refetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,7 +579,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
);
|
);
|
||||||
i.setState({ replies: [], mentions: [], messages: [] });
|
i.setState({ replies: [], mentions: [], messages: [] });
|
||||||
i.setState({ combined: i.buildCombined() });
|
i.setState({ combined: i.buildCombined() });
|
||||||
UserService.Instance.unreadInboxCountSub.next(0n);
|
UserService.Instance.unreadInboxCountSub.next(0);
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
i.setState(i.state);
|
i.setState(i.state);
|
||||||
}
|
}
|
||||||
|
@ -588,9 +588,9 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
sendUnreadCount(read: boolean) {
|
sendUnreadCount(read: boolean) {
|
||||||
let urcs = UserService.Instance.unreadInboxCountSub;
|
let urcs = UserService.Instance.unreadInboxCountSub;
|
||||||
if (read) {
|
if (read) {
|
||||||
urcs.next(urcs.getValue() - 1n);
|
urcs.next(urcs.getValue() - 1);
|
||||||
} else {
|
} else {
|
||||||
urcs.next(urcs.getValue() + 1n);
|
urcs.next(urcs.getValue() + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,13 @@ interface PersonDetailsProps {
|
||||||
admins: PersonView[];
|
admins: PersonView[];
|
||||||
allLanguages: Language[];
|
allLanguages: Language[];
|
||||||
siteLanguages: number[];
|
siteLanguages: number[];
|
||||||
page: bigint;
|
page: number;
|
||||||
limit: bigint;
|
limit: number;
|
||||||
sort: SortType;
|
sort: SortType;
|
||||||
enableDownvotes: boolean;
|
enableDownvotes: boolean;
|
||||||
enableNsfw: boolean;
|
enableNsfw: boolean;
|
||||||
view: PersonDetailsView;
|
view: PersonDetailsView;
|
||||||
onPageChange(page: bigint): bigint | any;
|
onPageChange(page: number): number | any;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ItemEnum {
|
enum ItemEnum {
|
||||||
|
@ -36,7 +36,7 @@ type ItemType = {
|
||||||
type_: ItemEnum;
|
type_: ItemEnum;
|
||||||
view: CommentView | PostView;
|
view: CommentView | PostView;
|
||||||
published: string;
|
published: string;
|
||||||
score: bigint;
|
score: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export class PersonDetails extends Component<PersonDetailsProps, any> {
|
export class PersonDetails extends Component<PersonDetailsProps, any> {
|
||||||
|
@ -199,7 +199,7 @@ export class PersonDetails extends Component<PersonDetailsProps, any> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePageChange(val: bigint) {
|
handlePageChange(val: number) {
|
||||||
this.props.onPageChange(val);
|
this.props.onPageChange(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ interface ProfileState {
|
||||||
interface ProfileProps {
|
interface ProfileProps {
|
||||||
view: PersonDetailsView;
|
view: PersonDetailsView;
|
||||||
sort: SortType;
|
sort: SortType;
|
||||||
page: bigint;
|
page: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProfileQueryParams() {
|
function getProfileQueryParams() {
|
||||||
|
@ -645,18 +645,18 @@ export class Profile extends Component<
|
||||||
this.fetchUserData();
|
this.fetchUserData();
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePageChange(page: bigint) {
|
handlePageChange(page: number) {
|
||||||
this.updateUrl({ page });
|
this.updateUrl({ page });
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSortChange(sort: SortType) {
|
handleSortChange(sort: SortType) {
|
||||||
this.updateUrl({ sort, page: 1n });
|
this.updateUrl({ sort, page: 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
handleViewChange(i: Profile, event: any) {
|
handleViewChange(i: Profile, event: any) {
|
||||||
i.updateUrl({
|
i.updateUrl({
|
||||||
view: PersonDetailsView[event.target.value],
|
view: PersonDetailsView[event.target.value],
|
||||||
page: 1n,
|
page: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ interface RegistrationApplicationsState {
|
||||||
listRegistrationApplicationsResponse?: ListRegistrationApplicationsResponse;
|
listRegistrationApplicationsResponse?: ListRegistrationApplicationsResponse;
|
||||||
siteRes: GetSiteResponse;
|
siteRes: GetSiteResponse;
|
||||||
unreadOrAll: UnreadOrAll;
|
unreadOrAll: UnreadOrAll;
|
||||||
page: bigint;
|
page: number;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ export class RegistrationApplications extends Component<
|
||||||
state: RegistrationApplicationsState = {
|
state: RegistrationApplicationsState = {
|
||||||
siteRes: this.isoData.site_res,
|
siteRes: this.isoData.site_res,
|
||||||
unreadOrAll: UnreadOrAll.Unread,
|
unreadOrAll: UnreadOrAll.Unread,
|
||||||
page: 1n,
|
page: 1,
|
||||||
loading: true,
|
loading: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -188,11 +188,11 @@ export class RegistrationApplications extends Component<
|
||||||
}
|
}
|
||||||
|
|
||||||
handleUnreadOrAllChange(i: RegistrationApplications, event: any) {
|
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();
|
i.refetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePageChange(page: bigint) {
|
handlePageChange(page: number) {
|
||||||
this.setState({ page });
|
this.setState({ page });
|
||||||
this.refetch();
|
this.refetch();
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ export class RegistrationApplications extends Component<
|
||||||
if (auth) {
|
if (auth) {
|
||||||
let form: ListRegistrationApplications = {
|
let form: ListRegistrationApplications = {
|
||||||
unread_only: true,
|
unread_only: true,
|
||||||
page: 1n,
|
page: 1,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
auth,
|
auth,
|
||||||
};
|
};
|
||||||
|
@ -254,7 +254,7 @@ export class RegistrationApplications extends Component<
|
||||||
);
|
);
|
||||||
let uacs = UserService.Instance.unreadApplicationCountSub;
|
let uacs = UserService.Instance.unreadApplicationCountSub;
|
||||||
// Minor bug, where if the application switches from deny to approve, the count will still go down
|
// 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);
|
this.setState(this.state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ interface ReportsState {
|
||||||
messageType: MessageType;
|
messageType: MessageType;
|
||||||
combined: ItemType[];
|
combined: ItemType[];
|
||||||
siteRes: GetSiteResponse;
|
siteRes: GetSiteResponse;
|
||||||
page: bigint;
|
page: number;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
unreadOrAll: UnreadOrAll.Unread,
|
unreadOrAll: UnreadOrAll.Unread,
|
||||||
messageType: MessageType.All,
|
messageType: MessageType.All,
|
||||||
combined: [],
|
combined: [],
|
||||||
page: 1n,
|
page: 1,
|
||||||
siteRes: this.isoData.site_res,
|
siteRes: this.isoData.site_res,
|
||||||
loading: true,
|
loading: true,
|
||||||
};
|
};
|
||||||
|
@ -422,18 +422,18 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePageChange(page: bigint) {
|
handlePageChange(page: number) {
|
||||||
this.setState({ page });
|
this.setState({ page });
|
||||||
this.refetch();
|
this.refetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleUnreadOrAllChange(i: Reports, event: any) {
|
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();
|
i.refetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMessageTypeChange(i: Reports, event: any) {
|
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();
|
i.refetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,7 +441,7 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
let promises: Promise<any>[] = [];
|
let promises: Promise<any>[] = [];
|
||||||
|
|
||||||
let unresolved_only = true;
|
let unresolved_only = true;
|
||||||
let page = 1n;
|
let page = 1;
|
||||||
let limit = fetchLimit;
|
let limit = fetchLimit;
|
||||||
let auth = req.auth;
|
let auth = req.auth;
|
||||||
|
|
||||||
|
@ -553,9 +553,9 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
);
|
);
|
||||||
let urcs = UserService.Instance.unreadReportCountSub;
|
let urcs = UserService.Instance.unreadReportCountSub;
|
||||||
if (data.post_report_view.post_report.resolved) {
|
if (data.post_report_view.post_report.resolved) {
|
||||||
urcs.next(urcs.getValue() - 1n);
|
urcs.next(urcs.getValue() - 1);
|
||||||
} else {
|
} else {
|
||||||
urcs.next(urcs.getValue() + 1n);
|
urcs.next(urcs.getValue() + 1);
|
||||||
}
|
}
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
} else if (op == UserOperation.ResolveCommentReport) {
|
} else if (op == UserOperation.ResolveCommentReport) {
|
||||||
|
@ -566,9 +566,9 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
);
|
);
|
||||||
let urcs = UserService.Instance.unreadReportCountSub;
|
let urcs = UserService.Instance.unreadReportCountSub;
|
||||||
if (data.comment_report_view.comment_report.resolved) {
|
if (data.comment_report_view.comment_report.resolved) {
|
||||||
urcs.next(urcs.getValue() - 1n);
|
urcs.next(urcs.getValue() - 1);
|
||||||
} else {
|
} else {
|
||||||
urcs.next(urcs.getValue() + 1n);
|
urcs.next(urcs.getValue() + 1);
|
||||||
}
|
}
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
} else if (op == UserOperation.ResolvePrivateMessageReport) {
|
} else if (op == UserOperation.ResolvePrivateMessageReport) {
|
||||||
|
@ -579,9 +579,9 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
);
|
);
|
||||||
let urcs = UserService.Instance.unreadReportCountSub;
|
let urcs = UserService.Instance.unreadReportCountSub;
|
||||||
if (data.private_message_report_view.private_message_report.resolved) {
|
if (data.private_message_report_view.private_message_report.resolved) {
|
||||||
urcs.next(urcs.getValue() - 1n);
|
urcs.next(urcs.getValue() - 1);
|
||||||
} else {
|
} else {
|
||||||
urcs.next(urcs.getValue() + 1n);
|
urcs.next(urcs.getValue() + 1);
|
||||||
}
|
}
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -509,7 +509,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
type_: "Url",
|
type_: "Url",
|
||||||
sort: "TopAll",
|
sort: "TopAll",
|
||||||
listing_type: "All",
|
listing_type: "All",
|
||||||
page: 1n,
|
page: 1,
|
||||||
limit: trendingFetchLimit,
|
limit: trendingFetchLimit,
|
||||||
auth: myAuth(false),
|
auth: myAuth(false),
|
||||||
};
|
};
|
||||||
|
@ -539,7 +539,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
sort: "TopAll",
|
sort: "TopAll",
|
||||||
listing_type: "All",
|
listing_type: "All",
|
||||||
community_id: this.state.form.community_id,
|
community_id: this.state.form.community_id,
|
||||||
page: 1n,
|
page: 1,
|
||||||
limit: trendingFetchLimit,
|
limit: trendingFetchLimit,
|
||||||
auth: myAuth(false),
|
auth: myAuth(false),
|
||||||
};
|
};
|
||||||
|
|
|
@ -80,9 +80,9 @@ interface PostListingState {
|
||||||
showReportDialog: boolean;
|
showReportDialog: boolean;
|
||||||
reportReason?: string;
|
reportReason?: string;
|
||||||
my_vote?: number;
|
my_vote?: number;
|
||||||
score: bigint;
|
score: number;
|
||||||
upvotes: bigint;
|
upvotes: number;
|
||||||
downvotes: bigint;
|
downvotes: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PostListingProps {
|
interface PostListingProps {
|
||||||
|
@ -652,9 +652,9 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get unreadCount(): bigint | undefined {
|
get unreadCount(): number | undefined {
|
||||||
let pv = this.props.post_view;
|
let pv = this.props.post_view;
|
||||||
return pv.unread_comments == pv.counts.comments || pv.unread_comments == 0n
|
return pv.unread_comments == pv.counts.comments || pv.unread_comments == 0
|
||||||
? undefined
|
? undefined
|
||||||
: pv.unread_comments;
|
: pv.unread_comments;
|
||||||
}
|
}
|
||||||
|
@ -691,7 +691,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
{showScores() && (
|
{showScores() && (
|
||||||
<span
|
<span
|
||||||
className={classNames("ml-2", {
|
className={classNames("ml-2", {
|
||||||
invisible: this.state.downvotes === 0n,
|
invisible: this.state.downvotes === 0,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{numToSI(this.state.downvotes)}
|
{numToSI(this.state.downvotes)}
|
||||||
|
@ -1311,19 +1311,19 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
|
|
||||||
if (myVote == 1) {
|
if (myVote == 1) {
|
||||||
this.setState({
|
this.setState({
|
||||||
score: this.state.score - 1n,
|
score: this.state.score - 1,
|
||||||
upvotes: this.state.upvotes - 1n,
|
upvotes: this.state.upvotes - 1,
|
||||||
});
|
});
|
||||||
} else if (myVote == -1) {
|
} else if (myVote == -1) {
|
||||||
this.setState({
|
this.setState({
|
||||||
score: this.state.score + 2n,
|
score: this.state.score + 2,
|
||||||
upvotes: this.state.upvotes + 1n,
|
upvotes: this.state.upvotes + 1,
|
||||||
downvotes: this.state.downvotes - 1n,
|
downvotes: this.state.downvotes - 1,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
score: this.state.score + 1n,
|
score: this.state.score + 1,
|
||||||
upvotes: this.state.upvotes + 1n,
|
upvotes: this.state.upvotes + 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1354,19 +1354,19 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
|
|
||||||
if (myVote == 1) {
|
if (myVote == 1) {
|
||||||
this.setState({
|
this.setState({
|
||||||
score: this.state.score - 2n,
|
score: this.state.score - 2,
|
||||||
upvotes: this.state.upvotes - 1n,
|
upvotes: this.state.upvotes - 1,
|
||||||
downvotes: this.state.downvotes + 1n,
|
downvotes: this.state.downvotes + 1,
|
||||||
});
|
});
|
||||||
} else if (myVote == -1) {
|
} else if (myVote == -1) {
|
||||||
this.setState({
|
this.setState({
|
||||||
score: this.state.score + 1n,
|
score: this.state.score + 1,
|
||||||
downvotes: this.state.downvotes - 1n,
|
downvotes: this.state.downvotes - 1,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
score: this.state.score - 1n,
|
score: this.state.score - 1,
|
||||||
downvotes: this.state.downvotes + 1n,
|
downvotes: this.state.downvotes + 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ export class PostReport extends Component<PostReportProps, any> {
|
||||||
read: false,
|
read: false,
|
||||||
creator_blocked: false,
|
creator_blocked: false,
|
||||||
my_vote: r.my_vote,
|
my_vote: r.my_vote,
|
||||||
unread_comments: 0n,
|
unread_comments: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -189,7 +189,7 @@ export class Post extends Component<any, PostState> {
|
||||||
type_: "Url",
|
type_: "Url",
|
||||||
sort: "TopAll",
|
sort: "TopAll",
|
||||||
listing_type: "All",
|
listing_type: "All",
|
||||||
page: 1n,
|
page: 1,
|
||||||
limit: trendingFetchLimit,
|
limit: trendingFetchLimit,
|
||||||
auth: myAuth(false),
|
auth: myAuth(false),
|
||||||
};
|
};
|
||||||
|
|
|
@ -77,7 +77,7 @@ interface SearchProps {
|
||||||
listingType: ListingType;
|
listingType: ListingType;
|
||||||
communityId?: number | null;
|
communityId?: number | null;
|
||||||
creatorId?: number | null;
|
creatorId?: number | null;
|
||||||
page: bigint;
|
page: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
type FilterType = "creator" | "community";
|
type FilterType = "creator" | "community";
|
||||||
|
@ -222,7 +222,7 @@ const personListing = ({ person, counts: { comment_count } }: PersonView) =>
|
||||||
|
|
||||||
function getListing(
|
function getListing(
|
||||||
listing: JSX.ElementClass,
|
listing: JSX.ElementClass,
|
||||||
count: bigint,
|
count: number,
|
||||||
translationKey: "number_of_comments" | "number_of_subscribers"
|
translationKey: "number_of_comments" | "number_of_subscribers"
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
|
@ -863,7 +863,7 @@ export class Search extends Component<any, SearchState> {
|
||||||
});
|
});
|
||||||
|
|
||||||
handleSortChange(sort: SortType) {
|
handleSortChange(sort: SortType) {
|
||||||
this.updateUrl({ sort, page: 1n });
|
this.updateUrl({ sort, page: 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTypeChange(i: Search, event: any) {
|
handleTypeChange(i: Search, event: any) {
|
||||||
|
@ -871,32 +871,32 @@ export class Search extends Component<any, SearchState> {
|
||||||
|
|
||||||
i.updateUrl({
|
i.updateUrl({
|
||||||
type,
|
type,
|
||||||
page: 1n,
|
page: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePageChange(page: bigint) {
|
handlePageChange(page: number) {
|
||||||
this.updateUrl({ page });
|
this.updateUrl({ page });
|
||||||
}
|
}
|
||||||
|
|
||||||
handleListingTypeChange(listingType: ListingType) {
|
handleListingTypeChange(listingType: ListingType) {
|
||||||
this.updateUrl({
|
this.updateUrl({
|
||||||
listingType,
|
listingType,
|
||||||
page: 1n,
|
page: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleCommunityFilterChange({ value }: Choice) {
|
handleCommunityFilterChange({ value }: Choice) {
|
||||||
this.updateUrl({
|
this.updateUrl({
|
||||||
communityId: getIdFromString(value) ?? null,
|
communityId: getIdFromString(value) ?? null,
|
||||||
page: 1n,
|
page: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleCreatorFilterChange({ value }: Choice) {
|
handleCreatorFilterChange({ value }: Choice) {
|
||||||
this.updateUrl({
|
this.updateUrl({
|
||||||
creatorId: getIdFromString(value) ?? null,
|
creatorId: getIdFromString(value) ?? null,
|
||||||
page: 1n,
|
page: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -905,7 +905,7 @@ export class Search extends Component<any, SearchState> {
|
||||||
|
|
||||||
i.updateUrl({
|
i.updateUrl({
|
||||||
q: i.state.searchText,
|
q: i.state.searchText,
|
||||||
page: 1n,
|
page: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,12 +22,12 @@ export class UserService {
|
||||||
private static _instance: UserService;
|
private static _instance: UserService;
|
||||||
public myUserInfo?: MyUserInfo;
|
public myUserInfo?: MyUserInfo;
|
||||||
public jwtInfo?: JwtInfo;
|
public jwtInfo?: JwtInfo;
|
||||||
public unreadInboxCountSub: BehaviorSubject<bigint> =
|
public unreadInboxCountSub: BehaviorSubject<number> =
|
||||||
new BehaviorSubject<bigint>(0n);
|
new BehaviorSubject<number>(0);
|
||||||
public unreadReportCountSub: BehaviorSubject<bigint> =
|
public unreadReportCountSub: BehaviorSubject<number> =
|
||||||
new BehaviorSubject<bigint>(0n);
|
new BehaviorSubject<number>(0);
|
||||||
public unreadApplicationCountSub: BehaviorSubject<bigint> =
|
public unreadApplicationCountSub: BehaviorSubject<number> =
|
||||||
new BehaviorSubject<bigint>(0n);
|
new BehaviorSubject<number>(0);
|
||||||
|
|
||||||
private constructor() {
|
private constructor() {
|
||||||
this.setJwtInfo();
|
this.setJwtInfo();
|
||||||
|
|
|
@ -70,12 +70,12 @@ export const webArchiveUrl = "https://web.archive.org";
|
||||||
export const elementUrl = "https://element.io";
|
export const elementUrl = "https://element.io";
|
||||||
|
|
||||||
export const postRefetchSeconds: number = 60 * 1000;
|
export const postRefetchSeconds: number = 60 * 1000;
|
||||||
export const fetchLimit = 40n;
|
export const fetchLimit = 40;
|
||||||
export const trendingFetchLimit = 6n;
|
export const trendingFetchLimit = 6;
|
||||||
export const mentionDropdownFetchLimit = 10;
|
export const mentionDropdownFetchLimit = 10;
|
||||||
export const commentTreeMaxDepth = 8;
|
export const commentTreeMaxDepth = 8;
|
||||||
export const markdownFieldCharacterLimit = 50000;
|
export const markdownFieldCharacterLimit = 50000;
|
||||||
export const maxUploadImages = 20n;
|
export const maxUploadImages = 20;
|
||||||
export const concurrentImageUpload = 4;
|
export const concurrentImageUpload = 4;
|
||||||
|
|
||||||
export const relTags = "noopener nofollow";
|
export const relTags = "noopener nofollow";
|
||||||
|
@ -122,8 +122,8 @@ export function getIdFromString(id?: string): number | undefined {
|
||||||
return id && id !== "0" && !Number.isNaN(Number(id)) ? Number(id) : undefined;
|
return id && id !== "0" && !Number.isNaN(Number(id)) ? Number(id) : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPageFromString(page?: string): bigint {
|
export function getPageFromString(page?: string): number {
|
||||||
return page && !Number.isNaN(Number(page)) ? BigInt(page) : BigInt(1);
|
return page && !Number.isNaN(Number(page)) ? Number(page) : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function randomStr(
|
export function randomStr(
|
||||||
|
@ -185,14 +185,14 @@ export function hotRankPost(post_view: PostView): number {
|
||||||
return hotRank(post_view.counts.score, post_view.post.published);
|
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
|
// 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 date: Date = new Date(timeStr + "Z"); // Add Z to convert from UTC date
|
||||||
let now: Date = new Date();
|
let now: Date = new Date();
|
||||||
let hoursElapsed: number = (now.getTime() - date.getTime()) / 36e5;
|
let hoursElapsed: number = (now.getTime() - date.getTime()) / 36e5;
|
||||||
|
|
||||||
let rank =
|
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);
|
Math.pow(hoursElapsed + 2, 1.8);
|
||||||
|
|
||||||
// console.log(`Comment: ${comment.content}\nRank: ${rank}\nScore: ${comment.score}\nHours: ${hoursElapsed}`);
|
// console.log(`Comment: ${comment.content}\nRank: ${rank}\nScore: ${comment.score}\nHours: ${hoursElapsed}`);
|
||||||
|
@ -212,17 +212,15 @@ export function mdToHtmlInline(text: string) {
|
||||||
return { __html: md.renderInline(text) };
|
return { __html: md.renderInline(text) };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getUnixTime(text?: string): bigint | undefined {
|
export function getUnixTime(text?: string): number | undefined {
|
||||||
return text ? BigInt(new Date(text).getTime() / 1000) : 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
|
return days
|
||||||
? BigInt(
|
? Math.trunc(
|
||||||
Math.trunc(
|
|
||||||
new Date(Date.now() + 1000 * 60 * 60 * 24 * days).getTime() / 1000
|
new Date(Date.now() + 1000 * 60 * 60 * 24 * days).getTime() / 1000
|
||||||
)
|
)
|
||||||
)
|
|
||||||
: undefined;
|
: undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1358,7 +1356,7 @@ export async function fetchCommunities(q: string) {
|
||||||
type_: "Communities",
|
type_: "Communities",
|
||||||
sort: "TopAll",
|
sort: "TopAll",
|
||||||
listing_type: "All",
|
listing_type: "All",
|
||||||
page: 1n,
|
page: 1,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
auth: myAuth(false),
|
auth: myAuth(false),
|
||||||
};
|
};
|
||||||
|
@ -1372,7 +1370,7 @@ export async function fetchUsers(q: string) {
|
||||||
type_: "Users",
|
type_: "Users",
|
||||||
sort: "TopAll",
|
sort: "TopAll",
|
||||||
listing_type: "All",
|
listing_type: "All",
|
||||||
page: 1n,
|
page: 1,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
auth: myAuth(false),
|
auth: myAuth(false),
|
||||||
};
|
};
|
||||||
|
@ -1407,7 +1405,7 @@ const SHORTNUM_SI_FORMAT = new Intl.NumberFormat("en-US", {
|
||||||
compactDisplay: "short",
|
compactDisplay: "short",
|
||||||
});
|
});
|
||||||
|
|
||||||
export function numToSI(value: bigint): string {
|
export function numToSI(value: number): string {
|
||||||
return SHORTNUM_SI_FORMAT.format(value);
|
return SHORTNUM_SI_FORMAT.format(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5334,10 +5334,10 @@ leac@^0.6.0:
|
||||||
resolved "https://registry.yarnpkg.com/leac/-/leac-0.6.0.tgz#dcf136e382e666bd2475f44a1096061b70dc0912"
|
resolved "https://registry.yarnpkg.com/leac/-/leac-0.6.0.tgz#dcf136e382e666bd2475f44a1096061b70dc0912"
|
||||||
integrity sha512-y+SqErxb8h7nE/fiEX07jsbuhrpO9lL8eca7/Y1nuWV2moNlXhyd59iDGcRf6moVyDMbmTNzL40SUyrFU/yDpg==
|
integrity sha512-y+SqErxb8h7nE/fiEX07jsbuhrpO9lL8eca7/Y1nuWV2moNlXhyd59iDGcRf6moVyDMbmTNzL40SUyrFU/yDpg==
|
||||||
|
|
||||||
lemmy-js-client@0.17.2-rc.16:
|
lemmy-js-client@0.17.2-rc.17:
|
||||||
version "0.17.2-rc.16"
|
version "0.17.2-rc.17"
|
||||||
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.2-rc.16.tgz#404c02917291e7e89fdece75b49e7dc68c73492a"
|
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.2-rc.17.tgz#91a167c3b61db39fab2e977685a42a77aeae519a"
|
||||||
integrity sha512-plAZn7ClopgjcTGTfh4b19jF894ucMfQh54J0P2DhQIG0k1Ic0ubq0rY1WZ+9yDyup6vCXF1i5MCylfNAs5Gxw==
|
integrity sha512-DBzQjVRo89co7Wppl72/xlNdJfAnXrUE0UgWZxO3v2I8axK9JUD4XmodpRe33thpfPmsURQ1W7dOUX60rcQPQg==
|
||||||
dependencies:
|
dependencies:
|
||||||
cross-fetch "^3.1.5"
|
cross-fetch "^3.1.5"
|
||||||
form-data "^4.0.0"
|
form-data "^4.0.0"
|
||||||
|
|
Loading…
Reference in a new issue