소스 검색

tweak: don't break if `contact_us` is not found

jelveh 6 달 전
부모
커밋
dc478382fb
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      src/gui/src/extensions/modify-user-options-menu.js

+ 7 - 1
src/gui/src/extensions/modify-user-options-menu.js

@@ -19,7 +19,13 @@ $(window).on('ctxmenu-will-open', (event) => {
         const items = event.detail.options.items;
         const insertBeforeIndex = items.findIndex(item => item.id === 'contact_us');
         
-        // Insert all new items before 'contact_us'
+        // 'contact_us' not found, append new items at the end
+        if (insertBeforeIndex === -1) {
+            event.detail.options.items = [...items, ...newMenuItems];
+            return;
+        }
+
+        // 'contact_us' found, insert new items before it
         const firstHalf = items.slice(0, insertBeforeIndex);
         const secondHalf = items.slice(insertBeforeIndex);
         event.detail.options.items = [...firstHalf, ...newMenuItems, ...secondHalf];