Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions client/reader/components/quick-post/hooks/use-post-mutation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { mutationOptions } from '@tanstack/react-query';
import { stripHTML } from 'calypso/lib/formatting';
import wpcom from 'calypso/lib/wp';

interface PostItem {
Expand All @@ -20,24 +19,10 @@ const request = async ( { postContent, status, siteId }: PostMutationVariables )
if ( ! siteId ) {
return Promise.reject( new Error( 'Site ID is required' ) );
}
return (
wpcom
.site( siteId )
.post()
//TODO: Revisit this title generation
.add( {
title:
(
stripHTML( postContent )
.split( '\n' )
.find( ( line: string ) => line.trim() ) || ''
)
.substring( 0, 57 )
.trim() + '...',
content: postContent,
status: status,
} )
);
return wpcom.site( siteId ).post().add( {
content: postContent,
status: status,
} );
};

export const savePostMutation = ( { siteId }: { siteId?: number } ) => {
Expand Down
2 changes: 0 additions & 2 deletions client/reader/components/quick-post/test/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ jest.mock( 'calypso/state/reader/analytics/useRecordReaderTracksEvent', () => (
const mockSavePostApi = ( type: 'publish' | 'draft' ) => {
return nock( 'https://public-api.wordpress.com:443' )
.post( '/rest/v1.1/sites/123/posts/new', {
title: 'Test post...',
content: 'Test post',
status: type,
} )
Expand Down Expand Up @@ -172,7 +171,6 @@ describe( 'QuickPost', () => {
it( 'shows an error notice when the post is not saved', async () => {
nock( 'https://public-api.wordpress.com:443' )
.post( '/rest/v1.1/sites/123/posts/new', {
title: 'Test post...',
content: 'Test post',
status: 'publish',
} )
Expand Down