]> Untitled Git - lemmy-ui.git/commitdiff
Changing all bigints to numbers
authorDessalines <tyhou13@gmx.com>
Mon, 15 May 2023 19:53:29 +0000 (15:53 -0400)
committerDessalines <tyhou13@gmx.com>
Mon, 15 May 2023 19:53:29 +0000 (15:53 -0400)
24 files changed:
package.json
src/shared/components/app/navbar.tsx
src/shared/components/comment/comment-node.tsx
src/shared/components/common/paginator.tsx
src/shared/components/community/communities.tsx
src/shared/components/community/community.tsx
src/shared/components/community/sidebar.tsx
src/shared/components/home/emojis-form.tsx
src/shared/components/home/home.tsx
src/shared/components/home/site-sidebar.tsx
src/shared/components/modlog.tsx
src/shared/components/person/inbox.tsx
src/shared/components/person/person-details.tsx
src/shared/components/person/profile.tsx
src/shared/components/person/registration-applications.tsx
src/shared/components/person/reports.tsx
src/shared/components/post/post-form.tsx
src/shared/components/post/post-listing.tsx
src/shared/components/post/post-report.tsx
src/shared/components/post/post.tsx
src/shared/components/search.tsx
src/shared/services/UserService.ts
src/shared/utils.ts
yarn.lock

index c9a19c2f25861797afbec7d939ac399ac8b994a1..2f16b8d3797fc72970f25074a864492d7645fc61 100644 (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.16",
+    "lemmy-js-client": "0.17.2-rc.17",
     "markdown-it": "^13.0.1",
     "markdown-it-container": "^3.0.0",
     "markdown-it-emoji": "^2.0.2",
index 448e92cbb05cd9f5dee8949a1637efb43c48f0d8..128d40238cebd9695004476939660b4904692859 100644 (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);
index d6fe0862a1bc2a726dd5aea7bf8f56c7dbbe7aa2..d68c5b30695a29bd8ab1c337b2a3eab3d45461c4 100644 (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),
index 2c877575d7daa2b370c5d8442f3b094b381c5f0d..75acde3e105ce59cc5a3510ee1f432392e269d6c 100644 (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);
   }
 }
index af7d827a045f42e3426630ac00b631d0df8aacba..2e147b83f83e85d0e83ec1985256f921c961878a 100644 (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,
     });
   }
 
index 8a70378b795abebad70838b41d76e58952515a8a..af562c195cac2bf4b248b3d443371fec402c7eb0 100644 (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);
index 43167554a2d3f5a4cc0b8f208f85dcdaa8219398..a5eef75c3f7c420d46f424e9f2f18622620e0ef9 100644 (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
index 409e1c4c6b81e358acf79402e464362f8622815c..d63633bef1056ab0a6c767a028650629cf0a6122 100644 (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: "",
index 0cd5b9897995489f0c75a99850161d4c46fbc8fa..52a82126082eb3d371fb47fc16c5a0c8fe8512dc 100644 (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;
index 0592f93fa84eb53a818c2d2e8c4b67dcf07bc33f..23fbf40010a8211035672b07d72797be51f403a2 100644 (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
index 922afc063bf253bd3b8e6ff19128546e9de28420..ef28816b668147dbb56ab8326ccfe579e150a401 100644 (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) => {
index 10af488e6ad4c5b9eba3bb63548f8bf5e0d99d96..a39977917480aa13c8713abc0ff2fa8e12d65338 100644 (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,
   };
@@ -471,18 +471,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();
   }
 
@@ -497,7 +497,7 @@ export class Inbox extends Component<any, InboxState> {
       let repliesForm: GetReplies = {
         sort: "New",
         unread_only: true,
-        page: 1n,
+        page: 1,
         limit: fetchLimit,
         auth,
       };
@@ -506,7 +506,7 @@ export class Inbox extends Component<any, InboxState> {
       let personMentionsForm: GetPersonMentions = {
         sort,
         unread_only: true,
-        page: 1n,
+        page: 1,
         limit: fetchLimit,
         auth,
       };
@@ -514,7 +514,7 @@ export class Inbox extends Component<any, InboxState> {
 
       let privateMessagesForm: GetPrivateMessages = {
         unread_only: true,
-        page: 1n,
+        page: 1,
         limit: fetchLimit,
         auth,
       };
@@ -565,7 +565,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();
   }
 
@@ -579,7 +579,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);
     }
@@ -588,9 +588,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);
     }
   }
 
index 910ea986b0ef7eab48636d6b2a3de1417ba682cb..d1ca4e38eee5f3a0b8bb8a6679eb6b23aebdb218 100644 (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);
   }
 }
