Skip to content

Commit

Permalink
Fixed issue with dedicated channels strategy
Browse files Browse the repository at this point in the history
The dedicated channels strategy would throw in `extractIdsFromSelector`
when the selector did not match certain criteria.
The code now checks these before selecting the strategy.
  • Loading branch information
jdgjsag67251 committed Sep 30, 2024
1 parent 58ba426 commit 2f20541
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/processors/getStrategy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
import { Strategy } from '../constants';

function canUseDedicatedChannels(selector) {
if (!selector || !selector._id) {
return false;
}

if (typeof selector._id === 'string') {
return true;
}

if (typeof selector._id === 'object' && '$in' in selector._id) {
return true;
}

return false;
}

/**
* @param selector
* @param options
Expand All @@ -15,7 +31,7 @@ export default function getStrategy(selector = {}, options = {}) {
return Strategy.LIMIT_SORT;
}

if (selector && selector._id) {
if (canUseDedicatedChannels(selector)) {
return Strategy.DEDICATED_CHANNELS;
}

Expand Down

0 comments on commit 2f20541

Please sign in to comment.