Use integers and not numbers in notification policy API counters (#29810)
This commit is contained in:
parent
d05f62391d
commit
b4d991adaa
|
@ -27,7 +27,7 @@ export const FilteredNotificationsBanner = () => {
|
||||||
};
|
};
|
||||||
}, [dispatch]);
|
}, [dispatch]);
|
||||||
|
|
||||||
if (policy === null || policy.getIn(['summary', 'pending_notifications_count']) * 1 === 0) {
|
if (policy === null || policy.getIn(['summary', 'pending_notifications_count']) === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,10 +70,10 @@ export function roundTo10(num: number): number {
|
||||||
return Math.round(num * 0.1) / 0.1;
|
return Math.round(num * 0.1) / 0.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toCappedNumber(num: string): string {
|
export function toCappedNumber(num: number, max = 99): string {
|
||||||
if (parseInt(num) > 99) {
|
if (num > max) {
|
||||||
return '99+';
|
return `${max}+`;
|
||||||
} else {
|
} else {
|
||||||
return num;
|
return num.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,8 @@ class REST::NotificationPolicySerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
def summary
|
def summary
|
||||||
{
|
{
|
||||||
pending_requests_count: object.pending_requests_count.to_s,
|
pending_requests_count: object.pending_requests_count.to_i,
|
||||||
pending_notifications_count: object.pending_notifications_count.to_s,
|
pending_notifications_count: object.pending_notifications_count.to_i,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,8 +32,8 @@ RSpec.describe 'Policies' do
|
||||||
filter_new_accounts: false,
|
filter_new_accounts: false,
|
||||||
filter_private_mentions: true,
|
filter_private_mentions: true,
|
||||||
summary: a_hash_including(
|
summary: a_hash_including(
|
||||||
pending_requests_count: '1',
|
pending_requests_count: 1,
|
||||||
pending_notifications_count: '0'
|
pending_notifications_count: 0
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -60,8 +60,8 @@ RSpec.describe 'Policies' do
|
||||||
filter_new_accounts: false,
|
filter_new_accounts: false,
|
||||||
filter_private_mentions: true,
|
filter_private_mentions: true,
|
||||||
summary: a_hash_including(
|
summary: a_hash_including(
|
||||||
pending_requests_count: '0',
|
pending_requests_count: 0,
|
||||||
pending_notifications_count: '0'
|
pending_notifications_count: 0
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue