@lvce-editor/activity-bar-worker 7.6.0 → 7.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1774,10 +1774,12 @@ const show2 = async (uid, menuId, x, y, args) => {
1774
1774
  const ACCOUNT_MENU_ID = 32_122;
1775
1775
  const handleClickAccount = async (state, eventX, eventY, viewletId) => {
1776
1776
  const {
1777
+ sideBarLocation,
1777
1778
  uid
1778
1779
  } = state;
1779
1780
  await show2(uid, ACCOUNT_MENU_ID, eventX, eventY, {
1780
- menuId: ACCOUNT_MENU_ID
1781
+ menuId: ACCOUNT_MENU_ID,
1782
+ openSubMenuToLeft: sideBarLocation === Right
1781
1783
  });
1782
1784
  return state;
1783
1785
  };
@@ -1823,16 +1825,38 @@ const updateItemsWithBadgeCount = async items => {
1823
1825
  }
1824
1826
  };
1825
1827
 
1826
- const handleBadgeCountChange = async state => {
1827
- const {
1828
- filteredItems
1829
- } = state;
1830
- const newItems = await updateItemsWithBadgeCount(filteredItems);
1828
+ const updateStateItems = (state, activityBarItems) => {
1829
+ const itemById = new Map(activityBarItems.map(item => [item.id, item]));
1830
+ const filteredItems = state.filteredItems.map(item => itemById.get(item.id) || item);
1831
1831
  return {
1832
1832
  ...state,
1833
- filteredItems: newItems
1833
+ activityBarItems,
1834
+ filteredItems
1834
1835
  };
1835
1836
  };
1837
+ const applyBadgeCountChanges = (state, badgeCounts) => {
1838
+ const activityBarItems = state.activityBarItems.map(item => {
1839
+ if (!Object.hasOwn(badgeCounts, item.id)) {
1840
+ return item;
1841
+ }
1842
+ const badgeCount = badgeCounts[item.id];
1843
+ return {
1844
+ ...item,
1845
+ badgeText: badgeCount ? String(badgeCount) : ''
1846
+ };
1847
+ });
1848
+ return updateStateItems(state, activityBarItems);
1849
+ };
1850
+ const handleBadgeCountChange = async (state, badgeCounts) => {
1851
+ if (badgeCounts) {
1852
+ return applyBadgeCountChanges(state, badgeCounts);
1853
+ }
1854
+ const newActivityBarItems = await updateItemsWithBadgeCount(state.activityBarItems);
1855
+ if (newActivityBarItems === state.activityBarItems) {
1856
+ return state;
1857
+ }
1858
+ return updateStateItems(state, newActivityBarItems);
1859
+ };
1836
1860
 
1837
1861
  const handleBlur = state => {
1838
1862
  return {
@@ -2205,12 +2229,12 @@ const handleExtensionsChanged = async state => {
2205
2229
  const contributedViews = await getContributedViews(state.platform);
2206
2230
  const items = getActivityBarItems(state, contributedViews);
2207
2231
  const itemsWithSelected = markSelected(items, selectedIndex);
2208
- const filteredItems = getFilteredActivityBarItems(itemsWithSelected, height, itemHeight);
2209
- const newItems = await updateItemsWithBadgeCount(filteredItems);
2232
+ const activityBarItems = await updateItemsWithBadgeCount(itemsWithSelected);
2233
+ const filteredItems = getFilteredActivityBarItems(activityBarItems, height, itemHeight);
2210
2234
  return {
2211
2235
  ...state,
2212
- activityBarItems: itemsWithSelected,
2213
- filteredItems: newItems
2236
+ activityBarItems,
2237
+ filteredItems
2214
2238
  };
2215
2239
  };
2216
2240
 
@@ -2273,12 +2297,12 @@ const handleSettingsChanged = async state => {
2273
2297
  };
2274
2298
  const items = getActivityBarItems(newState, contributedViews);
2275
2299
  const itemsWithSelected = markSelected(items, selectedIndex);
2276
- const filteredItems = getFilteredActivityBarItems(itemsWithSelected, height, itemHeight);
2277
- const newItems = await updateItemsWithBadgeCount(filteredItems);
2300
+ const activityBarItems = await updateItemsWithBadgeCount(itemsWithSelected);
2301
+ const filteredItems = getFilteredActivityBarItems(activityBarItems, height, itemHeight);
2278
2302
  return {
2279
2303
  ...newState,
2280
- activityBarItems: itemsWithSelected,
2281
- filteredItems: newItems,
2304
+ activityBarItems,
2305
+ filteredItems,
2282
2306
  sideBarLocation: sidebarLocation
2283
2307
  };
2284
2308
  };
@@ -2468,13 +2492,13 @@ const loadContent = async state => {
2468
2492
  const index = items.findIndex(item => item.id === activeView);
2469
2493
  const selectedIndex = sideBarVisible ? index : -1;
2470
2494
  const itemsWithSelected = markSelected(items, selectedIndex);
2471
- const filteredItems = getFilteredActivityBarItems(itemsWithSelected, height, itemHeight);
2472
- const newItems = await updateItemsWithBadgeCount(filteredItems);
2495
+ const activityBarItems = await updateItemsWithBadgeCount(itemsWithSelected);
2496
+ const filteredItems = getFilteredActivityBarItems(activityBarItems, height, itemHeight);
2473
2497
  return {
2474
2498
  ...newState,
2475
- activityBarItems: itemsWithSelected,
2499
+ activityBarItems,
2476
2500
  currentViewletId: Explorer,
2477
- filteredItems: newItems,
2501
+ filteredItems,
2478
2502
  initial: false,
2479
2503
  selectedIndex,
2480
2504
  sideBarLocation: sidebarLocation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/activity-bar-worker",
3
- "version": "7.6.0",
3
+ "version": "7.8.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",