feat: add focus mode

This commit is contained in:
Paul Makles
2022-09-18 12:05:48 +01:00
parent eade491473
commit 0ca988427f
10 changed files with 40 additions and 12 deletions

View File

@@ -25,6 +25,8 @@ export function useStatusColour(user?: User) {
return user?.online && user?.status?.presence !== "Invisible"
? user?.status?.presence === "Idle"
? theme.getVariable("status-away")
: user?.status?.presence === "Focus"
? theme.getVariable("status-focus")
: user?.status?.presence === "Busy"
? theme.getVariable("status-busy")
: theme.getVariable("status-online")

View File

@@ -32,6 +32,10 @@ export default observer(({ user, tooltip }: Props) => {
return <Text id="app.status.idle" />;
}
if (user.status?.presence === "Focus") {
return <Text id="app.status.focus" />;
}
if (user.status?.presence === "Invisible") {
return <Text id="app.status.offline" />;
}

View File

@@ -31,6 +31,7 @@ export type Variables =
| "tooltip"
| "status-online"
| "status-away"
| "status-focus"
| "status-busy"
| "status-streaming"
| "status-invisible";
@@ -283,6 +284,7 @@ export const PRESETS: Record<string, Theme> = {
"tertiary-foreground": "#3a3a3a",
"status-online": "#3ABF7E",
"status-away": "#F39F00",
"status-focus": "#4799F0",
"status-busy": "#F84848",
"status-streaming": "#977EFF",
"status-invisible": "#A5A5A5",
@@ -310,6 +312,7 @@ export const PRESETS: Record<string, Theme> = {
"tertiary-foreground": "#848484",
"status-online": "#3ABF7E",
"status-away": "#F39F00",
"status-focus": "#4799F0",
"status-busy": "#F84848",
"status-streaming": "#977EFF",
"status-invisible": "#A5A5A5",
@@ -336,9 +339,8 @@ export const generateVariables = (theme: Theme) => {
if (colour) {
const [r, g, b] = colour;
return `--${key}: ${theme[key]}; --${key}-rgb: ${r}, ${g}, ${b};`;
}
return `--${key}: ${theme[key]};`;
}
return `--${key}: ${theme[key]};`;
});
};

View File

@@ -1110,6 +1110,15 @@ export default function ContextMenus() {
<div className="indicator idle" />
<Text id={`app.status.idle`} />
</MenuItem>
<MenuItem
data={{
action: "set_presence",
presence: "Focus",
}}
disabled={!isOnline}>
<div className="indicator focus" />
<Text id={`app.status.focus`} />
</MenuItem>
<MenuItem
data={{
action: "set_presence",

View File

@@ -157,6 +157,8 @@ export default class NotificationOptions
return false;
}
// Check channel notification settings
const mentioned = message.mention_ids?.includes(user._id);
switch (this.computeForChannel(message.channel!)) {
case "muted":
case "none":
@@ -164,7 +166,12 @@ export default class NotificationOptions
return false;
case "mention":
// Ignore if it doesn't mention us.
if (!message.mention_ids?.includes(user._id)) return false;
if (!mentioned) return false;
}
// Check if we are in focus mode
if (user.status?.presence === "Focus" && !mentioned) {
return false;
}
return true;

View File

@@ -92,6 +92,10 @@
background: var(--status-away);
}
&.focus {
background: var(--status-focus);
}
&.busy {
background: var(--status-busy);
}