mirror of
https://git.sr.ht/~ashkeel/strimertul
synced 2024-10-02 02:50:32 +00:00
Compare commits
No commits in common. "3c3ea7bdb40e58f299be8d7bae7aae187386b6a0" and "82b7d51df7a5e3b42f4c004c644222200d45f550" have entirely different histories.
3c3ea7bdb4
...
82b7d51df7
5 changed files with 17 additions and 99 deletions
|
@ -8,14 +8,7 @@ import {
|
|||
import { useLiveKey, useModule } from '~/lib/react';
|
||||
import { useAppDispatch, useAppSelector } from '~/store';
|
||||
import { modules } from '~/store/api/reducer';
|
||||
import * as HoverCard from '@radix-ui/react-hover-card';
|
||||
import {
|
||||
PageContainer,
|
||||
SectionHeader,
|
||||
styled,
|
||||
TextBlock,
|
||||
TooltipContent,
|
||||
} from '../theme';
|
||||
import { PageContainer, SectionHeader, styled, TextBlock } from '../theme';
|
||||
import BrowserLink from '../components/BrowserLink';
|
||||
import Scrollbar from '../components/utils/Scrollbar';
|
||||
import RevealLink from '../components/utils/RevealLink';
|
||||
|
@ -352,21 +345,15 @@ function TwitchEventLog({ events }: { events: EventSubNotification[] }) {
|
|||
const { t } = useTranslation();
|
||||
return (
|
||||
<>
|
||||
<HoverCard.Root>
|
||||
<HoverCard.Trigger asChild>
|
||||
<SectionHeader>
|
||||
{t('pages.dashboard.twitch-events.header')}
|
||||
<a style={{ marginLeft: '10px' }}>
|
||||
<InfoCircledIcon />
|
||||
</a>
|
||||
</SectionHeader>
|
||||
</HoverCard.Trigger>
|
||||
<HoverCard.Portal>
|
||||
<TooltipContent>
|
||||
{t('pages.dashboard.twitch-events.warning')}
|
||||
</TooltipContent>
|
||||
</HoverCard.Portal>
|
||||
</HoverCard.Root>
|
||||
<SectionHeader>
|
||||
{t('pages.dashboard.twitch-events.header')}
|
||||
<a
|
||||
style={{ marginLeft: '10px' }}
|
||||
title={t('pages.dashboard.twitch-events.warning')}
|
||||
>
|
||||
<InfoCircledIcon />
|
||||
</a>
|
||||
</SectionHeader>
|
||||
<Scrollbar vertical={true} viewport={{ maxHeight: '250px' }}>
|
||||
<EventListContainer>
|
||||
{events
|
||||
|
@ -440,15 +427,10 @@ function TwitchSection() {
|
|||
);
|
||||
}
|
||||
|
||||
function ProblemList() {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
export default function Dashboard(): React.ReactElement {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<PageContainer>
|
||||
<ProblemList />
|
||||
<TwitchSection />
|
||||
<SectionHeader>{t('pages.dashboard.quick-links')}</SectionHeader>
|
||||
<UsefulLinksMenu>
|
||||
|
|
|
@ -26,8 +26,6 @@ import extensionsReducer, {
|
|||
startExtension,
|
||||
stopExtension,
|
||||
} from '~/store/extensions/reducer';
|
||||
import { useModule } from '~/lib/react';
|
||||
import { modules } from '~/store/api/reducer';
|
||||
import AlertContent from '../components/AlertContent';
|
||||
import DialogContent from '../components/DialogContent';
|
||||
import Loading from '../components/Loading';
|
||||
|
@ -39,7 +37,6 @@ import {
|
|||
DialogActions,
|
||||
Field,
|
||||
FlexRow,
|
||||
getTheme,
|
||||
InputBox,
|
||||
Label,
|
||||
MultiButton,
|
||||
|
@ -223,7 +220,7 @@ function ExtensionListItem(props: ExtensionListItemProps) {
|
|||
}}
|
||||
showCancel={false}
|
||||
>
|
||||
<code>{props.error.message}</code>
|
||||
<code>{props.error.toString()}</code>
|
||||
</AlertContent>
|
||||
</Alert>
|
||||
) : null}
|
||||
|
@ -586,7 +583,6 @@ function ExtensionEditor() {
|
|||
}
|
||||
|
||||
export default function ExtensionsPage(): React.ReactElement {
|
||||
const [uiConfig] = useModule(modules.uiConfig);
|
||||
const { t } = useTranslation();
|
||||
const extensions = useAppSelector((state) => state.extensions);
|
||||
const dispatch = useAppDispatch();
|
||||
|
@ -623,20 +619,12 @@ export default function ExtensionsPage(): React.ReactElement {
|
|||
};
|
||||
|
||||
if (!extensions.ready) {
|
||||
const theme = getTheme(
|
||||
uiConfig?.theme ?? localStorage.getItem('theme') ?? 'dark',
|
||||
);
|
||||
|
||||
return (
|
||||
<PageContainer>
|
||||
<PageHeader>
|
||||
<PageTitle>{t('pages.extensions.title')}</PageTitle>
|
||||
</PageHeader>
|
||||
<Loading
|
||||
theme={theme}
|
||||
size="fill"
|
||||
message={t('pages.extensions.loading')}
|
||||
/>
|
||||
<Loading size="fill" message={t('pages.extensions.loading')} />
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* eslint-disable import/prefer-default-export */
|
||||
|
||||
import { Content as HoverCardContent } from '@radix-ui/react-hover-card';
|
||||
import { styled, theme } from './theme';
|
||||
|
||||
export const FlexRow = styled('div', {
|
||||
|
@ -27,15 +26,3 @@ export const FlexRow = styled('div', {
|
|||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const TooltipContent = styled(HoverCardContent, {
|
||||
borderRadius: 6,
|
||||
display: 'flex',
|
||||
padding: '0.5rem',
|
||||
gap: '0.5rem',
|
||||
flexDirection: 'column',
|
||||
border: '2px solid $gray6',
|
||||
backgroundColor: '$gray2',
|
||||
alignItems: 'flex-start',
|
||||
boxShadow: '0px 5px 20px rgba(0,0,0,0.4)',
|
||||
});
|
||||
|
|
|
@ -3,7 +3,6 @@ package twitch
|
|||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/nicklaw5/helix/v2"
|
||||
|
@ -17,60 +16,22 @@ type AuthResponse struct {
|
|||
Time time.Time
|
||||
}
|
||||
|
||||
var scopes = []string{
|
||||
"bits:read",
|
||||
"channel:bot",
|
||||
"channel:moderate",
|
||||
"channel:read:hype_train",
|
||||
"channel:read:polls",
|
||||
"channel:read:predictions",
|
||||
"channel:read:redemptions",
|
||||
"channel:read:subscriptions",
|
||||
"chat:edit",
|
||||
"chat:read",
|
||||
"moderator:manage:announcements",
|
||||
"moderator:read:chatters",
|
||||
"moderator:read:followers",
|
||||
"user_read",
|
||||
"user:bot",
|
||||
"user:manage:whispers",
|
||||
"user:read:chat",
|
||||
"whispers:edit",
|
||||
"whispers:read",
|
||||
}
|
||||
|
||||
func (c *Client) GetAuthorizationURL() string {
|
||||
if c.API == nil {
|
||||
return "twitch-not-configured"
|
||||
}
|
||||
return c.API.GetAuthorizationURL(&helix.AuthorizationURLParams{
|
||||
ResponseType: "code",
|
||||
Scopes: scopes,
|
||||
Scopes: []string{"bits:read channel:read:subscriptions channel:read:redemptions channel:read:polls channel:read:predictions channel:read:hype_train user_read chat:read chat:edit channel:moderate whispers:read whispers:edit moderator:read:chatters moderator:read:followers user:manage:whispers moderator:manage:announcements"},
|
||||
})
|
||||
}
|
||||
|
||||
// CheckScopes checks if the user has authorized all required scopes
|
||||
// Normally this would be the case but between versions strimertul has changed
|
||||
// the required scopes, and it's possible that some users have not re-authorized
|
||||
// the application with the new scopes.
|
||||
func (c *Client) CheckScopes() (bool, error) {
|
||||
var authResp AuthResponse
|
||||
if err := c.db.GetJSON(AuthKey, &authResp); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// Sort scopes for comparison
|
||||
slices.Sort(authResp.Scope)
|
||||
|
||||
return slices.Equal(scopes, authResp.Scope), nil
|
||||
}
|
||||
|
||||
func (c *Client) GetUserClient(forceRefresh bool) (*helix.Client, error) {
|
||||
var authResp AuthResponse
|
||||
if err := c.db.GetJSON(AuthKey, &authResp); err != nil {
|
||||
err := c.db.GetJSON(AuthKey, &authResp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Handle token expiration
|
||||
if forceRefresh || time.Now().After(authResp.Time.Add(time.Duration(authResp.ExpiresIn)*time.Second)) {
|
||||
// Refresh tokens
|
||||
|
@ -147,7 +108,7 @@ func (c *Client) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||
return
|
||||
}
|
||||
w.Header().Add("Content-Type", "text/html")
|
||||
_, _ = fmt.Fprintf(w, `<html><body><h2>All done, you can close me now!</h2><script>window.close();</script></body></html>`)
|
||||
fmt.Fprintf(w, `<html><body><h2>All done, you can close me now!</h2><script>window.close();</script></body></html>`)
|
||||
}
|
||||
|
||||
type RefreshResponse struct {
|
||||
|
|
|
@ -14,7 +14,7 @@ var (
|
|||
)
|
||||
|
||||
func setStdHandle(stdhandle int32, handle syscall.Handle) error {
|
||||
r0, _, e1 := syscall.SyscallN(procSetStdHandle.Addr(), uintptr(stdhandle), uintptr(handle), 0)
|
||||
r0, _, e1 := syscall.SyscallN(procSetStdHandle.Addr(), 2, uintptr(stdhandle), uintptr(handle), 0)
|
||||
if r0 == 0 {
|
||||
if e1 != 0 {
|
||||
return error(e1)
|
||||
|
|
Loading…
Reference in a new issue