mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[PR #4485] [CLOSED] fix: preserve request order when importing and exporting collections #4829
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#4829
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/4485
Author: @sz-2302
Created: 10/27/2024
Status: ❌ Closed
Base:
next← Head:fix/import-order📝 Commits (6)
8d11c04Ensure correct order and prevent duplicate requests during import of user collections4063711Implement consistent request ordering and remove duplicates during importa9b9e66Adjust schema to improve collection and request indexingb07829dEnsure request order consistency during collection export11c34dcCorrect request ordering and indexing during team collection export1cf3b9cFix inconsistencies📊 Changes
4 files changed (+517 additions, -247 deletions)
View changed files
📝
packages/hoppscotch-backend/prisma/schema.prisma(+2 -1)📝
packages/hoppscotch-backend/src/user-collection/user-collection.service.ts(+137 -3)📝
packages/hoppscotch-selfhost-web/src/platform/collections/collections.platform.ts(+249 -221)📝
packages/hoppscotch-selfhost-web/src/platform/collections/collections.sync.ts(+129 -22)📄 Description
This pull request addresses the issue (potentially 4407 and 4375) where importing collections while logged in to the self-hosted web results in duplicate and out-of-order requests within collections. The problem was due to asynchronous operations not being properly awaited and
orderIndexvalues not being preserved or utilised correctly during the import and synchronisation process.What's changed
Fixed asynchronous handling in
collections.sync.tsrecursivelySyncCollectionsfunction to properly handle asynchronous operations usingasync/await.forEachloops withfor...ofloops to ensure that each asynchronous operation completes before proceeding.Updated IDs in the store after backend creation
Preserved and utilised
orderIndexinexportedCollectionToHoppCollectionorderIndexfrom the imported data when parsing requests.requestsarray based onorderIndexafter mapping.Adjusted subscription handlers in
collections.platform.tssetupUserRequestCreatedSubscriptionto check for existing requests using updated IDs.orderIndex.Backend adjustments in
user-collection.service.tsorderIndexin the data sent through subscription events.File to import:
request_import_test.json
Before fix:

After fix:

Notes to reviewers
Testing Instructions:
Potential Impact:
Code Review Suggestions:
recursivelySyncCollectionsto ensure that there are no unintended side effects.orderIndexin both the frontend and backend to confirm that it is consistently utilised.Future Improvements:
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.