message: Handle applied plugs when creating a loadout from equipped.
diff: @@ -4,6 +4,7 @@ import { getCurrentStore } from 'app/inventory/stores-helpers';
  import { itemCanBeInLoadout } from 'app/utils/item-utils';
  import { infoLog } from 'app/utils/log';
  import { DestinyClass } from 'bungie-api-ts/destiny2';
  +import { BucketHashes } from 'data/d2/generated-enums';
  import _ from 'lodash';
  import React, { useMemo } from 'react';
  import type {
  @@ -98,7 +99,7 @@ export default function LoadoutDrawerContents(
  function doFillLoadoutFromEquipped(e: React.MouseEvent) {
  e.preventDefault();
  - fillLoadoutFromEquipped(loadout, itemsByBucket, stores, add);
  + fillLoadoutFromEquipped(loadout, itemsByBucket, stores, add, onApplySocketOverrides);
  }
  function doFillLoadOutFromUnequipped(e: React.MouseEvent) {
  e.preventDefault();
  @@ -274,11 +275,32 @@ async function pickLoadoutSubclass(
  } catch (e) {}
  }
  +function createSocketOverridesFromEquipped(
  + item: DimItem,
  + onApplySocketOverrides: (item: DimItem, socketOverrides: SocketOverrides) => void
  +) {
  + const socketOverrides: SocketOverrides = {};
  + for (const socket of item.sockets?.allSockets || []) {
  + // If the socket is plugged and we plug isn't the initial plug we apply the overrides
  + // to the loadout.
  + if (
  + socket.plugged &&
  + socket.plugged.plugDef.hash !== socket.socketDefinition.singleInitialItemHash
  + ) {
  + socketOverrides[socket.socketIndex] = socket.plugged.plugDef.hash;
  + }
  + }
  + if (Object.keys(socketOverrides).length) {
  + onApplySocketOverrides(item, socketOverrides);
  + }
  +}
  +
  function fillLoadoutFromEquipped(
  loadout: Loadout,
  itemsByBucket: { [bucketId: string]: DimItem[] },
  stores: DimStore[],
  - add: (item: DimItem, e?: MouseEvent, equip?: boolean) => void
  + add: (item: DimItem, e?: MouseEvent, equip?: boolean) => void,
  + onApplySocketOverrides: (item: DimItem, socketOverrides: SocketOverrides) => void
  ) {
  if (!loadout) {
  return;
  @@ -300,6 +322,9 @@ function fillLoadoutFromEquipped(
  !itemsByBucket[item.bucket.hash].some((i) => i.equipped)
  ) {
  add(item, undefined, true);
  + if (item.bucket.hash === BucketHashes.Subclass) {
  + createSocketOverridesFromEquipped(item, onApplySocketOverrides);
  + }
  } else {
  infoLog('loadout', 'Skipping', item, { itemsByBucket, bucketId: item.bucket.hash });
  }
  