Merge branch 'main' into nicer-error-hnadling

This commit is contained in:
abias 2023-05-15 20:34:45 -04:00
commit 5068df6bf5
24 changed files with 175 additions and 194 deletions

View file

@ -60,7 +60,7 @@
"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",

View file

@ -40,9 +40,9 @@ interface NavbarProps {
interface NavbarState {
expanded: boolean;
unreadInboxCount: bigint;
unreadReportCount: bigint;
unreadApplicationCount: bigint;
unreadInboxCount: number;
unreadReportCount: number;
unreadApplicationCount: number;
showDropdown: boolean;
onSiteBanner?(url: string): any;
}
@ -54,9 +54,9 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
private unreadReportCountSub: Subscription;
private unreadApplicationCountSub: Subscription;
state: NavbarState = {
unreadInboxCount: 0n,
unreadReportCount: 0n,
unreadApplicationCount: 0n,
unreadInboxCount: 0,
unreadReportCount: 0,
unreadApplicationCount: 0,
expanded: false,
showDropdown: false,
};
@ -512,7 +512,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
unreadReportCount:
data.post_reports +
data.comment_reports +
(data.private_message_reports ?? 0n),
(data.private_message_reports ?? 0),
});
this.sendReportUnread();
} 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)
) {
this.setState({
unreadInboxCount: this.state.unreadInboxCount + 1n,
unreadInboxCount: this.state.unreadInboxCount + 1,
});
this.sendUnreadCount();
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
) {
this.setState({
unreadInboxCount: this.state.unreadInboxCount + 1n,
unreadInboxCount: this.state.unreadInboxCount + 1,
});
this.sendUnreadCount();
notifyPrivateMessage(data.private_message_view, this.context.router);

View file

@ -84,9 +84,9 @@ interface CommentNodeState {
showReportDialog: boolean;
reportReason?: string;
my_vote?: number;
score: bigint;
upvotes: bigint;
downvotes: bigint;
score: number;
upvotes: number;
downvotes: number;
readLoading: boolean;
saveLoading: boolean;
}
@ -833,9 +833,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
>
{i18n.t("x_more_replies", {
count: node.comment_view.counts.child_count,
formattedCount: numToSI(
BigInt(node.comment_view.counts.child_count)
),
formattedCount: numToSI(node.comment_view.counts.child_count),
})}{" "}
</button>
@ -1152,19 +1150,19 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
if (myVote == 1) {
this.setState({
score: this.state.score - 1n,
upvotes: this.state.upvotes - 1n,
score: this.state.score - 1,
upvotes: this.state.upvotes - 1,
});
} else if (myVote == -1) {
this.setState({
downvotes: this.state.downvotes - 1n,
upvotes: this.state.upvotes + 1n,
score: this.state.score + 2n,
downvotes: this.state.downvotes - 1,
upvotes: this.state.upvotes + 1,
score: this.state.score + 2,
});
} else {
this.setState({
score: this.state.score + 1n,
upvotes: this.state.upvotes + 1n,
score: this.state.score + 1,
upvotes: this.state.upvotes + 1,
});
}
@ -1189,19 +1187,19 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
if (myVote == 1) {
this.setState({
downvotes: this.state.downvotes + 1n,
upvotes: this.state.upvotes - 1n,
score: this.state.score - 2n,
downvotes: this.state.downvotes + 1,
upvotes: this.state.upvotes - 1,
score: this.state.score - 2,
});
} else if (myVote == -1) {
this.setState({
downvotes: this.state.downvotes - 1n,
score: this.state.score + 1n,
downvotes: this.state.downvotes - 1,
score: this.state.score + 1,
});
} else {
this.setState({
downvotes: this.state.downvotes + 1n,
score: this.state.score - 1n,
downvotes: this.state.downvotes + 1,
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,
parent_id: i.props.node.comment_view.comment.id,
max_depth: commentTreeMaxDepth,
limit: 999n, // TODO
limit: 999, // TODO
type_: "All",
saved_only: false,
auth: myAuth(false),

View file

@ -2,8 +2,8 @@ import { Component, linkEvent } from "inferno";
import { i18n } from "../../i18next";
interface PaginatorProps {
page: bigint;
onChange(val: bigint): any;
page: number;
onChange(val: number): any;
}
export class Paginator extends Component<PaginatorProps, any> {
@ -15,7 +15,7 @@ export class Paginator extends Component<PaginatorProps, any> {
<div className="my-2">
<button
className="btn btn-secondary mr-2"
disabled={this.props.page == 1n}
disabled={this.props.page == 1}
onClick={linkEvent(this, this.handlePrev)}
>
{i18n.t("prev")}
@ -31,10 +31,10 @@ export class Paginator extends Component<PaginatorProps, any> {
}
handlePrev(i: Paginator) {
i.props.onChange(i.props.page - 1n);
i.props.onChange(i.props.page - 1);
}
handleNext(i: Paginator) {
i.props.onChange(i.props.page + 1n);
i.props.onChange(i.props.page + 1);
}
}

View file

@ -34,7 +34,7 @@ import { ListingTypeSelect } from "../common/listing-type-select";
import { Paginator } from "../common/paginator";
import { CommunityLink } from "./community-link";
const communityLimit = 50n;
const communityLimit = 50;
interface CommunitiesState {
listCommunitiesResponse?: ListCommunitiesResponse;
@ -45,7 +45,7 @@ interface CommunitiesState {
interface CommunitiesProps {
listingType: ListingType;
page: bigint;
page: number;
}
function getCommunitiesQueryParams() {
@ -280,14 +280,14 @@ export class Communities extends Component<any, CommunitiesState> {
refetch();
}
handlePageChange(page: bigint) {
handlePageChange(page: number) {
this.updateUrl({ page });
}
handleListingTypeChange(val: ListingType) {
this.updateUrl({
listingType: val,
page: 1n,
page: 1,
});
}

View file

@ -88,7 +88,7 @@ interface State {
interface CommunityProps {
dataType: DataType;
sort: SortType;
page: bigint;
page: number;
}
function getCommunityQueryParams() {
@ -427,18 +427,18 @@ export class Community extends Component<
);
}
handlePageChange(page: bigint) {
handlePageChange(page: number) {
this.updateUrl({ page });
window.scrollTo(0, 0);
}
handleSortChange(sort: SortType) {
this.updateUrl({ sort, page: 1n });
this.updateUrl({ sort, page: 1 });
window.scrollTo(0, 0);
}
handleDataTypeChange(dataType: DataType) {
this.updateUrl({ dataType, page: 1n });
this.updateUrl({ dataType, page: 1 });
window.scrollTo(0, 0);
}
@ -606,11 +606,7 @@ export class Community extends Component<
.show_new_post_notifs;
// Only push these if you're on the first page, you pass the nsfw check, and it isn't blocked
if (
page === 1n &&
nsfwCheck(post_view) &&
!isPostBlocked(post_view)
) {
if (page === 1 && nsfwCheck(post_view) && !isPostBlocked(post_view)) {
this.state.posts.unshift(post_view);
if (showPostNotifs) {
notifyPost(post_view, this.context.router);

View file

@ -185,7 +185,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
<li className="list-inline-item badge badge-secondary">
{i18n.t("number_online", {
count: this.props.online,
formattedCount: numToSI(BigInt(this.props.online)),
formattedCount: numToSI(this.props.online),
})}
</li>
<li

View file

@ -35,7 +35,7 @@ interface EmojiFormState {
siteRes: GetSiteResponse;
customEmojis: CustomEmojiViewForm[];
loading: boolean;
page: bigint;
page: number;
}
interface CustomEmojiViewForm {
@ -46,7 +46,7 @@ interface CustomEmojiViewForm {
alt_text: string;
keywords: string;
changed: boolean;
page: bigint;
page: number;
}
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,
keywords: x.keywords.map(x => x.keyword).join(" "),
changed: false,
page: BigInt(1 + Math.floor(index / this.itemsPerPage)),
page: 1 + Math.floor(index / this.itemsPerPage),
})),
page: 1n,
page: 1,
};
state: EmojiFormState;
private scrollRef: any = {};
@ -125,10 +125,10 @@ export class EmojiForm extends Component<any, EmojiFormState> {
<tbody>
{this.state.customEmojis
.slice(
Number((this.state.page - 1n) * BigInt(this.itemsPerPage)),
Number((this.state.page - 1) * this.itemsPerPage),
Number(
(this.state.page - 1n) * BigInt(this.itemsPerPage) +
BigInt(this.itemsPerPage)
(this.state.page - 1) * this.itemsPerPage +
this.itemsPerPage
)
)
.map((cv, index) => (
@ -304,7 +304,7 @@ export class EmojiForm extends Component<any, EmojiFormState> {
else return i18n.t("custom_emoji_save_validation");
}
handlePageChange(page: bigint) {
handlePageChange(page: number) {
this.setState({ page: page });
}
@ -327,10 +327,9 @@ export class EmojiForm extends Component<any, EmojiFormState> {
) {
let custom_emojis = [...props.form.state.customEmojis];
let pagedIndex =
(props.form.state.page - 1n) * BigInt(props.form.itemsPerPage) +
BigInt(props.index);
(props.form.state.page - 1) * props.form.itemsPerPage + props.index;
let item = {
...props.form.state.customEmojis[Number(pagedIndex)],
...props.form.state.customEmojis[pagedIndex],
category: event.target.value,
changed: true,
};
@ -344,10 +343,9 @@ export class EmojiForm extends Component<any, EmojiFormState> {
) {
let custom_emojis = [...props.form.state.customEmojis];
let pagedIndex =
(props.form.state.page - 1n) * BigInt(props.form.itemsPerPage) +
BigInt(props.index);
(props.form.state.page - 1) * props.form.itemsPerPage + props.index;
let item = {
...props.form.state.customEmojis[Number(pagedIndex)],
...props.form.state.customEmojis[pagedIndex],
shortcode: event.target.value,
changed: true,
};
@ -361,10 +359,9 @@ export class EmojiForm extends Component<any, EmojiFormState> {
) {
let custom_emojis = [...props.form.state.customEmojis];
let pagedIndex =
(props.form.state.page - 1n) * BigInt(props.form.itemsPerPage) +
BigInt(props.index);
(props.form.state.page - 1) * props.form.itemsPerPage + props.index;
let item = {
...props.form.state.customEmojis[Number(pagedIndex)],
...props.form.state.customEmojis[pagedIndex],
image_url: props.overrideValue ?? event.target.value,
changed: true,
};
@ -378,10 +375,9 @@ export class EmojiForm extends Component<any, EmojiFormState> {
) {
let custom_emojis = [...props.form.state.customEmojis];
let pagedIndex =
(props.form.state.page - 1n) * BigInt(props.form.itemsPerPage) +
BigInt(props.index);
(props.form.state.page - 1) * props.form.itemsPerPage + props.index;
let item = {
...props.form.state.customEmojis[Number(pagedIndex)],
...props.form.state.customEmojis[pagedIndex],
alt_text: event.target.value,
changed: true,
};
@ -395,10 +391,9 @@ export class EmojiForm extends Component<any, EmojiFormState> {
) {
let custom_emojis = [...props.form.state.customEmojis];
let pagedIndex =
(props.form.state.page - 1n) * BigInt(props.form.itemsPerPage) +
BigInt(props.index);
(props.form.state.page - 1) * props.form.itemsPerPage + props.index;
let item = {
...props.form.state.customEmojis[Number(pagedIndex)],
...props.form.state.customEmojis[pagedIndex],
keywords: event.target.value,
changed: true,
};
@ -412,8 +407,7 @@ export class EmojiForm extends Component<any, EmojiFormState> {
cv: CustomEmojiViewForm;
}) {
let pagedIndex =
(props.form.state.page - 1n) * BigInt(props.form.itemsPerPage) +
BigInt(props.index);
(props.form.state.page - 1) * props.form.itemsPerPage + props.index;
if (props.cv.id != 0) {
const deleteForm: DeleteCustomEmoji = {
id: props.cv.id,
@ -458,9 +452,8 @@ export class EmojiForm extends Component<any, EmojiFormState> {
handleAddEmojiClick(form: EmojiForm, event: any) {
event.preventDefault();
let custom_emojis = [...form.state.customEmojis];
const page = BigInt(
1 + Math.floor(form.state.customEmojis.length / form.itemsPerPage)
);
const page =
1 + Math.floor(form.state.customEmojis.length / form.itemsPerPage);
let item: CustomEmojiViewForm = {
id: 0,
shortcode: "",

View file

@ -100,7 +100,7 @@ interface HomeProps {
listingType: ListingType;
dataType: DataType;
sort: SortType;
page: bigint;
page: number;
}
function getDataTypeFromQuery(type?: string): DataType {
@ -324,7 +324,7 @@ export class Home extends Component<any, HomeState> {
const type_ = getListingTypeFromQuery(listingType);
const sort = getSortTypeFromQuery(urlSort);
const page = urlPage ? BigInt(urlPage) : 1n;
const page = urlPage ? Number(urlPage) : 1;
const promises: Promise<any>[] = [];
@ -700,23 +700,23 @@ export class Home extends Component<any, HomeState> {
i.setState({ subscribedCollapsed: !i.state.subscribedCollapsed });
}
handlePageChange(page: bigint) {
handlePageChange(page: number) {
this.updateUrl({ page });
window.scrollTo(0, 0);
}
handleSortChange(val: SortType) {
this.updateUrl({ sort: val, page: 1n });
this.updateUrl({ sort: val, page: 1 });
window.scrollTo(0, 0);
}
handleListingTypeChange(val: ListingType) {
this.updateUrl({ listingType: val, page: 1n });
this.updateUrl({ listingType: val, page: 1 });
window.scrollTo(0, 0);
}
handleDataTypeChange(val: DataType) {
this.updateUrl({ dataType: val, page: 1n });
this.updateUrl({ dataType: val, page: 1 });
window.scrollTo(0, 0);
}
@ -765,11 +765,7 @@ export class Home extends Component<any, HomeState> {
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
if (
page === 1n &&
nsfwCheck(post_view) &&
!isPostBlocked(post_view)
) {
if (page === 1 && nsfwCheck(post_view) && !isPostBlocked(post_view)) {
const mui = UserService.Instance.myUserInfo;
const showPostNotifs =
mui?.local_user_view.local_user.show_new_post_notifs;

View file

@ -105,7 +105,7 @@ export class SiteSidebar extends Component<SiteSidebarProps, SiteSidebarState> {
<li className="list-inline-item badge badge-secondary">
{i18n.t("number_online", {
count: online,
formattedCount: numToSI(BigInt(online)),
formattedCount: numToSI(online),
})}
</li>
<li

View file

@ -111,7 +111,7 @@ interface ModlogState {
}
interface ModlogProps {
page: bigint;
page: number;
userId?: number | null;
modId?: number | null;
actionType: ModlogActionType;
@ -868,20 +868,20 @@ export class Modlog extends Component<
handleFilterActionChange(i: Modlog, event: any) {
i.updateUrl({
actionType: event.target.value as ModlogActionType,
page: 1n,
page: 1,
});
}
handlePageChange(page: bigint) {
handlePageChange(page: number) {
this.updateUrl({ page });
}
handleUserChange(option: Choice) {
this.updateUrl({ userId: getIdFromString(option.value) ?? null, page: 1n });
this.updateUrl({ userId: getIdFromString(option.value) ?? null, page: 1 });
}
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) => {

View file

@ -84,7 +84,7 @@ interface InboxState {
messages: PrivateMessageView[];
combined: ReplyType[];
sort: CommentSortType;
page: bigint;
page: number;
siteRes: GetSiteResponse;
loading: boolean;
}
@ -100,7 +100,7 @@ export class Inbox extends Component<any, InboxState> {
messages: [],
combined: [],
sort: "New",
page: 1n,
page: 1,
siteRes: this.isoData.site_res,
loading: true,
};
@ -466,18 +466,18 @@ export class Inbox extends Component<any, InboxState> {
);
}
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();
}
@ -492,7 +492,7 @@ export class Inbox extends Component<any, InboxState> {
let repliesForm: GetReplies = {
sort: "New",
unread_only: true,
page: 1n,
page: 1,
limit: fetchLimit,
auth,
};
@ -501,7 +501,7 @@ export class Inbox extends Component<any, InboxState> {
let personMentionsForm: GetPersonMentions = {
sort,
unread_only: true,
page: 1n,
page: 1,
limit: fetchLimit,
auth,
};
@ -509,7 +509,7 @@ export class Inbox extends Component<any, InboxState> {
let privateMessagesForm: GetPrivateMessages = {
unread_only: true,
page: 1n,
page: 1,
limit: fetchLimit,
auth,
};
@ -560,7 +560,7 @@ export class Inbox extends Component<any, InboxState> {
}
handleSortChange(val: CommentSortType) {
this.setState({ sort: val, page: 1n });
this.setState({ sort: val, page: 1 });
this.refetch();
}
@ -574,7 +574,7 @@ export class Inbox extends Component<any, InboxState> {
);
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);
}
@ -583,9 +583,9 @@ export class Inbox extends Component<any, InboxState> {
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);
}
}

View file

@ -18,13 +18,13 @@ interface PersonDetailsProps {
admins: PersonView[];
allLanguages: Language[];
siteLanguages: number[];
page: bigint;
limit: bigint;
page: number;
limit: number;
sort: SortType;
enableDownvotes: boolean;
enableNsfw: boolean;
view: PersonDetailsView;
onPageChange(page: bigint): bigint | any;
onPageChange(page: number): number | any;
}
enum ItemEnum {
@ -36,7 +36,7 @@ type ItemType = {
type_: ItemEnum;
view: CommentView | PostView;
published: string;
score: bigint;
score: number;
};
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);
}
}

View file

@ -81,7 +81,7 @@ interface ProfileState {
interface ProfileProps {
view: PersonDetailsView;
sort: SortType;
page: bigint;
page: number;
}
function getProfileQueryParams() {
@ -645,18 +645,18 @@ export class Profile extends Component<
this.fetchUserData();
}
handlePageChange(page: bigint) {
handlePageChange(page: number) {
this.updateUrl({ page });
}
handleSortChange(sort: SortType) {
this.updateUrl({ sort, page: 1n });
this.updateUrl({ sort, page: 1 });
}
handleViewChange(i: Profile, event: any) {
i.updateUrl({
view: PersonDetailsView[event.target.value],
page: 1n,
page: 1,
});
}

View file

@ -37,7 +37,7 @@ interface RegistrationApplicationsState {
listRegistrationApplicationsResponse?: ListRegistrationApplicationsResponse;
siteRes: GetSiteResponse;
unreadOrAll: UnreadOrAll;
page: bigint;
page: number;
loading: boolean;
}
@ -50,7 +50,7 @@ export class RegistrationApplications extends Component<
state: RegistrationApplicationsState = {
siteRes: this.isoData.site_res,
unreadOrAll: UnreadOrAll.Unread,
page: 1n,
page: 1,
loading: true,
};
@ -183,11 +183,11 @@ export class RegistrationApplications extends Component<
}
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();
}
@ -199,7 +199,7 @@ export class RegistrationApplications extends Component<
if (auth) {
let form: ListRegistrationApplications = {
unread_only: true,
page: 1n,
page: 1,
limit: fetchLimit,
auth,
};
@ -249,7 +249,7 @@ export class RegistrationApplications extends Component<
);
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);
}
}

View file

@ -75,7 +75,7 @@ interface ReportsState {
messageType: MessageType;
combined: ItemType[];
siteRes: GetSiteResponse;
page: bigint;
page: number;
loading: boolean;
}
@ -86,7 +86,7 @@ export class Reports extends Component<any, ReportsState> {
unreadOrAll: UnreadOrAll.Unread,
messageType: MessageType.All,
combined: [],
page: 1n,
page: 1,
siteRes: this.isoData.site_res,
loading: true,
};
@ -417,18 +417,18 @@ export class Reports extends Component<any, ReportsState> {
);
}
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();
}
@ -436,7 +436,7 @@ export class Reports extends Component<any, ReportsState> {
let promises: Promise<any>[] = [];
let unresolved_only = true;
let page = 1n;
let page = 1;
let limit = fetchLimit;
let auth = req.auth;
@ -548,9 +548,9 @@ export class Reports extends Component<any, ReportsState> {
);
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) {
@ -561,9 +561,9 @@ export class Reports extends Component<any, ReportsState> {
);
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) {
@ -574,9 +574,9 @@ export class Reports extends Component<any, ReportsState> {
);
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);
}

View file

@ -509,7 +509,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
type_: "Url",
sort: "TopAll",
listing_type: "All",
page: 1n,
page: 1,
limit: trendingFetchLimit,
auth: myAuth(false),
};
@ -539,7 +539,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
sort: "TopAll",
listing_type: "All",
community_id: this.state.form.community_id,
page: 1n,
page: 1,
limit: trendingFetchLimit,
auth: myAuth(false),
};

View file

@ -80,9 +80,9 @@ interface PostListingState {
showReportDialog: boolean;
reportReason?: string;
my_vote?: number;
score: bigint;
upvotes: bigint;
downvotes: bigint;
score: number;
upvotes: number;
downvotes: number;
}
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;
return pv.unread_comments == pv.counts.comments || pv.unread_comments == 0n
return pv.unread_comments == pv.counts.comments || pv.unread_comments == 0
? undefined
: pv.unread_comments;
}
@ -691,7 +691,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
{showScores() && (
<span
className={classNames("ml-2", {
invisible: this.state.downvotes === 0n,
invisible: this.state.downvotes === 0,
})}
>
{numToSI(this.state.downvotes)}
@ -1311,19 +1311,19 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
if (myVote == 1) {
this.setState({
score: this.state.score - 1n,
upvotes: this.state.upvotes - 1n,
score: this.state.score - 1,
upvotes: this.state.upvotes - 1,
});
} else if (myVote == -1) {
this.setState({
score: this.state.score + 2n,
upvotes: this.state.upvotes + 1n,
downvotes: this.state.downvotes - 1n,
score: this.state.score + 2,
upvotes: this.state.upvotes + 1,
downvotes: this.state.downvotes - 1,
});
} else {
this.setState({
score: this.state.score + 1n,
upvotes: this.state.upvotes + 1n,
score: this.state.score + 1,
upvotes: this.state.upvotes + 1,
});
}
@ -1354,19 +1354,19 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
if (myVote == 1) {
this.setState({
score: this.state.score - 2n,
upvotes: this.state.upvotes - 1n,
downvotes: this.state.downvotes + 1n,
score: this.state.score - 2,
upvotes: this.state.upvotes - 1,
downvotes: this.state.downvotes + 1,
});
} else if (myVote == -1) {
this.setState({
score: this.state.score + 1n,
downvotes: this.state.downvotes - 1n,
score: this.state.score + 1,
downvotes: this.state.downvotes - 1,
});
} else {
this.setState({
score: this.state.score - 1n,
downvotes: this.state.downvotes + 1n,
score: this.state.score - 1,
downvotes: this.state.downvotes + 1,
});
}

View file

@ -40,7 +40,7 @@ export class PostReport extends Component<PostReportProps, any> {
read: false,
creator_blocked: false,
my_vote: r.my_vote,
unread_comments: 0n,
unread_comments: 0,
};
return (

View file

@ -189,7 +189,7 @@ export class Post extends Component<any, PostState> {
type_: "Url",
sort: "TopAll",
listing_type: "All",
page: 1n,
page: 1,
limit: trendingFetchLimit,
auth: myAuth(false),
};

View file

@ -77,7 +77,7 @@ interface SearchProps {
listingType: ListingType;
communityId?: number | null;
creatorId?: number | null;
page: bigint;
page: number;
}
type FilterType = "creator" | "community";
@ -222,7 +222,7 @@ const personListing = ({ person, counts: { comment_count } }: PersonView) =>
function getListing(
listing: JSX.ElementClass,
count: bigint,
count: number,
translationKey: "number_of_comments" | "number_of_subscribers"
) {
return (
@ -863,7 +863,7 @@ export class Search extends Component<any, SearchState> {
});
handleSortChange(sort: SortType) {
this.updateUrl({ sort, page: 1n });
this.updateUrl({ sort, page: 1 });
}
handleTypeChange(i: Search, event: any) {
@ -871,32 +871,32 @@ export class Search extends Component<any, SearchState> {
i.updateUrl({
type,
page: 1n,
page: 1,
});
}
handlePageChange(page: bigint) {
handlePageChange(page: number) {
this.updateUrl({ page });
}
handleListingTypeChange(listingType: ListingType) {
this.updateUrl({
listingType,
page: 1n,
page: 1,
});
}
handleCommunityFilterChange({ value }: Choice) {
this.updateUrl({
communityId: getIdFromString(value) ?? null,
page: 1n,
page: 1,
});
}
handleCreatorFilterChange({ value }: Choice) {
this.updateUrl({
creatorId: getIdFromString(value) ?? null,
page: 1n,
page: 1,
});
}
@ -905,7 +905,7 @@ export class Search extends Component<any, SearchState> {
i.updateUrl({
q: i.state.searchText,
page: 1n,
page: 1,
});
}

View file

@ -22,12 +22,12 @@ export class UserService {
private static _instance: UserService;
public myUserInfo?: MyUserInfo;
public jwtInfo?: JwtInfo;
public unreadInboxCountSub: BehaviorSubject<bigint> =
new BehaviorSubject<bigint>(0n);
public unreadReportCountSub: BehaviorSubject<bigint> =
new BehaviorSubject<bigint>(0n);
public unreadApplicationCountSub: BehaviorSubject<bigint> =
new BehaviorSubject<bigint>(0n);
public unreadInboxCountSub: BehaviorSubject<number> =
new BehaviorSubject<number>(0);
public unreadReportCountSub: BehaviorSubject<number> =
new BehaviorSubject<number>(0);
public unreadApplicationCountSub: BehaviorSubject<number> =
new BehaviorSubject<number>(0);
private constructor() {
this.setJwtInfo();

View file

@ -70,12 +70,12 @@ export const webArchiveUrl = "https://web.archive.org";
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";
@ -128,8 +128,8 @@ export function getIdFromString(id?: string): number | undefined {
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(
@ -191,14 +191,14 @@ export function hotRankPost(post_view: PostView): number {
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}`);
@ -218,16 +218,14 @@ export function mdToHtmlInline(text: string) {
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;
}
@ -1364,7 +1362,7 @@ export async function fetchCommunities(q: string) {
type_: "Communities",
sort: "TopAll",
listing_type: "All",
page: 1n,
page: 1,
limit: fetchLimit,
auth: myAuth(false),
};
@ -1378,7 +1376,7 @@ export async function fetchUsers(q: string) {
type_: "Users",
sort: "TopAll",
listing_type: "All",
page: 1n,
page: 1,
limit: fetchLimit,
auth: myAuth(false),
};
@ -1415,7 +1413,7 @@ const SHORTNUM_SI_FORMAT = new Intl.NumberFormat("en-US", {
compactDisplay: "short",
});
export function numToSI(value: bigint): string {
export function numToSI(value: number): string {
return SHORTNUM_SI_FORMAT.format(value);
}

View file

@ -5334,10 +5334,10 @@ leac@^0.6.0:
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"