dce-reactkit 4.2.0-beta-select-admin-check.1 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -3875,6 +3875,10 @@ var LogAction;
3875
3875
  LogAction["Jump"] = "Jump";
3876
3876
  // Post a submission/message/etc. into the target
3877
3877
  LogAction["Post"] = "Post";
3878
+ // Like something
3879
+ LogAction["Like"] = "Like";
3880
+ // Dislike something
3881
+ LogAction["Dislike"] = "Dislike";
3878
3882
  // Unknown action
3879
3883
  LogAction["Unknown"] = "Unknown";
3880
3884
  })(LogAction || (LogAction = {}));
@@ -15357,7 +15361,7 @@ const LOG_REVIEW_STATUS_ROUTE = `${ROUTE_PATH_PREFIX}/logs/access_allowed`;
15357
15361
  * Route for checking if the current user is a select admin
15358
15362
  * @author Gabe Abrams
15359
15363
  */
15360
- const SELECT_ADMIN_CHECK_ROUTE = `${ROUTE_PATH_PREFIX}/select-admin/is-select-admin`;
15364
+ const SELECT_ADMIN_CHECK_ROUTE = '/api/admin/select/is-select-admin';
15361
15365
 
15362
15366
  // True if user is on mobile or tablet
15363
15367
  let cachedResult = undefined;
@@ -16422,6 +16426,42 @@ const getTimestampFromTimeInfoInET = (opts) => {
16422
16426
  return timestamp;
16423
16427
  };
16424
16428
 
16429
+ /*------------------------------------------------------------------------*/
16430
+ /* ------------------------------- Caching ------------------------------ */
16431
+ /*------------------------------------------------------------------------*/
16432
+ // If true, user is a select admin
16433
+ let cachedUserIsSelectAdmin;
16434
+ /*------------------------------------------------------------------------*/
16435
+ /* -------------------------------- Main -------------------------------- */
16436
+ /*------------------------------------------------------------------------*/
16437
+ /**
16438
+ * Checks if the current user is a select admin
16439
+ * @author Gardenia Liu
16440
+ * @returns true if the user is a select admin, false otherwise
16441
+ */
16442
+ const isSelectAdmin = () => __awaiter(void 0, void 0, void 0, function* () {
16443
+ // Use cached version if we have one
16444
+ if (cachedUserIsSelectAdmin !== undefined) {
16445
+ return cachedUserIsSelectAdmin;
16446
+ }
16447
+ // Check if the user is a select admin
16448
+ try {
16449
+ const userIsSelectAdmin = yield visitServerEndpoint({
16450
+ path: SELECT_ADMIN_CHECK_ROUTE,
16451
+ method: 'GET',
16452
+ });
16453
+ // Cache the result
16454
+ cachedUserIsSelectAdmin = !!userIsSelectAdmin;
16455
+ // Return the result
16456
+ return userIsSelectAdmin;
16457
+ }
16458
+ catch (err) {
16459
+ // Error means the user isn't a select admin
16460
+ cachedUserIsSelectAdmin = false;
16461
+ return false;
16462
+ }
16463
+ });
16464
+
16425
16465
  /**
16426
16466
  * Days of the week
16427
16467
  * @author Gabe Abrams
@@ -16517,6 +16557,7 @@ exports.getWordCount = getWordCount;
16517
16557
  exports.idify = idify;
16518
16558
  exports.initClient = initClient;
16519
16559
  exports.isMobileOrTablet = isMobileOrTablet;
16560
+ exports.isSelectAdmin = isSelectAdmin;
16520
16561
  exports.leaveToURL = leaveToURL;
16521
16562
  exports.logClientEvent = logClientEvent;
16522
16563
  exports.makeLinksClickable = makeLinksClickable;