index b38dae937f7a1a8dbcaefb3f43ee8910b65cf972..42c7c306ccf54a47d3a741506bc976e8cf609de4 100644 (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,
     });
   }
 
index cd99bcc454aadb7b0d9ad2c4efbda242ef9ee317..181674121ba1cd81b73ff1820e31e544cb889784 100644 (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,
   };
 
@@ -188,11 +188,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();
   }
@@ -204,7 +204,7 @@ export class RegistrationApplications extends Component<
     if (auth) {
       let form: ListRegistrationApplications = {
         unread_only: true,
-        page: 1n,
+        page: 1,
         limit: fetchLimit,
         auth,
       };
@@ -254,7 +254,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);
     }
   }
index 8fc30810898b9629a6652554d979ed4b4197d65a..0af56b53bf13809dad421ebb798b109a09f5338a 100644 (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,
   };
@@ -422,18 +422,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();
   }
 
@@ -441,7 +441,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;
 
@@ -553,9 +553,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) {
@@ -566,9 +566,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) {
@@ -579,9 +579,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);
     }
index e7edf22c7835dee9f2d7d7363e126812e9e1f407..ef168374a7b1e87e3cab9f631334bf55cac8e0fc 100644 (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),
       };
index b3a93c095f4490a00a91475546281efab999a81c..1096b73eab43fd7ee8f5ed491a18512fdb066203 100644 (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,
       });
     }
 
index 5ef25b4d484245dd528a82d430bea2f0e64c772e..0122cbe34b27ba8f91a7dc01ef45cce9627b9a9a 100644 (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 (
index eed5aad1bcb11109edd3690ebd686ed28fcb9d19..96d7911ec792307ffd2f9ef58ac60ddca4062d32 100644 (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),
       };
index 94e9d29f6b6f50fe73770bbb47cf593b44972ec4..9f762785ac8b40994a4a0e0e8cd0245ba1a19d70 100644 (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,
     });
   }
 
index 16540f2373dd20f1a3162912ac8e6dc274dd2f3f..cc036b498e75c07ff0a8d6f9c45d72ef532d1dea 100644 (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();
index d65d2d3739718d14985fdc2198ad04971e8ad57c..b5b39c4f9a507e1cd2d2cbd67291d9b43e03daf1 100644 (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";
@@ -122,8 +122,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(
@@ -185,14 +185,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}`);
@@ -212,16 +212,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;
 }
@@ -1358,7 +1356,7 @@ export async function fetchCommunities(q: string) {
     type_: "Communities",
     sort: "TopAll",
     listing_type: "All",
-    page: 1n,
+    page: 1,
     limit: fetchLimit,
     auth: myAuth(false),
   };
@@ -1372,7 +1370,7 @@ export async function fetchUsers(q: string) {
     type_: "Users",
     sort: "TopAll",
     listing_type: "All",
-    page: 1n,
+    page: 1,
     limit: fetchLimit,
     auth: myAuth(false),
   };
@@ -1407,7 +1405,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);
 }
 
index 476dab1a5746022ff3230b1c24b31a32f558fd75..24b8a351c8b3c6a8616f2158b60152d8584ade4a 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -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.16:
-  version "0.17.2-rc.16"
-  resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.2-rc.16.tgz#404c02917291e7e89fdece75b49e7dc68c73492a"
-  integrity sha512-plAZn7ClopgjcTGTfh4b19jF894ucMfQh54J0P2DhQIG0k1Ic0ubq0rY1WZ+9yDyup6vCXF1i5MCylfNAs5Gxw==
+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"