restore one-click list refresh (#1040)

This commit is contained in:
Athou
2023-03-06 14:08:48 +01:00
parent 3da900db7f
commit 10bfbbec17
31 changed files with 91 additions and 214 deletions

View File

@@ -1,11 +1,25 @@
import { Trans } from "@lingui/macro"
import { t, Trans } from "@lingui/macro"
import { Box, Divider, Group, Menu, SegmentedControl, SegmentedControlItem, useMantineColorScheme } from "@mantine/core"
import { showNotification } from "@mantine/notifications"
import { client } from "app/client"
import { redirectToAbout, redirectToAdminUsers, redirectToMetrics, redirectToSettings } from "app/slices/redirect"
import { changeViewMode } from "app/slices/user"
import { useAppDispatch, useAppSelector } from "app/store"
import { ViewMode } from "app/types"
import { useState } from "react"
import { TbChartLine, TbHelp, TbLayoutList, TbList, TbMoon, TbNotes, TbPower, TbSettings, TbSun, TbUsers } from "react-icons/tb"
import {
TbChartLine,
TbHelp,
TbLayoutList,
TbList,
TbMoon,
TbNotes,
TbPower,
TbSettings,
TbSun,
TbUsers,
TbWorldDownload,
} from "react-icons/tb"
interface ProfileMenuProps {
control: React.ReactElement
@@ -56,6 +70,7 @@ const viewModeData: ViewModeControlItem[] = [
export function ProfileMenu(props: ProfileMenuProps) {
const [opened, setOpened] = useState(false)
const viewMode = useAppSelector(state => state.user.settings?.viewMode)
const profile = useAppSelector(state => state.user.profile)
const admin = useAppSelector(state => state.user.profile?.admin)
const dispatch = useAppDispatch()
const { colorScheme, toggleColorScheme } = useMantineColorScheme()
@@ -69,6 +84,7 @@ export function ProfileMenu(props: ProfileMenuProps) {
<Menu position="bottom-end" closeOnItemClick={false} opened={opened} onChange={setOpened}>
<Menu.Target>{props.control}</Menu.Target>
<Menu.Dropdown>
{profile && <Menu.Label>{profile.name}</Menu.Label>}
<Menu.Item
icon={<TbSettings size={iconSize} />}
onClick={() => {
@@ -78,6 +94,21 @@ export function ProfileMenu(props: ProfileMenuProps) {
>
<Trans>Settings</Trans>
</Menu.Item>
<Menu.Item
icon={<TbWorldDownload size={iconSize} />}
onClick={() =>
client.feed.refreshAll().then(() => {
showNotification({
message: t`Your feeds have been queued for refresh.`,
color: "green",
autoClose: 1000,
})
setOpened(false)
})
}
>
<Trans>Fetch all my feeds now</Trans>
</Menu.Item>
<Divider />
<Menu.Label>