Skip to content

Commit 069f5c5

Browse files
authored
Merge pull request #274 from DestinyItemManager/tag-delete
Fix tag deleting
2 parents 2e2132d + bc6c068 commit 069f5c5

3 files changed

Lines changed: 24 additions & 14 deletions

File tree

api/routes/update.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,6 @@ function validateUpdates(
185185
return results;
186186
}
187187

188-
// TODO: For ease of porting, I made each update a separate transaction. But it
189-
// would be more efficient to batch them all into one transaction. That said,
190-
// aside from bulk-tagging, it's most likely that only one update will be sent
191-
// at a time.
192188
async function statelyUpdate(
193189
updates: ProfileUpdate[],
194190
bungieMembershipId: number,

api/stately/item-annotations-queries.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,24 @@ it('can update tags clearing value', async () => {
7979
});
8080
});
8181

82+
it('can create tags while passing null notes', async () => {
83+
await client.transaction(async (txn) => {
84+
await updateItemAnnotation(txn, platformMembershipId, 2, [
85+
{
86+
id: '123456',
87+
tag: 'favorite',
88+
notes: null,
89+
},
90+
]);
91+
});
92+
93+
const annotations = (await getItemAnnotationsForProfile(platformMembershipId, 2)).tags;
94+
expect(annotations[0]).toEqual({
95+
id: '123456',
96+
tag: 'favorite',
97+
});
98+
});
99+
82100
it('can delete tags', async () => {
83101
await client.transaction(async (txn) => {
84102
await updateItemAnnotation(txn, platformMembershipId, 2, [

api/stately/item-annotations-queries.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,6 @@ export async function updateItemAnnotation(
105105
destinyVersion,
106106
});
107107

108-
if (
109-
(tagValue === 'clear' && !ia.notes) ||
110-
(notesValue === 'clear' && !ia.tag) ||
111-
(tagValue === 'clear' && notesValue === 'clear')
112-
) {
113-
itemsToDelete.push(keyFor(platformMembershipId, destinyVersion, itemAnnotation.id));
114-
continue;
115-
}
116-
117108
if (tagValue === 'clear') {
118109
ia.tag = StatelyTagValue.TagValue_UNSPECIFIED;
119110
} else if (tagValue !== null) {
@@ -130,7 +121,12 @@ export async function updateItemAnnotation(
130121
ia.craftedDate = BigInt(itemAnnotation.craftedDate * 1000);
131122
}
132123

133-
itemsToPut.push(ia);
124+
// If we're updating them both to nothing, delete the annotation
125+
if (!ia.notes && !ia.tag) {
126+
itemsToDelete.push(keyFor(platformMembershipId, destinyVersion, itemAnnotation.id));
127+
} else {
128+
itemsToPut.push(ia);
129+
}
134130
}
135131

136132
if (itemsToDelete.length) {

0 commit comments

Comments
 (0)