mirror of
https://github.com/element-hq/element-web
synced 2024-11-29 04:48:50 +03:00
Clarify that vectorState is a VectorState
This commit is contained in:
parent
5b9fca3b91
commit
0e749e32ac
2 changed files with 20 additions and 20 deletions
|
@ -14,11 +14,11 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { PushRuleVectorState, State } from "./PushRuleVectorState";
|
||||
import { PushRuleVectorState, VectorState } from "./PushRuleVectorState";
|
||||
import { IAnnotatedPushRule, IPushRules, PushRuleKind } from "matrix-js-sdk/src/@types/PushRules";
|
||||
|
||||
export interface IContentRules {
|
||||
vectorState: State;
|
||||
vectorState: VectorState;
|
||||
rules: IAnnotatedPushRule[];
|
||||
externalRules: IAnnotatedPushRule[];
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ export class ContentRules {
|
|||
|
||||
if (contentRules.loud.length) {
|
||||
return {
|
||||
vectorState: State.Loud,
|
||||
vectorState: VectorState.Loud,
|
||||
rules: contentRules.loud,
|
||||
externalRules: [
|
||||
...contentRules.loud_but_disabled,
|
||||
|
@ -69,25 +69,25 @@ export class ContentRules {
|
|||
};
|
||||
} else if (contentRules.loud_but_disabled.length) {
|
||||
return {
|
||||
vectorState: State.Off,
|
||||
vectorState: VectorState.Off,
|
||||
rules: contentRules.loud_but_disabled,
|
||||
externalRules: [...contentRules.on, ...contentRules.on_but_disabled, ...contentRules.other],
|
||||
};
|
||||
} else if (contentRules.on.length) {
|
||||
return {
|
||||
vectorState: State.On,
|
||||
vectorState: VectorState.On,
|
||||
rules: contentRules.on,
|
||||
externalRules: [...contentRules.on_but_disabled, ...contentRules.other],
|
||||
};
|
||||
} else if (contentRules.on_but_disabled.length) {
|
||||
return {
|
||||
vectorState: State.Off,
|
||||
vectorState: VectorState.Off,
|
||||
rules: contentRules.on_but_disabled,
|
||||
externalRules: contentRules.other,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
vectorState: State.On,
|
||||
vectorState: VectorState.On,
|
||||
rules: [],
|
||||
externalRules: contentRules.other,
|
||||
};
|
||||
|
@ -116,14 +116,14 @@ export class ContentRules {
|
|||
r.kind = kind;
|
||||
|
||||
switch (PushRuleVectorState.contentRuleVectorStateKind(r)) {
|
||||
case State.On:
|
||||
case VectorState.On:
|
||||
if (r.enabled) {
|
||||
contentRules.on.push(r);
|
||||
} else {
|
||||
contentRules.on_but_disabled.push(r);
|
||||
}
|
||||
break;
|
||||
case State.Loud:
|
||||
case VectorState.Loud:
|
||||
if (r.enabled) {
|
||||
contentRules.loud.push(r);
|
||||
} else {
|
||||
|
|
|
@ -18,7 +18,7 @@ import { StandardActions } from "./StandardActions";
|
|||
import { NotificationUtils } from "./NotificationUtils";
|
||||
import { IPushRule } from "matrix-js-sdk/src/@types/PushRules";
|
||||
|
||||
export enum State {
|
||||
export enum VectorState {
|
||||
/** The push rule is disabled */
|
||||
Off = "off",
|
||||
/** The user will receive push notification for this rule */
|
||||
|
@ -30,26 +30,26 @@ export enum State {
|
|||
|
||||
export class PushRuleVectorState {
|
||||
// Backwards compatibility (things should probably be using the enum above instead)
|
||||
static OFF = State.Off;
|
||||
static ON = State.On;
|
||||
static LOUD = State.Loud;
|
||||
static OFF = VectorState.Off;
|
||||
static ON = VectorState.On;
|
||||
static LOUD = VectorState.Loud;
|
||||
|
||||
/**
|
||||
* Enum for state of a push rule as defined by the Vector UI.
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
*/
|
||||
static states = State;
|
||||
static states = VectorState;
|
||||
|
||||
/**
|
||||
* Convert a PushRuleVectorState to a list of actions
|
||||
*
|
||||
* @return [object] list of push-rule actions
|
||||
*/
|
||||
static actionsFor(pushRuleVectorState: State) {
|
||||
if (pushRuleVectorState === State.On) {
|
||||
static actionsFor(pushRuleVectorState: VectorState) {
|
||||
if (pushRuleVectorState === VectorState.On) {
|
||||
return StandardActions.ACTION_NOTIFY;
|
||||
} else if (pushRuleVectorState === State.Loud) {
|
||||
} else if (pushRuleVectorState === VectorState.Loud) {
|
||||
return StandardActions.ACTION_HIGHLIGHT_DEFAULT_SOUND;
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ export class PushRuleVectorState {
|
|||
* category or in PushRuleVectorState.LOUD, regardless of its enabled
|
||||
* state. Returns null if it does not match these categories.
|
||||
*/
|
||||
static contentRuleVectorStateKind(rule: IPushRule): State {
|
||||
static contentRuleVectorStateKind(rule: IPushRule): VectorState {
|
||||
const decoded = NotificationUtils.decodeActions(rule.actions);
|
||||
|
||||
if (!decoded) {
|
||||
|
@ -79,10 +79,10 @@ export class PushRuleVectorState {
|
|||
let stateKind = null;
|
||||
switch (tweaks) {
|
||||
case 0:
|
||||
stateKind = State.On;
|
||||
stateKind = VectorState.On;
|
||||
break;
|
||||
case 2:
|
||||
stateKind = State.Loud;
|
||||
stateKind = VectorState.Loud;
|
||||
break;
|
||||
}
|
||||
return stateKind;
|
||||
|
|
Loading…
Reference in a new issue