From de16acf560e326671e7251ac2fb4c46e96fc01c2 Mon Sep 17 00:00:00 2001 From: Grigory Date: Sun, 5 Oct 2025 13:56:02 +0500 Subject: [PATCH] docs(development/api-wrapper/context-menu): improve example --- .../api-wrapper/classes/context-menu.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/docs/development/api-wrapper/classes/context-menu.md b/docs/development/api-wrapper/classes/context-menu.md index 807566f..04c7787 100644 --- a/docs/development/api-wrapper/classes/context-menu.md +++ b/docs/development/api-wrapper/classes/context-menu.md @@ -71,14 +71,10 @@ deregister(): void #### Example ```ts -// This function will determine if the selected item is a track -function ifItemIsTrack(uri) { - let uriObj = Spicetify.URI.fromString(uri[0]); - switch (uriObj.type) { - case Type.TRACK: - return true; - } - return false; +// This function will determine if the given item is a track +function isTrack(uri) { + const uriObject = Spicetify.URI.fromString(uri); + return uriObject.type === Spicetify.URI.Type.TRACK; } // Create a new menu item that only appears when a track is selected @@ -87,7 +83,7 @@ const menuItem = new Spicetify.ContextMenu.Item( () => { Spicetify.showNotification("My Menu Item clicked!"); }, - ifItemIsTrack, + (uris) => uris.every((uri) => isTrack(uri)), Spicetify.SVGIcons["play"], false, );