fix(frontend): resolve TypeScript type errors in repository pages
- commits.tsx: fix Unix timestamp (time_secs) not multiplied by 1000 - RoomMessageSearch.tsx: add explicit generic type for resp.data - RoomPinPanel.tsx: make sender_id optional (string | null) - message-list.tsx: remove unused index variable in map - repository-context.tsx: use correct RepoInfo field names - use-audio-recording.ts: use audioStream state instead of undefined var - universal-ws.ts: rename unused id to _id
This commit is contained in:
parent
88dd3a5f61
commit
1deea4c671
@ -350,9 +350,9 @@ export const RepoCommits = () => {
|
||||
<span className="font-medium">
|
||||
{commit.author?.name || "Unknown"}
|
||||
</span>
|
||||
<span className="flex items-center gap-1" title={formatWithGlobalTimezone(commit.committer?.time_secs)}>
|
||||
<span className="flex items-center gap-1" title={commit.committer?.time_secs ? formatWithGlobalTimezone(new Date(commit.committer.time_secs * 1000).toISOString()) : undefined}>
|
||||
<Calendar className="h-3.5 w-3.5" />
|
||||
{getRelativeTime(commit.committer?.time_secs)}
|
||||
{getRelativeTime(commit.committer?.time_secs ? new Date(commit.committer.time_secs * 1000).toISOString() : null)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -37,11 +37,11 @@ export function RoomMessageSearch({ roomId, onSelectMessage, onClose }: RoomMess
|
||||
|
||||
setIsSearching(true);
|
||||
try {
|
||||
const resp = await client.get({
|
||||
const resp = await client.get<any, { data?: SearchResult }>({
|
||||
url: `/api/rooms/${roomId}/messages/search`,
|
||||
params: { q: searchQuery, limit: 20, offset: searchOffset },
|
||||
});
|
||||
const data = resp.data?.data as SearchResult | undefined;
|
||||
const data = resp.data;
|
||||
if (data) {
|
||||
setResults(data);
|
||||
setOffset(searchOffset);
|
||||
|
||||
@ -58,7 +58,7 @@ interface RoomPinPanelProps {
|
||||
messages: Array<{
|
||||
id: string;
|
||||
content: string;
|
||||
sender_id: string;
|
||||
sender_id?: string | null;
|
||||
sender_type: string;
|
||||
send_at: string;
|
||||
}>;
|
||||
|
||||
@ -24,7 +24,7 @@ export function MessageList({
|
||||
}: MessageListProps) {
|
||||
return (
|
||||
<div className="space-y-4 overflow-visible">
|
||||
{messages.map((message, index) => {
|
||||
{messages.map((message) => {
|
||||
const additionalOptions =
|
||||
typeof messageOptions === "function"
|
||||
? messageOptions(message)
|
||||
|
||||
@ -111,9 +111,10 @@ export const RepositoryContextProvider = ({
|
||||
// Return a minimal placeholder during loading to avoid unmounting
|
||||
// the entire subtree (which causes state loss and flash).
|
||||
const fallbackRepo: RepoInfo = {
|
||||
id: '', name: '', namespace: '', display_name: '',
|
||||
description: '', is_private: false, default_branch: '',
|
||||
fork_count: 0, star_count: 0, watch_count: 0,
|
||||
namespace: '', repo_name: '', uid: '',
|
||||
description: null, is_private: false, default_branch: '',
|
||||
commit_count: 0, branch_count: 0, tag_count: 0,
|
||||
star_count: 0, watch_count: 0,
|
||||
last_commit_at: new Date().toISOString(),
|
||||
is_star: false, is_watch: false,
|
||||
ssh_clone_url: '', https_clone_url: '', ai_code_review_enabled: false,
|
||||
|
||||
@ -77,8 +77,8 @@ export function useAudioRecording({
|
||||
console.error("Error recording audio:", error)
|
||||
setIsListening(false)
|
||||
setIsRecording(false)
|
||||
if (stream) {
|
||||
stream.getTracks().forEach((track) => track.stop())
|
||||
if (audioStream) {
|
||||
audioStream.getTracks().forEach((track: MediaStreamTrack) => track.stop())
|
||||
}
|
||||
setAudioStream(null)
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ export class UniversalWsClient {
|
||||
// Reject all pending requests
|
||||
const pending = [...this.pendingRequests.entries()];
|
||||
this.pendingRequests.clear();
|
||||
for (const [id, req] of pending) {
|
||||
for (const [_id, req] of pending) {
|
||||
clearTimeout(req.timeout);
|
||||
req.reject(new Error(`WebSocket closed: ${ev.reason || 'unknown'}`));
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user