tweb-i2p/src/helpers/restrictions.ts
2022-02-12 02:17:35 +04:00

26 lines
573 B
TypeScript

import { RestrictionReason } from "../layer";
const platforms = new Set([
'all',
'web',
'webk'
]);
const ignore = new Set();
export function getRestrictionReason(reasons: RestrictionReason[]) {
// return reasons[0];
return reasons.find(reason => platforms.has(reason.platform) && !ignore.has(reason.reason));
}
export function isRestricted(reasons: RestrictionReason[]) {
return !!getRestrictionReason(reasons);
}
export function ignoreRestrictionReasons(reasons: string[]) {
ignore.clear();
reasons.forEach(reason => {
ignore.add(reason);
});
}