-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
move [static-badge] to own service & add test #1802
Conversation
Generated by 🚫 dangerJS |
I can't set it so the label/message accepts being empty, return {
label: label || '',
message: message || '',
color
}; static get defaultBadgeData() {
return { label: '', message: '' };
} And those do not seem to help. Any ideas? |
Phew, thanks for taking this on! Re the custom headers and the caching: Because the static badge is one-of-a-kind, I think we should deal with the differences in the static badge's service class rather than building a bunch of extra features into BaseService. So I'd suggest we give StaticBadge its own implementation of Line 206 in f5fe85c
This code translates from named params + query params to serviceData: Lines 209 to 214 in f5fe85c
Since you don't need Re the empty message, I'd suggest we replace this code: Lines 187 to 190 in f5fe85c
with a function like this: function coalesce(...candidates) {
return candidates.find(c => typeof c === 'string');
}
console.log(coalesce('', 'foo', ''));
console.log(coalesce('asdf', 'foo', ''));
console.log(coalesce(null, '', 'bar'));
console.log(coalesce(undefined, '', 'bar')); I'm pretty sure accepting an empty string anywhere along that chain will do the right thing. We aren't in the habit of returning an empty string as a kind of null. |
@RedSparr0w Would you like me to pick up the changes to |
If you could that would be great! 👍 |
Mind merging master into this branch when you have a moment? I wrote some steps here: #1866 (comment) |
Reopened as #2284! |
…2284) This picks up @RedSparr0w's work in #1802. 1. The handler for the static badge is moved into its own service with a synchronous handler. Avoiding an async call may make the static badges slightly faster, though it may be worth profiling this if it turns out we want asynchronous static badges in the future. If it doesn't make a performance difference we could make this handler `async` like the others. 2. Most of the custom static-badge logic is in a BaseStaticBadge base class. 3. Rewrite the static Gitter badge to use BaseStaticBadge. 4. A bit of minor cleanup in related functions.
Move the static badge to its own service module,
Add tests.
I'm unsure how to add the custom headers back such as these though: