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">
|
<span className="font-medium">
|
||||||
{commit.author?.name || "Unknown"}
|
{commit.author?.name || "Unknown"}
|
||||||
</span>
|
</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" />
|
<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>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -37,11 +37,11 @@ export function RoomMessageSearch({ roomId, onSelectMessage, onClose }: RoomMess
|
|||||||
|
|
||||||
setIsSearching(true);
|
setIsSearching(true);
|
||||||
try {
|
try {
|
||||||
const resp = await client.get({
|
const resp = await client.get<any, { data?: SearchResult }>({
|
||||||
url: `/api/rooms/${roomId}/messages/search`,
|
url: `/api/rooms/${roomId}/messages/search`,
|
||||||
params: { q: searchQuery, limit: 20, offset: searchOffset },
|
params: { q: searchQuery, limit: 20, offset: searchOffset },
|
||||||
});
|
});
|
||||||
const data = resp.data?.data as SearchResult | undefined;
|
const data = resp.data;
|
||||||
if (data) {
|
if (data) {
|
||||||
setResults(data);
|
setResults(data);
|
||||||
setOffset(searchOffset);
|
setOffset(searchOffset);
|
||||||
|
|||||||
@ -58,7 +58,7 @@ interface RoomPinPanelProps {
|
|||||||
messages: Array<{
|
messages: Array<{
|
||||||
id: string;
|
id: string;
|
||||||
content: string;
|
content: string;
|
||||||
sender_id: string;
|
sender_id?: string | null;
|
||||||
sender_type: string;
|
sender_type: string;
|
||||||
send_at: string;
|
send_at: string;
|
||||||
}>;
|
}>;
|
||||||
|
|||||||
@ -24,7 +24,7 @@ export function MessageList({
|
|||||||
}: MessageListProps) {
|
}: MessageListProps) {
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4 overflow-visible">
|
<div className="space-y-4 overflow-visible">
|
||||||
{messages.map((message, index) => {
|
{messages.map((message) => {
|
||||||
const additionalOptions =
|
const additionalOptions =
|
||||||
typeof messageOptions === "function"
|
typeof messageOptions === "function"
|
||||||
? messageOptions(message)
|
? messageOptions(message)
|
||||||
|
|||||||
@ -111,9 +111,10 @@ export const RepositoryContextProvider = ({
|
|||||||
// Return a minimal placeholder during loading to avoid unmounting
|
// Return a minimal placeholder during loading to avoid unmounting
|
||||||
// the entire subtree (which causes state loss and flash).
|
// the entire subtree (which causes state loss and flash).
|
||||||
const fallbackRepo: RepoInfo = {
|
const fallbackRepo: RepoInfo = {
|
||||||
id: '', name: '', namespace: '', display_name: '',
|
namespace: '', repo_name: '', uid: '',
|
||||||
description: '', is_private: false, default_branch: '',
|
description: null, is_private: false, default_branch: '',
|
||||||
fork_count: 0, star_count: 0, watch_count: 0,
|
commit_count: 0, branch_count: 0, tag_count: 0,
|
||||||
|
star_count: 0, watch_count: 0,
|
||||||
last_commit_at: new Date().toISOString(),
|
last_commit_at: new Date().toISOString(),
|
||||||
is_star: false, is_watch: false,
|
is_star: false, is_watch: false,
|
||||||
ssh_clone_url: '', https_clone_url: '', ai_code_review_enabled: 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)
|
console.error("Error recording audio:", error)
|
||||||
setIsListening(false)
|
setIsListening(false)
|
||||||
setIsRecording(false)
|
setIsRecording(false)
|
||||||
if (stream) {
|
if (audioStream) {
|
||||||
stream.getTracks().forEach((track) => track.stop())
|
audioStream.getTracks().forEach((track: MediaStreamTrack) => track.stop())
|
||||||
}
|
}
|
||||||
setAudioStream(null)
|
setAudioStream(null)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,7 +89,7 @@ export class UniversalWsClient {
|
|||||||
// Reject all pending requests
|
// Reject all pending requests
|
||||||
const pending = [...this.pendingRequests.entries()];
|
const pending = [...this.pendingRequests.entries()];
|
||||||
this.pendingRequests.clear();
|
this.pendingRequests.clear();
|
||||||
for (const [id, req] of pending) {
|
for (const [_id, req] of pending) {
|
||||||
clearTimeout(req.timeout);
|
clearTimeout(req.timeout);
|
||||||
req.reject(new Error(`WebSocket closed: ${ev.reason || 'unknown'}`));
|
req.reject(new Error(`WebSocket closed: ${ev.reason || 'unknown'}`));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user