forked from abner/for-legacy-web
Merge branch 'master' of https://gitlab.insrt.uk/revolt/revite
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { Text } from "preact-i18n";
|
||||
import styled from "styled-components";
|
||||
import { Children } from "../../types/Preact";
|
||||
import Tippy, { TippyProps } from '@tippyjs/react';
|
||||
|
||||
@@ -17,3 +19,24 @@ export default function Tooltip(props: Props) {
|
||||
</Tippy>
|
||||
);
|
||||
}
|
||||
|
||||
const PermissionTooltipBase = styled.div`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
|
||||
code {
|
||||
font-family: 'Fira Mono';
|
||||
}
|
||||
`;
|
||||
|
||||
export function PermissionTooltip(props: Omit<Props, 'content'> & { permission: string }) {
|
||||
const { permission, ...tooltipProps } = props;
|
||||
|
||||
return (
|
||||
<Tooltip content={<PermissionTooltipBase>
|
||||
<Text id="app.permissions.required" />
|
||||
<code>{ permission }</code>
|
||||
</PermissionTooltipBase>} {...tooltipProps} />
|
||||
)
|
||||
}
|
||||
|
||||
25
src/components/common/UpdateIndicator.tsx
Normal file
25
src/components/common/UpdateIndicator.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { updateSW } from "../../main";
|
||||
import IconButton from "../ui/IconButton";
|
||||
import { ThemeContext } from "../../context/Theme";
|
||||
import { Download } from "@styled-icons/boxicons-regular";
|
||||
import { internalSubscribe } from "../../lib/eventEmitter";
|
||||
import { useContext, useEffect, useState } from "preact/hooks";
|
||||
|
||||
var pendingUpdate = false;
|
||||
|
||||
export default function UpdateIndicator() {
|
||||
const [ pending, setPending ] = useState(pendingUpdate);
|
||||
|
||||
useEffect(() => {
|
||||
return internalSubscribe('PWA', 'update', () => setPending(true));
|
||||
});
|
||||
|
||||
if (!pending) return;
|
||||
const theme = useContext(ThemeContext);
|
||||
|
||||
return (
|
||||
<IconButton onClick={() => updateSW(true)}>
|
||||
<Download size={22} color={theme.success} />
|
||||
</IconButton>
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ulid } from "ulid";
|
||||
import { Text } from "preact-i18n";
|
||||
import Tooltip from "../Tooltip";
|
||||
import Tooltip, { PermissionTooltip } from "../Tooltip";
|
||||
import { Channel } from "revolt.js";
|
||||
import styled from "styled-components";
|
||||
import { defer } from "../../../lib/defer";
|
||||
@@ -90,9 +90,9 @@ function MessageBox({ channel, draft, dispatcher }: Props) {
|
||||
return (
|
||||
<Base>
|
||||
<Blocked>
|
||||
<Tooltip content={<div>Permissions Required<div>Send messages</div></div>} placement="top">
|
||||
<PermissionTooltip permission="SendMessages" placement="top">
|
||||
<ShieldX size={22}/>
|
||||
</Tooltip>
|
||||
</PermissionTooltip>
|
||||
<Text id="app.main.channel.misc.no_sending" />
|
||||
</Blocked>
|
||||
</Base>
|
||||
|
||||
Reference in New Issue
Block a user