mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-24 11:29:12 +00:00
parent
175144cc7a
commit
dec4aa9619
4 changed files with 4 additions and 32 deletions
|
@ -13,7 +13,6 @@ export const verifyRequest = async (
|
|||
const signature = request.headers.get('x-signature-ed25519');
|
||||
|
||||
if (!timestamp || !signature) {
|
||||
console.error("interactions: missing signature headers", { timestamp, signature });
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -32,13 +31,8 @@ export const verifyRequest = async (
|
|||
bufferizeString(timestamp + JSON.stringify(interaction))
|
||||
);
|
||||
|
||||
if (!verified) {
|
||||
console.error("interactions: signature verification failed", { timestamp, signature });
|
||||
}
|
||||
|
||||
return verified;
|
||||
} catch (e) {
|
||||
console.error("interactions: signature verification failed", e);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2,10 +2,10 @@ import { Popover } from '@roleypoly/design-system/atoms/popover';
|
|||
import { Role } from '@roleypoly/design-system/atoms/role';
|
||||
import { RoleSearch } from '@roleypoly/design-system/molecules/role-search';
|
||||
import { Role as RoleT } from '@roleypoly/types';
|
||||
import { sortBy, uniq } from 'lodash';
|
||||
import React from 'react';
|
||||
import { GoPlus } from 'react-icons/go';
|
||||
import { AddRoleButton, EditableRoleListStyled } from './EditableRoleList.styled';
|
||||
import { sortByReverse } from '@roleypoly/misc-utils/sortBy';
|
||||
|
||||
type Props = {
|
||||
roles: RoleT[];
|
||||
|
@ -36,7 +36,7 @@ export const EditableRoleList = (props: Props) => {
|
|||
<EditableRoleListStyled>
|
||||
{props.selectedRoles.length !== 0 ? (
|
||||
<>
|
||||
{sortByReverse(
|
||||
{sortBy(
|
||||
props.roles.filter((r) => props.selectedRoles.includes(r.id)),
|
||||
'position'
|
||||
).map((role) => (
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Role } from '@roleypoly/design-system/atoms/role';
|
||||
import { AmbientLarge, LargeText } from '@roleypoly/design-system/atoms/typography';
|
||||
import { sortByReverse } from '@roleypoly/misc-utils/sortBy';
|
||||
import { sortBy } from '@roleypoly/misc-utils/sortBy';
|
||||
import { Category as RPCCategory, Role as RPCRole, RoleSafety } from '@roleypoly/types';
|
||||
import * as React from 'react';
|
||||
import ReactTooltip from 'react-tooltip';
|
||||
|
@ -47,7 +47,7 @@ export const PickerCategory = (props: CategoryProps) => (
|
|||
)}
|
||||
</Head>
|
||||
<Category>
|
||||
{sortByReverse(props.roles, 'position').map((role, idx) => (
|
||||
{sortBy(props.roles, 'position').map((role, idx) => (
|
||||
<Container key={idx}>
|
||||
<Role
|
||||
role={role}
|
||||
|
|
|
@ -19,25 +19,3 @@ export const sortBy = <T, Key extends keyof T>(
|
|||
return -1;
|
||||
});
|
||||
};
|
||||
|
||||
export const sortByReverse = <T, Key extends keyof T>(
|
||||
array: T[],
|
||||
key: Key,
|
||||
predicate?: (a: T[typeof key], b: T[typeof key]) => number
|
||||
) => {
|
||||
return array.sort((a, b) => {
|
||||
if (predicate) {
|
||||
return predicate(a[key], b[key]);
|
||||
}
|
||||
|
||||
if (a[key] === b[key]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (a[key] > b[key]) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
});
|
||||
}
|
Loading…
Add table
Reference in a new issue