Skip to content

Commit

Permalink
Merge pull request #10727 from DestinyItemManager/no-more-type
Browse files Browse the repository at this point in the history
Getrid of DimItem#type in favor of bucket hashes
  • Loading branch information
bhollis committed Sep 18, 2024
2 parents cacb326 + f491e1f commit ec76296
Show file tree
Hide file tree
Showing 33 changed files with 433 additions and 403 deletions.
4 changes: 1 addition & 3 deletions config/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@
"DevVersion": "Are you running a development version of DIM? You must register your chrome extension with Bungie.net.",
"Difficulties": "Bungie.net is currently experiencing difficulties.",
"ErrorTitle": "Bungie.net Error",
"ItemUniquenessExplanation": "You tried to move the '{{name}}' {{type}} to your {{character}} but that destination already has that item and is only allowed one.",
"ItemUniquenessExplanation_female": "You tried to move the '{{name}}' {{type}} to your {{character}} but that destination already has that item and is only allowed one.",
"ItemUniquenessExplanation_male": "You tried to move the '{{name}}' {{type}} to your {{character}} but that destination already has that item and is only allowed one.",
"ItemUniquenessExplanation": "A character can only have one of '{{name}}' on it.",
"Maintenance": "Bungie.net servers are down for maintenance.",
"MissingInventory": "Bungie.net did not return your inventory, possibly because your privacy settings prevent it. Try logging out and logging back in.",
"DestinyCannotPerformActionAtThisLocation": "You cannot equip items or change mods while in an activity. Try heading to orbit or a social area. This is a limitation of the Bungie.net API, not DIM.",
Expand Down
3 changes: 3 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Next

* Renamed `is:class` to `is:subclass`.
* Fixed D1 item category searches such as `is:primary` and `is:horn`. Now they're up to parity with the D2 categories.

## 8.37.0 <span class="changelog-date">(2024-09-15)</span>

## 8.36.1 <span class="changelog-date">(2024-09-12)</span>
Expand Down
6 changes: 1 addition & 5 deletions src/app/bungie-api/bungie-service-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { PlatformErrorCodes } from 'bungie-api-ts/destiny2';
import { HttpClient, HttpClientConfig } from 'bungie-api-ts/http';
import _ from 'lodash';
import { DimItem } from '../inventory/item-types';
import { DimStore } from '../inventory/store-types';
import { FatalTokenError, fetchWithBungieOAuth } from './authenticated-fetch';
import { API_KEY } from './bungie-api-utils';
import {
Expand Down Expand Up @@ -216,7 +215,7 @@ function handleErrors(error: unknown): never {
}

// Handle "DestinyUniquenessViolation" (1648)
export function handleUniquenessViolation(error: unknown, item: DimItem, store: DimStore): never {
export function handleUniquenessViolation(error: unknown, item: DimItem): never {
if (
error instanceof BungieError &&
error.code === PlatformErrorCodes.DestinyUniquenessViolation
Expand All @@ -225,9 +224,6 @@ export function handleUniquenessViolation(error: unknown, item: DimItem, store:
'BungieService.ItemUniquenessExplanation',
t('BungieService.ItemUniquenessExplanation', {
name: item.name,
type: item.type.toLowerCase(),
character: store.name,
context: store.genderName,
}),
).withError(error);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/bungie-api/destiny1-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export async function transfer(
}),
);
} catch (e) {
return handleUniquenessViolation(e, item, store);
return handleUniquenessViolation(e, item);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/bungie-api/destiny2-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export async function transfer(
try {
return await response;
} catch (e) {
return handleUniquenessViolation(e, item, store);
return handleUniquenessViolation(e, item);
}
}

Expand Down
45 changes: 0 additions & 45 deletions src/app/destiny1/d1-buckets.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,14 @@
import { D1BucketHashes } from 'app/search/d1-known-values';
import { filterMap } from 'app/utils/collections';
import { HashLookup, StringLookup } from 'app/utils/util-types';
import { BucketCategory } from 'bungie-api-ts/destiny2';
import { BucketHashes } from 'data/d2/generated-enums';
import type {
D1BucketCategory,
DimBucketType,
InventoryBucket,
InventoryBuckets,
} from '../inventory/inventory-buckets';
import { D1Categories } from './d1-bucket-categories';
import type { D1ManifestDefinitions } from './d1-definitions';

// A mapping from the bucket hash to DIM item types
const bucketToTypeRaw = {
[BucketHashes.ChestArmor]: 'Chest',
[BucketHashes.LegArmor]: 'Leg',
[BucketHashes.LostItems]: 'LostItems',
[BucketHashes.Ships]: 'Ship',
[D1BucketHashes.Missions]: 'Missions',
[D1BucketHashes.Artifact]: 'Artifact',
[BucketHashes.PowerWeapons]: 'Heavy',
[BucketHashes.SpecialOrders]: 'SpecialOrders',
[BucketHashes.Consumables]: 'Consumable',
[BucketHashes.KineticWeapons]: 'Primary',
[BucketHashes.ClassArmor]: 'ClassItem',
[D1BucketHashes.RecordBook]: 'RecordBook',
[D1BucketHashes.RecordBookLegacy]: 'RecordBookLegacy',
[D1BucketHashes.Quests]: 'Quests',
[BucketHashes.Vehicle]: 'Vehicle',
[D1BucketHashes.Bounties]: 'Bounties',
[BucketHashes.EnergyWeapons]: 'Special',
[D1BucketHashes.Shader]: 'Shader',
[BucketHashes.Modifications]: 'Ornaments',
[BucketHashes.Emotes_Equippable]: 'Emote',
[BucketHashes.Messages]: 'Messages',
[BucketHashes.Subclass]: 'Class',
[BucketHashes.Helmet]: 'Helmet',
[BucketHashes.Gauntlets]: 'Gauntlets',
[D1BucketHashes.Horn]: 'Horn',
[BucketHashes.Materials]: 'Material',
[BucketHashes.Ghost]: 'Ghost',
[BucketHashes.Emblems]: 'Emblem',
} as const;

export type D1BucketTypes = (typeof bucketToTypeRaw)[keyof typeof bucketToTypeRaw];

// A mapping from the bucket hash to DIM item types
const bucketToType: {
[hash: number]: DimBucketType | undefined;
} = bucketToTypeRaw;

export const vaultTypes: HashLookup<string> = {
3003523923: 'Armor',
4046403665: 'Weapons',
Expand Down Expand Up @@ -84,7 +42,6 @@ export function getBuckets(defs: D1ManifestDefinitions) {
category: BucketCategory.Item,
capacity: Number.MAX_SAFE_INTEGER,
sort: 'Unknown',
type: 'Unknown',
accountWide: false,
},
setHasUnknown() {
Expand All @@ -93,7 +50,6 @@ export function getBuckets(defs: D1ManifestDefinitions) {
};
for (const def of Object.values(defs.InventoryBucket.getAll())) {
if (def.enabled) {
const type = bucketToType[def.hash];
const sort = bucketHashToSort[def.hash] ?? vaultTypes[def.hash];
const bucket: InventoryBucket = {
description: def.bucketDescription,
Expand All @@ -104,7 +60,6 @@ export function getBuckets(defs: D1ManifestDefinitions) {
capacity: def.itemCount,
accountWide: false,
category: BucketCategory.Item,
type,
sort,
};
if (sort) {
Expand Down
Loading

0 comments on commit ec76296

Please sign in to comment.