Skip to content

Commit

Permalink
Merge pull request #203 from k2maan/preorder/#200
Browse files Browse the repository at this point in the history
Fixed: inconsistent shopfiy shop ordering through manually sorting the shopListings on the UI (#200)
  • Loading branch information
ravilodhi authored Sep 6, 2023
2 parents 3a157b0 + bdca711 commit 9e9762b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/views/catalog-product-details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@
<ion-item v-if="!Object.keys(shopListings).length">
{{ $t('No shop listings found') }}
</ion-item>
<ion-item v-else v-for="(listData, index) in shopListings" :key="index">
<ion-item v-else v-for="(listData, index) in getSortedShopListings(shopListings)" :key="index">
<ion-label class="ion-text-wrap">
<h5>{{ listData.name }}</h5>
<!-- internationalized while preparation -->
Expand Down Expand Up @@ -992,7 +992,7 @@ export default defineComponent({
return shopifyConfigsAndProductIds
}, {})

await Promise.allSettled(Object.keys(configs).sort().map(async (shopId: any) => {
await Promise.allSettled(Object.keys(configs).map(async (shopId: any) => {
const configAndIdData = shopifyConfigsAndProductIds[shopId];
let listData = {
...configs[shopId], // adding shopify shop information to be available for showing name
Expand Down Expand Up @@ -1088,6 +1088,11 @@ export default defineComponent({
}).then(() => {
showToast(this.$t("Copied to clipboard"));
})
},
getSortedShopListings(shopListings: any) {
// using return based sorting instead of localeCompare
// as localeCompare is slower
return shopListings.sort((a: any, b: any) => a.name < b.name ? -1 : 1)
}
},
setup() {
Expand Down

0 comments on commit 9e9762b

Please sign in to comment.