Repository navigation
fix(webapp): server logs pagination and twitch not-configured ux #613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,9 @@ export default function TwitchNotificationsPage() { | |
| const [showAdd, setShowAdd] = useState(false) | ||
| const [newTwitchInput, setNewTwitchInput] = useState('') | ||
| const [newChannelId, setNewChannelId] = useState('') | ||
| const [twitchConfigured, setTwitchConfigured] = useState<boolean | null>( | ||
| null, | ||
| ) | ||
| const notificationsRequestIdRef = useRef(0) | ||
| const channelsRequestIdRef = useRef(0) | ||
| const selectedGuildIdRef = useRef<string | undefined>(guildId) | ||
|
|
@@ -49,6 +52,18 @@ export default function TwitchNotificationsPage() { | |
| selectedGuildIdRef.current = guildId | ||
| }, [guildId]) | ||
|
|
||
| useEffect(() => { | ||
| const checkTwitchStatus = async () => { | ||
| try { | ||
| const res = await api.twitch.status() | ||
| setTwitchConfigured(res.data.configured) | ||
| } catch { | ||
| setTwitchConfigured(false) | ||
| } | ||
|
Comment on lines
+55
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don’t map all status-check failures to “not configured.” Line 61 currently sets Suggested fix+ const [twitchStatusError, setTwitchStatusError] = useState<string | null>(null)
useEffect(() => {
const checkTwitchStatus = async () => {
try {
const res = await api.twitch.status()
setTwitchConfigured(res.data.configured)
+ setTwitchStatusError(null)
} catch {
- setTwitchConfigured(false)
+ setTwitchConfigured(null)
+ setTwitchStatusError('Unable to verify Twitch configuration status')
}
}
checkTwitchStatus()
}, [])🤖 Prompt for AI Agents |
||
| } | ||
| checkTwitchStatus() | ||
| }, []) | ||
|
|
||
| const channelNameById = useMemo( | ||
| () => new Map(channels.map((channel) => [channel.id, channel.name])), | ||
| [channels], | ||
|
|
@@ -272,6 +287,26 @@ export default function TwitchNotificationsPage() { | |
| ) | ||
| } | ||
|
|
||
| if (twitchConfigured === false) { | ||
| return ( | ||
| <div className='space-y-6 px-1 sm:px-0'> | ||
| <header className='flex items-center gap-3'> | ||
| <Tv className='h-6 w-6 text-purple-500' /> | ||
| <h1 className='text-xl font-bold text-white'> | ||
| Twitch Notifications | ||
| </h1> | ||
| </header> | ||
| <div className='p-4 rounded-lg bg-lucky-error/10 border border-lucky-error text-lucky-error'> | ||
| <p className='font-semibold mb-1'>Not Configured</p> | ||
| <p className='text-sm'> | ||
| Twitch API is not configured on this server. Contact the | ||
| server administrator to set up Twitch credentials. | ||
| </p> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| return ( | ||
| <div className='space-y-6 px-1 sm:px-0'> | ||
| <header className='flex items-center justify-between'> | ||
|
|
@@ -286,7 +321,8 @@ export default function TwitchNotificationsPage() { | |
| </div> | ||
| <button | ||
| onClick={() => setShowAdd(!showAdd)} | ||
| className='flex cursor-pointer items-center gap-2 rounded-lg bg-purple-600/10 px-3 py-1.5 text-sm text-purple-400 transition-colors hover:bg-purple-600/20' | ||
| disabled={!twitchConfigured} | ||
| className='flex cursor-pointer items-center gap-2 rounded-lg bg-purple-600/10 px-3 py-1.5 text-sm text-purple-400 transition-colors hover:bg-purple-600/20 disabled:opacity-50 disabled:cursor-not-allowed' | ||
| > | ||
| <Plus className='w-4 h-4' /> | ||
| Add | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,13 +4,19 @@ import type { ServerLog } from '@/types' | |
| export function createLogsApi(apiClient: AxiosInstance) { | ||
| return { | ||
| getRecent: (guildId: string, limit?: number) => | ||
| apiClient.get<{ logs: ServerLog[] }>(`/guilds/${guildId}/logs`, { | ||
| params: limit ? { limit } : {}, | ||
| }), | ||
| apiClient.get<{ logs: ServerLog[]; total: number }>( | ||
| `/guilds/${guildId}/logs`, | ||
| { | ||
| params: limit ? { limit } : {}, | ||
| }, | ||
| ), | ||
| getByType: (guildId: string, type: string, limit?: number) => | ||
| apiClient.get<{ logs: ServerLog[] }>(`/guilds/${guildId}/logs`, { | ||
| params: { type, ...(limit ? { limit } : {}) }, | ||
| }), | ||
| apiClient.get<{ logs: ServerLog[]; total: number }>( | ||
| `/guilds/${guildId}/logs`, | ||
| { | ||
| params: { type, ...(limit ? { limit } : {}) }, | ||
| }, | ||
| ), | ||
|
Comment on lines
6
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use explicit Current truthy checks omit Suggested fix getRecent: (guildId: string, limit?: number) =>
apiClient.get<{ logs: ServerLog[]; total: number }>(
`/guilds/${guildId}/logs`,
{
- params: limit ? { limit } : {},
+ params: limit !== undefined ? { limit } : {},
},
),
getByType: (guildId: string, type: string, limit?: number) =>
apiClient.get<{ logs: ServerLog[]; total: number }>(
`/guilds/${guildId}/logs`,
{
- params: { type, ...(limit ? { limit } : {}) },
+ params: { type, ...(limit !== undefined ? { limit } : {}) },
},
),🤖 Prompt for AI Agents |
||
| search: ( | ||
| guildId: string, | ||
| filters: { type?: string; userId?: string }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/api/twitch/statuscan report a false positive configured stateLine 113 only checks
TWITCH_CLIENT_ID, but lookup logic in this same file also needs eitherTWITCH_ACCESS_TOKENorTWITCH_CLIENT_SECRET. This can re-enable the broken UX you’re fixing (button enabled, then lookup fails).Suggested fix
🤖 Prompt for AI Agents