findNewShaderIds method
Returns a new FindShaderIdsResponse
with a list of the new shader ids.
storeShaderIds
: The list of stored shader ids
Upon success a list of new shader ids is provided
In case of error a ResponseError
is set and no shader id list is
provided
Implementation
@override
Future<FindShaderIdsResponse> findNewShaderIds(
Set<String> storeShaderIds) async {
final newShaderIds = <String>[];
var addShaderIds = <String>{};
var from = 0;
final num = _options.shaderCount;
do {
final clientResponse = await _hybridClient.findShaderIds(
sort: Sort.newest, from: from, num: num);
if (!clientResponse.ok) {
return clientResponse;
}
final shaderIds = clientResponse.ids ?? [];
final clientShaderIds = shaderIds.toSet();
addShaderIds = clientShaderIds.difference(storeShaderIds);
shaderIds.retainWhere((shaderId) => addShaderIds.contains(shaderId));
newShaderIds.addAll(shaderIds);
from += num;
} while (addShaderIds.isNotEmpty && addShaderIds.length == num);
return FindShaderIdsResponse(ids: newShaderIds);
}