Skip to content

Commit 355cede

Browse files
committed
Remove rendering logic from collections
1 parent 0efb8de commit 355cede

4 files changed

Lines changed: 20 additions & 59 deletions

File tree

smart-chats/smart_thread.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class SmartThread extends SmartSource {
8383
* @returns {Promise<DocumentFragment>} The rendered thread interface.
8484
*/
8585
async render(container = this.container, opts = {}) {
86-
const frag = await this.render_component('thread', opts);
86+
const frag = await this.env.render_component('thread', this, opts);
8787
if (container) {
8888
container.empty();
8989
if (container.classList.contains('sc-thread')) {

smart-collections/collection.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -460,15 +460,6 @@ export class Collection {
460460
this.env.collections[this.collection_key] = null;
461461
}
462462

463-
/**
464-
* Helper function to render a component in the collection scope
465-
* @param {*} component_key
466-
* @param {*} opts
467-
* @returns
468-
*/
469-
async render_component(component_key, opts = {}) {
470-
return await this.env.render_component(component_key, this, opts);
471-
}
472463
// only show process notice if taking longer than 1 second
473464
show_process_notice(process, opts = {}) {
474465
if(!this.debounce_process_notice) this.debounce_process_notice = {};

smart-collections/item.js

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,6 @@ export class CollectionItem {
258258
*/
259259
parse() { /* NO-OP by default */ }
260260

261-
/**
262-
* Helper function to render a component in the item scope
263-
* @param {*} component_key
264-
* @param {*} opts
265-
* @returns
266-
*/
267-
async render_component(component_key, opts = {}) {
268-
return await this.env.render_component(component_key, this, opts);
269-
}
270-
271261
get actions() {
272262
if(!this._actions) {
273263
this._actions = Object.entries(this.env.opts.items[this.item_type_key].actions || {}).reduce((acc, [k,v]) => {
@@ -357,19 +347,19 @@ export class CollectionItem {
357347
this.env.smart_settings.save();
358348
}
359349

360-
/**
361-
* Render this item into a container using the item's component.
362-
* @deprecated 2024-12-02 Use explicit component pattern from environment
363-
* @param {HTMLElement} container
364-
* @param {Object} opts
365-
* @returns {Promise<HTMLElement>}
366-
*/
367-
async render_item(container, opts = {}) {
368-
const frag = await this.component.call(this.smart_view, this, opts);
369-
this.env.smart_view.empty(container);
370-
container.appendChild(frag);
371-
return container;
372-
}
350+
// /**
351+
// * Render this item into a container using the item's component.
352+
// * @deprecated 2024-12-02 Use explicit component pattern from environment
353+
// * @param {HTMLElement} container
354+
// * @param {Object} opts
355+
// * @returns {Promise<HTMLElement>}
356+
// */
357+
// async render_item(container, opts = {}) {
358+
// const frag = await this.component.call(this.smart_view, this, opts);
359+
// this.env.smart_view.empty(container);
360+
// container.appendChild(frag);
361+
// return container;
362+
// }
373363

374364
/**
375365
* @deprecated use env.smart_view
@@ -380,12 +370,12 @@ export class CollectionItem {
380370
return this._smart_view;
381371
}
382372

383-
/**
384-
* Override in child classes to set the component for this item
385-
* @deprecated 2024-12-02
386-
* @returns {Function} The render function for this component
387-
*/
388-
get component() { return item_component; }
373+
// /**
374+
// * Override in child classes to set the component for this item
375+
// * @deprecated 2024-12-02
376+
// * @returns {Function} The render function for this component
377+
// */
378+
// get component() { return item_component; }
389379
}
390380

391381
/**

smart-entities/smart_entity.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -306,33 +306,13 @@ export class SmartEntity extends CollectionItem {
306306
*/
307307
get path() { return this.data.path; }
308308

309-
/**
310-
* Gets the component responsible for rendering the entity.
311-
* @readonly
312-
* @returns {Function} The render function for the entity component.
313-
*/
314-
get component() { return render_entity_component; }
315309

316310
get is_unembedded() {
317311
if(!this.vec) return true;
318312
if(!this.embed_hash || this.embed_hash !== this.read_hash) return true;
319313
return false;
320314
}
321315

322-
// COMPONENTS 2024-11-27
323-
get connections_component() {
324-
if(!this._connections_component) this._connections_component = this.components?.connections?.bind(this.smart_view);
325-
return this._connections_component;
326-
}
327-
async render_connections(container, opts={}) {
328-
if(container) this.env.smart_view.safe_inner_html(container, 'Loading connections...');
329-
const frag = await this.env.render_component('connections', this, opts);
330-
if(container) {
331-
this.env.smart_view.empty(container);
332-
container.appendChild(frag);
333-
}
334-
return frag;
335-
}
336316
}
337317

338318
import { find_connections } from "./actions/find_connections.js";

0 commit comments

Comments
 (0)