Skip to content

Commit 964d829

Browse files
committed
Adding suggestions
1 parent d11c042 commit 964d829

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/jupyter-chat/src/widgets/chat-widget.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
import { ReactWidget } from '@jupyterlab/apputils';
77
import { Cell } from '@jupyterlab/cells';
88
import { DirListing } from '@jupyterlab/filebrowser';
9+
import { DocumentWidget } from '@jupyterlab/docregistry';
910
import { ICell, isCode, isMarkdown, isRaw } from '@jupyterlab/nbformat';
1011
import React from 'react';
1112
import { Message } from '@lumino/messaging';
1213
import { Drag } from '@lumino/dragdrop';
14+
import { Widget } from '@lumino/widgets';
1315

1416
import { Chat, IInputToolbarRegistry, MESSAGE_CLASS } from '../components';
1517
import { chatIcon } from '../icons';
@@ -332,27 +334,26 @@ export class ChatWidget extends ReactWidget {
332334
* Process dropped tabBar files
333335
*/
334336
private _processTabDrop(event: Drag.Event) {
335-
const factory = event.mimeData.getData(TABBAR_FILE_MIME) as () => any;
337+
const factory = event.mimeData.getData(TABBAR_FILE_MIME) as () => Widget;
336338
if (!factory) {
337339
console.warn('No factory in drag event');
338340
return;
339341
}
340342

341343
const widget = factory();
342-
if (!widget) {
343-
console.warn('Factory did not return a widget');
344+
if (!widget || !(widget instanceof DocumentWidget)) {
345+
console.warn('No file associated to the element');
344346
return;
345347
}
346348

347-
const path =
348-
typeof widget.context?.path === 'string' ? widget.context.path : null;
349+
const path = widget.context.path;
349350
if (!path) {
350351
console.warn('Widget has no path');
351352
return;
352353
}
353354

354355
const mimetype =
355-
widget.context?.model?.mimeType || 'application/octet-stream';
356+
widget.context.model?.mimeType || 'application/octet-stream';
356357
const attachment: IFileAttachment = {
357358
type: 'file',
358359
value: path,

0 commit comments

Comments
 (0)