Skip to content

Commit 971efb5

Browse files
committed
Cleaned up unused code.
1 parent ac59ed8 commit 971efb5

File tree

1 file changed

+24
-58
lines changed

1 file changed

+24
-58
lines changed

src/notebook.ts

Lines changed: 24 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
1-
// @ts-nocheck
21
import {
3-
Cell,
42
CodeCell,
5-
CellModel,
6-
CodeCellModel,
7-
MarkdownCellModel,
8-
RawCellModel
3+
CodeCellModel
94
} from '@jupyterlab/cells';
105
import { NotebookPanel } from '@jupyterlab/notebook';
11-
import { KernelMessage } from '@jupyterlab/services';
126
import {
137
CellChange,
148
createMutex,
15-
ISharedCodeCell,
16-
ISharedMarkdownCell,
17-
ISharedRawCell,
18-
YCodeCell
9+
ISharedCodeCell
1910
} from '@jupyter/ydoc';
2011
import { IOutputAreaModel, OutputAreaModel } from '@jupyterlab/outputarea';
12+
import { IOutputModel } from '@jupyterlab/rendermime';
2113
import { requestAPI } from './handler';
22-
import { CellList } from '@jupyterlab/notebook';
2314

2415
import { ObservableList } from '@jupyterlab/observables';
2516

@@ -130,84 +121,59 @@ CodeCellModel.prototype.onOutputsChange = function (
130121
event: IOutputAreaModel.ChangedArgs
131122
) {
132123
console.debug('Inside onOutputsChange, called with event: ', event);
133-
return
134-
// @ts-ignore
135-
const codeCell = this.sharedModel as YCodeCell;
136-
globalModelDBMutex(() => {
137-
if (event.type == 'remove') {
138-
codeCell.updateOutputs(event.oldIndex, event.oldValues.length, []);
139-
}
140-
});
141124
};
142125

126+
127+
/* A new OutputAreaModel that loads outputs from outputs service */
143128
class RtcOutputAreaModel extends OutputAreaModel implements IOutputAreaModel{
144-
/**
145-
* Construct a new observable outputs instance.
146-
*/
147129
constructor(options: IOutputAreaModel.IOptions = {}) {
148130
super({...options, values: []})
131+
// @ts-ignore
149132
this._trusted = !!options.trusted;
133+
// @ts-ignore
150134
this.contentFactory =
151135
options.contentFactory || OutputAreaModel.defaultContentFactory;
152136
this.list = new ObservableList<IOutputModel>();
137+
// @ts-ignore
138+
this.list.changed.connect(this._onListChanged, this);
153139
if (options.values) {
154140
// Create an array to store promises for each value
155-
const valuePromises = options.values.map((value, originalIndex) => {
156-
console.log("originalIndex: ", originalIndex, ", value: ", value);
157-
// If value has a URL, fetch the data, otherwise just use the value directly
141+
const valuePromises = options.values.map((value, index) => {
142+
console.debug("output #${index}, value: ${value}");
143+
// @ts-ignore
158144
if (value.metadata?.url) {
145+
// @ts-ignore
159146
return requestAPI(value.metadata.url)
160147
.then(data => {
161-
console.log("data from outputs service: " , data)
162-
return {data, originalIndex}
148+
return data
163149
})
164150
.catch(error => {
165151
console.error('Error fetching output:', error);
166-
// If fetch fails, return original value to maintain order
167-
return { data: null, originalIndex };
152+
return null;
168153
});
169154
} else {
170155
// For values without url, return immediately with original value
171-
return Promise.resolve({ data: value, originalIndex });
156+
return Promise.resolve(value);
172157
}
173158
});
174159

175160
// Wait for all promises to resolve and add values in original order
176161
Promise.all(valuePromises)
177162
.then(results => {
178-
// Sort by original index to maintain order
179-
results.sort((a, b) => a.originalIndex - b.originalIndex);
180-
181-
console.log("After fetching outputs...")
163+
console.log("After fetching from outputs service:")
182164
// Add each value in order
183-
results.forEach((result) => {
184-
console.log("originalIndex: ", result.originalIndex, ", data: ", result.data)
185-
if(result.data && !this.isDisposed){
186-
const index = this._add(result.data) - 1;
165+
results.forEach((data, index) => {
166+
console.debug("output #${index}, data: ${data}");
167+
if(data && !this.isDisposed){
168+
// @ts-ignore
169+
const index = this._add(data) - 1;
187170
const item = this.list.get(index);
171+
// @ts-ignore
188172
item.changed.connect(this._onGenericChange, this);
189173
}
190174
});
191-
192-
// Connect the list changed handler after all items are added
193-
//this.list.changed.connect(this._onListChanged, this);
194-
})/*
195-
.catch(error => {
196-
console.error('Error processing values:', error);
197-
// If something goes wrong, fall back to original behavior
198-
options.values.forEach(value => {
199-
const index = this._add(value) - 1;
200-
const item = this.list.get(index);
201-
item.changed.connect(this._onGenericChange, this);
202-
});
203-
this.list.changed.connect(this._onListChanged, this);
204-
});*/
205-
} else {
206-
// If no values, just connect the list changed handler
207-
//this.list.changed.connect(this._onListChanged, this);
175+
});
208176
}
209-
210-
this.list.changed.connect(this._onListChanged, this);
211177
}
212178
}
213179

0 commit comments

Comments
 (0)