Better types for WebAPI
This commit is contained in:
parent
c05d23e628
commit
b9d6497cb1
22 changed files with 156 additions and 107 deletions
|
@ -8,6 +8,7 @@ import { action } from '@storybook/addon-actions';
|
|||
import { times } from 'lodash';
|
||||
|
||||
import { setupI18n } from '../../../util/setupI18n';
|
||||
import { CapabilityError } from '../../../types/errors';
|
||||
import enMessages from '../../../../_locales/en/messages.json';
|
||||
import { ConversationDetails, Props } from './ConversationDetails';
|
||||
import { ConversationType } from '../../../state/ducks/conversations';
|
||||
|
@ -152,9 +153,7 @@ story.add('Group add with missing capabilities', () => (
|
|||
{...createProps()}
|
||||
canEditGroupInfo
|
||||
addMembers={async () => {
|
||||
const error = new Error();
|
||||
error.code = 'E_NO_CAPABILITY';
|
||||
throw error;
|
||||
throw new CapabilityError('stories');
|
||||
}}
|
||||
/>
|
||||
));
|
||||
|
|
|
@ -9,6 +9,7 @@ import { getMutedUntilText } from '../../../util/getMutedUntilText';
|
|||
|
||||
import { LocalizerType } from '../../../types/Util';
|
||||
import { MediaItemType } from '../../../types/MediaItem';
|
||||
import { CapabilityError } from '../../../types/errors';
|
||||
import { missingCaseError } from '../../../util/missingCaseError';
|
||||
|
||||
import { DisappearingTimerSelect } from '../../DisappearingTimerSelect';
|
||||
|
@ -224,7 +225,7 @@ export const ConversationDetails: React.ComponentType<Props> = ({
|
|||
setModalState(ModalState.NothingOpen);
|
||||
setAddGroupMembersRequestState(RequestState.Inactive);
|
||||
} catch (err) {
|
||||
if (err.code === 'E_NO_CAPABILITY') {
|
||||
if (err instanceof CapabilityError) {
|
||||
setMembersMissingCapability(true);
|
||||
setAddGroupMembersRequestState(RequestState.InactiveWithError);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue