Skip to content

Commit

Permalink
Merge pull request #610 from adobe/issue-608
Browse files Browse the repository at this point in the history
feat: new event "previewed"
  • Loading branch information
rofe committed Nov 20, 2023
2 parents 64d27cf + 4489ff2 commit 9de9431
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/extension/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,19 @@ import sampleRUM from './rum.js';
* @description This event is fired when the environment has been switched
*/

/**
* @event Sidekick#previewed
* @arg {CustomEvent} e The event
* @prop {string} e.detail.data The previewed path
* @description This event is fired when content has been previewed.
*/

/**
* @event Sidekick#updated
* @arg {CustomEvent} e The event
* @prop {string} e.detail.data The updated path
* @description This event is fired when content or code has been updated.
* This event is deprecated for content, use {@link Sidekick#previewed} instead.
*/

/**
Expand Down Expand Up @@ -1015,6 +1023,7 @@ import sampleRUM from './rum.js';
'shown',
'hidden',
'updated',
'previewed',
'published',
'unpublished',
'deleted',
Expand Down Expand Up @@ -3837,6 +3846,7 @@ import sampleRUM from './rum.js';
/**
* Updates the preview or code of the current resource.
* @fires Sidekick#updated
* @fires Sidekick#previewed
* @returns {Response} The response object
*/
async update(path) {
Expand All @@ -3859,7 +3869,10 @@ import sampleRUM from './rum.js';
await fetch(`https://${config.innerHost}${path}`, { cache: 'reload', mode: 'no-cors' });
}
respPath = (await resp.json()).webPath;
fireEvent(this, 'updated', respPath);
fireEvent(this, 'updated', respPath); // @deprecated for content, use for code only
if (this.isContent()) {
fireEvent(this, 'previewed', respPath);
}
}
} catch (e) {
console.error('failed to update', path, e);
Expand Down

0 comments on commit 9de9431

Please sign in to comment.