mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-01 19:46:36 +03:00
webterm: fix bell icon in tabs
Presumably due to how js non-objects work in closures, the selected prop we were reading out whenever a blit came in was stale. Also, it was possible that a bell was hiding inside a %mor blit, so we add a small helper for checking properly.
This commit is contained in:
parent
8da6c20f70
commit
60ed368bc4
@ -12,7 +12,7 @@ import useTermState from './state';
|
||||
import React from 'react';
|
||||
import { Box, Col } from '@tlon/indigo-react';
|
||||
import { makeTheme } from './lib/theme';
|
||||
import { showBlit, csi } from './lib/blit';
|
||||
import { showBlit, csi, hasBell } from './lib/blit';
|
||||
import { DEFAULT_SESSION } from './constants';
|
||||
import { retry } from './lib/retry';
|
||||
|
||||
@ -180,7 +180,8 @@ export default function Buffer({ name, selected, dark }: BufferProps) {
|
||||
app: 'herm', path: '/session/' + name + '/view',
|
||||
event: (e) => {
|
||||
showBlit(ses.term, e);
|
||||
if (e.bel && !selected) {
|
||||
//NOTE getting selected from state because selected prop is stale
|
||||
if (hasBell(e) && (useTermState.getState().selected !== name)) {
|
||||
useTermState.getState().set((state) => {
|
||||
state.sessions[name].hasBell = true;
|
||||
});
|
||||
|
@ -73,3 +73,13 @@ export const showSlog = (term: Terminal, slog: string) => {
|
||||
+ csi('r')
|
||||
+ csi('u'));
|
||||
};
|
||||
|
||||
export const hasBell = (blit: Blit) => {
|
||||
if ('bel' in blit) {
|
||||
return true;
|
||||
} else if ('mor' in blit) {
|
||||
return blit.mor.some(hasBell);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user