Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: order of collection items is determined by backend. #256

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@logion/client",
"version": "0.43.1-1",
"version": "0.43.1-2",
"description": "logion SDK for client applications",
"main": "dist/index.js",
"packageManager": "[email protected]",
Expand Down
18 changes: 12 additions & 6 deletions packages/client/src/LocClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,15 +612,21 @@ export abstract class LocClient {
const { locId } = parameters;
const onchainItems = await this.nodeApi.queries.getCollectionItems(locId);

const onchainItemsMap: Record<string, CollectionItem> = {};
for(const item of onchainItems) {
onchainItemsMap[item.id.toHex()] = item;
}

try {
const result: UploadableCollectionItem[] = [];
const offchainItems = await this.getOffchainItems({ locId });

const offchainItemsMap: Record<string, OffchainCollectionItem> = {};
for(const item of offchainItems) {
offchainItemsMap[item.itemId] = item;
for(const offchainItem of offchainItems) {
const onchainItem = onchainItemsMap[offchainItem.itemId];
if (onchainItem) {
result.push(this.mergeItems(onchainItem, offchainItem))
}
}

return onchainItems.map(item => this.mergeItems(item, offchainItemsMap[item.id.toHex()]));
return result;
} catch(e) {
throw newBackendError(e);
}
Expand Down
Loading