filter: Copy is_web_public_compatible from server to frontend.

This will be used to check if the narrow being requested by
spectator requires authentication without requesting the server.
Having this check locally, makes this process look snappy to
the user and doesn't result in 404s in the browser log.
This commit is contained in:
Aman Agrawal
2020-10-05 14:20:51 +05:30
committed by Tim Abbott
parent 3ed833a7e4
commit 3e7538b974
4 changed files with 52 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
import Handlebars from "handlebars/runtime";
import _ from "lodash";
import * as hash_util from "./hash_util";
import {$t} from "./i18n";
import * as message_edit from "./message_edit";
import * as message_parser from "./message_parser";
@@ -1005,4 +1006,16 @@ export class Filter {
static describe(operators) {
return Handlebars.Utils.escapeExpression(Filter.describe_unescaped(operators));
}
static is_web_public_compatible(ops) {
for (const op of ops) {
if (op.operand === undefined) {
return false;
}
if (!hash_util.allowed_web_public_narrows.includes(op.operator)) {
return false;
}
}
return true;
}
}