mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 09:25:27 +00:00
feat: add focus mode
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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" />;
|
||||
}
|
||||
|
||||
@@ -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]};`;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -92,6 +92,10 @@
|
||||
background: var(--status-away);
|
||||
}
|
||||
|
||||
&.focus {
|
||||
background: var(--status-focus);
|
||||
}
|
||||
|
||||
&.busy {
|
||||
background: var(--status-busy);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user