From 0756439c4a8dc8761b67091d583e580dbbf801e3 Mon Sep 17 00:00:00 2001 From: marcustyphoon Date: Sun, 7 Jul 2024 05:08:09 -0700 Subject: [PATCH] Refactor: Use Array.prototype.at (#1535) --- src/features/quick_reblog.js | 2 +- src/features/trim_reblogs.js | 2 +- src/utils/sidebar.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/features/quick_reblog.js b/src/features/quick_reblog.js index e52fc9082..3d8077914 100644 --- a/src/features/quick_reblog.js +++ b/src/features/quick_reblog.js @@ -75,7 +75,7 @@ ${postSelector} footer button[aria-label="${translate('Reblog')}"]:not([role]) const renderBlogAvatar = async () => { const { value: selectedUuid } = blogSelector; const { avatar } = userBlogs.find(({ uuid }) => uuid === selectedUuid); - const { url } = avatar[avatar.length - 1]; + const { url } = avatar.at(-1); blogAvatar.style.backgroundImage = `url(${url})`; }; blogSelector.addEventListener('change', renderBlogAvatar); diff --git a/src/features/trim_reblogs.js b/src/features/trim_reblogs.js index b1cbb2936..8d6509c05 100644 --- a/src/features/trim_reblogs.js +++ b/src/features/trim_reblogs.js @@ -73,7 +73,7 @@ const onButtonClicked = async function ({ currentTarget: controlButton }) { const createPreviewItem = ({ blog, brokenBlog, content, disableCheckbox = false }) => { const { avatar, name } = blog ?? brokenBlog ?? blogPlaceholder; - const { url: src } = avatar[avatar.length - 1]; + const { url: src } = avatar.at(-1); const textContent = content.map(({ text }) => text).find(Boolean) ?? '\u22EF'; const checkbox = dom('input', { type: 'checkbox' }); diff --git a/src/utils/sidebar.js b/src/utils/sidebar.js index 290c874e6..6ada9a1e7 100644 --- a/src/utils/sidebar.js +++ b/src/utils/sidebar.js @@ -116,7 +116,7 @@ const addSidebarToPage = (siblingCandidates) => { const addSidebarToDrawer = (navItems) => { updateSidebarItemVisibility(); - const lastNavItem = navItems[navItems.length - 1]; + const lastNavItem = navItems.at(-1); lastNavItem?.after(sidebarItems); };