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