mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-12 18:29:57 -05:00
Merge branch 'master' of https://gitlab.insrt.uk/revolt/revite
This commit is contained in:
commit
a1729e0836
7 changed files with 60 additions and 9 deletions
2
external/lang
vendored
2
external/lang
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 9406c734ca2cb7b65eefcf926d9e829f9a2056d7
|
Subproject commit 03b206f608b071eb26a099657d9619d32f2bb264
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { Text } from "preact-i18n";
|
||||||
|
import styled from "styled-components";
|
||||||
import { Children } from "../../types/Preact";
|
import { Children } from "../../types/Preact";
|
||||||
import Tippy, { TippyProps } from '@tippyjs/react';
|
import Tippy, { TippyProps } from '@tippyjs/react';
|
||||||
|
|
||||||
|
@ -17,3 +19,24 @@ export default function Tooltip(props: Props) {
|
||||||
</Tippy>
|
</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 { ulid } from "ulid";
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
import Tooltip from "../Tooltip";
|
import Tooltip, { PermissionTooltip } from "../Tooltip";
|
||||||
import { Channel } from "revolt.js";
|
import { Channel } from "revolt.js";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { defer } from "../../../lib/defer";
|
import { defer } from "../../../lib/defer";
|
||||||
|
@ -90,9 +90,9 @@ function MessageBox({ channel, draft, dispatcher }: Props) {
|
||||||
return (
|
return (
|
||||||
<Base>
|
<Base>
|
||||||
<Blocked>
|
<Blocked>
|
||||||
<Tooltip content={<div>Permissions Required<div>Send messages</div></div>} placement="top">
|
<PermissionTooltip permission="SendMessages" placement="top">
|
||||||
<ShieldX size={22}/>
|
<ShieldX size={22}/>
|
||||||
</Tooltip>
|
</PermissionTooltip>
|
||||||
<Text id="app.main.channel.misc.no_sending" />
|
<Text id="app.main.channel.misc.no_sending" />
|
||||||
</Blocked>
|
</Blocked>
|
||||||
</Base>
|
</Base>
|
||||||
|
|
|
@ -20,3 +20,4 @@ export function internalEmit(ns: string, event: string, ...args: any[]) {
|
||||||
// - MessageBox/append
|
// - MessageBox/append
|
||||||
// - TextArea/focus
|
// - TextArea/focus
|
||||||
// - ReplyBar/add
|
// - ReplyBar/add
|
||||||
|
// - PWA/update
|
||||||
|
|
10
src/main.tsx
10
src/main.tsx
|
@ -1,9 +1,9 @@
|
||||||
import { registerSW } from 'virtual:pwa-register'
|
import { registerSW } from 'virtual:pwa-register';
|
||||||
const updateSW = registerSW({
|
import { internalEmit } from './lib/eventEmitter';
|
||||||
|
|
||||||
|
export const updateSW = registerSW({
|
||||||
onNeedRefresh() {
|
onNeedRefresh() {
|
||||||
// ! FIXME: temp
|
internalEmit('PWA', 'update');
|
||||||
updateSW(true);
|
|
||||||
// show a prompt to user
|
|
||||||
},
|
},
|
||||||
onOfflineReady() {
|
onOfflineReady() {
|
||||||
console.info('Ready to work offline.');
|
console.info('Ready to work offline.');
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { ChannelHeaderProps } from "../ChannelHeader";
|
||||||
import IconButton from "../../../components/ui/IconButton";
|
import IconButton from "../../../components/ui/IconButton";
|
||||||
import { AppContext } from "../../../context/revoltjs/RevoltClient";
|
import { AppContext } from "../../../context/revoltjs/RevoltClient";
|
||||||
import { isTouchscreenDevice } from "../../../lib/isTouchscreenDevice";
|
import { isTouchscreenDevice } from "../../../lib/isTouchscreenDevice";
|
||||||
|
import UpdateIndicator from "../../../components/common/UpdateIndicator";
|
||||||
import { useIntermediate } from "../../../context/intermediate/Intermediate";
|
import { useIntermediate } from "../../../context/intermediate/Intermediate";
|
||||||
import { VoiceContext, VoiceOperationsContext, VoiceStatus } from "../../../context/Voice";
|
import { VoiceContext, VoiceOperationsContext, VoiceStatus } from "../../../context/Voice";
|
||||||
import { UserPlus, Cog, Sidebar as SidebarIcon, PhoneCall, PhoneOutgoing } from "@styled-icons/boxicons-regular";
|
import { UserPlus, Cog, Sidebar as SidebarIcon, PhoneCall, PhoneOutgoing } from "@styled-icons/boxicons-regular";
|
||||||
|
@ -15,6 +16,7 @@ export default function HeaderActions({ channel, toggleSidebar }: ChannelHeaderP
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<UpdateIndicator />
|
||||||
{ channel.channel_type === "Group" && (
|
{ channel.channel_type === "Group" && (
|
||||||
<>
|
<>
|
||||||
<IconButton onClick={() =>
|
<IconButton onClick={() =>
|
||||||
|
|
Loading…
Reference in a new issue