aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/reviewDB/index.tsx
diff options
context:
space:
mode:
authorManti <67705577+mantikafasi@users.noreply.github.com>2023-09-21 18:16:15 +0300
committerGitHub <noreply@github.com>2023-09-21 17:16:15 +0200
commite5c0898dd6ee4bae213aa2d727e15714739d2f91 (patch)
treeb429661bc240115992c70b36974068139cc39a55 /src/plugins/reviewDB/index.tsx
parent9550b74b2ac00be97201855efc85bc527926d610 (diff)
downloadVencord-e5c0898dd6ee4bae213aa2d727e15714739d2f91.tar.gz
Vencord-e5c0898dd6ee4bae213aa2d727e15714739d2f91.tar.bz2
Vencord-e5c0898dd6ee4bae213aa2d727e15714739d2f91.zip
[ReviewDB] add emojis, discord markdown & notifications (#1718)
Co-authored-by: V <vendicated@riseup.net>
Diffstat (limited to 'src/plugins/reviewDB/index.tsx')
-rw-r--r--src/plugins/reviewDB/index.tsx65
1 files changed, 29 insertions, 36 deletions
diff --git a/src/plugins/reviewDB/index.tsx b/src/plugins/reviewDB/index.tsx
index de09ac7..a519713 100644
--- a/src/plugins/reviewDB/index.tsx
+++ b/src/plugins/reviewDB/index.tsx
@@ -24,13 +24,13 @@ import ExpandableHeader from "@components/ExpandableHeader";
import { OpenExternalIcon } from "@components/Icons";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
-import { Alerts, Menu, useState } from "@webpack/common";
+import { Alerts, Menu, Parser, useState } from "@webpack/common";
import { Guild, User } from "discord-types/general";
import { openReviewsModal } from "./components/ReviewModal";
import ReviewsView from "./components/ReviewsView";
-import { UserType } from "./entities";
-import { getCurrentUserInfo } from "./reviewDbApi";
+import { NotificationType } from "./entities";
+import { getCurrentUserInfo, readNotification } from "./reviewDbApi";
import { settings } from "./settings";
import { showToast } from "./utils";
@@ -78,40 +78,33 @@ export default definePlugin({
addContextMenuPatch("guild-header-popout", guildPopoutPatch);
- if (user.banInfo) {
- const endDate = new Date(user.banInfo.banEndDate);
- if (endDate.getTime() > Date.now() && (s.user?.banInfo?.banEndDate ?? 0) < endDate.getTime()) {
- Alerts.show({
- title: "You have been banned from ReviewDB",
- body: (
- <>
- <p>
- You are banned from ReviewDB {
- user.type === UserType.Banned
- ? "permanently"
- : "until " + endDate.toLocaleString()
- }
- </p>
- {user.banInfo.reviewContent && (
- <p>Offending Review: {user.banInfo.reviewContent}</p>
- )}
- <p>Continued offenses will result in a permanent ban.</p>
- </>
- ),
- cancelText: "Appeal",
- confirmText: "Ok",
- onCancel: () =>
- VencordNative.native.openExternal(
- "https://reviewdb.mantikafasi.dev/api/redirect?"
- + new URLSearchParams({
- token: settings.store.token!,
- page: "dashboard/appeal"
- })
- )
- });
- }
+ if (user.notification) {
+ const props = user.notification.type === NotificationType.Ban ? {
+ cancelText: "Appeal",
+ confirmText: "Ok",
+ onCancel: () =>
+ VencordNative.native.openExternal(
+ "https://reviewdb.mantikafasi.dev/api/redirect?"
+ + new URLSearchParams({
+ token: settings.store.token!,
+ page: "dashboard/appeal"
+ })
+ )
+ } : {};
+
+ Alerts.show({
+ title: user.notification.title,
+ body: (
+ Parser.parse(
+ user.notification.content,
+ false
+ )
+ ),
+ ...props
+ });
+
+ readNotification(user.notification.id);
}
-
s.user = user;
}, 4000);
},