Skip to content

Commit

Permalink
cleanup deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Joseph Petro committed Dec 28, 2024
1 parent 87d72a5 commit b7c6381
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 56 deletions.
30 changes: 0 additions & 30 deletions smart-blocks/smart_block.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,25 +376,6 @@ export class SmartBlock extends SmartEntity {
*/
get source() { return this.source_collection.get(this.source_key); }

/**
* Retrieves the source adapter based on the file type.
* @readonly
* @returns {Object} The source adapter instance.
*/
get source_adapter() {
if(this._source_adapter) return this._source_adapter;
if(this.source_adapters[this.file_type]) this._source_adapter = new this.source_adapters[this.file_type](this);
else this._source_adapter = new this.source_adapters["default"](this);
return this._source_adapter;
}

/**
* Retrieves the source adapters from the SmartSource.
* @readonly
* @returns {Object} An object mapping file extensions to adapter constructors.
*/
get source_adapters() { return this.source.source_adapters; }

/**
* Retrieves the SmartSources collection instance.
* @readonly
Expand All @@ -412,20 +393,9 @@ export class SmartBlock extends SmartEntity {
get is_canvas() { return this.source.is_canvas; }
get is_excalidraw() { return this.source.is_excalidraw; }
get mtime() { return this.source.mtime; }
get smart_change_adapter() { return this.source.smart_change_adapter; }

// COMPONENTS

/**
* Retrieves the component responsible for rendering the SmartBlock.
* @readonly
* @returns {Function} The render function for the source component.
*/
// get component() { return render_source_component; }


// DEPRECATED

/**
* @deprecated Use `source` instead.
* @readonly
Expand Down
53 changes: 27 additions & 26 deletions smart-sources/smart_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,6 @@ export class SmartSource extends SmartEntity {
}
}

/**
* @async
* @deprecated Use `update` instead.
* @param {string} content - The content to update.
* @returns {Promise<void>}
*/
async _update(content) {
await this.source_adapter.update(content);
}

/**
* Reads the entire content of the source file.
Expand All @@ -255,14 +246,6 @@ export class SmartSource extends SmartEntity {
}
}

/**
* @async
* @deprecated Use `read` instead.
* @returns {Promise<string>} A promise that resolves with the content of the file.
*/
async _read() {
return await this.source_adapter._read();
}

/**
* Removes the source file from the file system and deletes the entity.
Expand All @@ -281,12 +264,6 @@ export class SmartSource extends SmartEntity {
}
}

/**
* @async
* @deprecated Use `remove` instead.
* @returns {Promise<void>} A promise that resolves when the entity is destroyed.
*/
async destroy() { await this.remove(); }

/**
* Moves the current source to a new location.
Expand Down Expand Up @@ -522,7 +499,6 @@ export class SmartSource extends SmartEntity {
get should_embed() {
return !this.vec || !this.embed_hash || (this.embed_hash !== this.read_hash);
}
get smart_change_adapter() { return this.env.settings.is_obsidian_vault ? "obsidian_markdown" : "markdown"; }
get source_adapters() { return this.collection.source_adapters; }
get source_adapter() {
if(this._source_adapter) return this._source_adapter;
Expand Down Expand Up @@ -573,7 +549,33 @@ export class SmartSource extends SmartEntity {
}

// DEPRECATED methods

/**
* @async
* @deprecated Use `read` instead.
* @returns {Promise<string>} A promise that resolves with the content of the file.
*/
async _read() {
return await this.source_adapter._read();
}
/**
* @async
* @deprecated Use `remove` instead.
* @returns {Promise<void>} A promise that resolves when the entity is destroyed.
*/
async destroy() { await this.remove(); }
/**
* @async
* @deprecated Use `update` instead.
* @param {string} content - The content to update.
* @returns {Promise<void>}
*/
async _update(content) {
await this.source_adapter.update(content);
}
/**
* @deprecated in favor of new smart_changes collection
*/
get smart_change_adapter() { return this.env.settings.is_obsidian_vault ? "obsidian_markdown" : "markdown"; }
/**
* @deprecated Use `source` instead.
* @readonly
Expand All @@ -583,5 +585,4 @@ export class SmartSource extends SmartEntity {
return this.fs.files[this.path];
}


}

0 comments on commit b7c6381

Please sign in to comment.