Skip to content

Commit

Permalink
Refactor: Use Array.prototype.at (AprilSylph#1535)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcustyphoon authored Jul 7, 2024
1 parent cdeb99b commit 0756439
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/features/quick_reblog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/features/trim_reblogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down
2 changes: 1 addition & 1 deletion src/utils/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down

0 comments on commit 0756439

Please sign in to comment.