Skip to content

Commit

Permalink
Fix: image content types (#637)
Browse files Browse the repository at this point in the history
Fix: image content types
  • Loading branch information
thewahome committed Jul 17, 2020
2 parents 2ca7df4 + 92e1467 commit 7183703
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/app/services/actions/query-action-creator-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function isImageResponse(contentType: string) {
if (!contentType) { return false; }
return (
contentType === 'application/octet-stream' ||
contentType.substr(0, 6) === 'image/'
contentType.includes('image/')
);
}

Expand Down
8 changes: 6 additions & 2 deletions src/app/services/actions/query-action-creators.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { MessageBarType } from 'office-ui-fabric-react';

import { ContentType } from '../../../types/enums';
import { IHistoryItem } from '../../../types/history';
import { IQuery } from '../../../types/query-runner';
import { writeHistoryData } from '../../views/sidebar/history/history-utils';
import { anonymousRequest, authenticatedRequest, parseResponse, queryResponse } from './query-action-creator-util';
import {
anonymousRequest, authenticatedRequest,
isImageResponse, parseResponse, queryResponse
} from './query-action-creator-util';
import { setQueryResponseStatus } from './query-status-action-creator';
import { addHistoryItem } from './request-history-action-creators';

Expand Down Expand Up @@ -83,7 +87,7 @@ async function createHistory(response: Response, respHeaders: any, query: IQuery
const responseHeaders = { ...respHeaders };
const contentType = respHeaders['content-type'];

if (contentType === ContentType.Image) {
if (isImageResponse(contentType)) {
result = {
message: 'Run the query to view the image'
};
Expand Down
15 changes: 8 additions & 7 deletions src/app/views/query-response/pivot-items/pivot-items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react';
import { ThemeContext } from '../../../../themes/theme-context';
import { ContentType, Mode } from '../../../../types/enums';
import { IQuery } from '../../../../types/query-runner';
import { isImageResponse } from '../../../services/actions/query-action-creator-util';
import { lookupTemplate } from '../../../utils/adaptive-cards-lookup';
import { Image, Monaco } from '../../common';
import { genericCopy } from '../../common/copy';
Expand Down Expand Up @@ -112,14 +113,14 @@ function displayResultComponent(headers: any, body: any, verb: string) {
case ContentType.XML:
return <Monaco body={formatXml(body)} verb={verb} language='xml' />;

case ContentType.Image:
return <Image
styles={{ padding: '10px' }}
body={body}
alt='profile image'
/>;

default:
if (isImageResponse(contentType)) {
return <Image
styles={{ padding: '10px' }}
body={body}
alt='profile image'
/>;
}
return <Monaco body={body} verb={verb} language={language} />;
}
}
Expand Down

0 comments on commit 7183703

Please sign in to comment.