Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ const App: React.FC = () => {
return (
<RepoDetail
token={token}
user={user}
repo={selectedRepo}
onBack={navigateBack}
onIssueSelect={navigateToIssue}
Expand Down
4 changes: 2 additions & 2 deletions services/cacheService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ export function clearCache(key?: string): void {

// Cache keys helper
export const CacheKeys = {
repos: () => 'repos',
repos: (userId: string) => `repos_${userId}`,
repoIssues: (owner: string, repo: string) => `issues_${owner}_${repo}`,
issueComments: (owner: string, repo: string, issueNumber: number) => `comments_${owner}_${repo}_${issueNumber}`,
workflowRuns: (owner: string, repo: string) => `workflows_${owner}_${repo}`,
prDetails: (owner: string, repo: string, prNumber: number) => `pr_${owner}_${repo}_${prNumber}`,
issueExpandedData: (owner: string, repo: string, issueNumber: number) => `expanded_${owner}_${repo}_${issueNumber}`,
workflowFiles: () => 'workflow_files',
workflowFiles: (userId: string) => `workflow_files_${userId}`,
};

// Type for cached expanded issue data (all data needed for expanded view)
Expand Down
10 changes: 5 additions & 5 deletions views/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export const Dashboard: React.FC<DashboardProps> = ({ token, user, onRepoSelect,

// Initialize from cache for instant display
const [repos, setRepos] = useState<Repository[]>(() => {
return getCached<Repository[]>(CacheKeys.repos()) || [];
return getCached<Repository[]>(CacheKeys.repos(user.login)) || [];
});
const [loading, setLoading] = useState(() => {
// Only show loading if no cached data
return !getCached<Repository[]>(CacheKeys.repos());
return !getCached<Repository[]>(CacheKeys.repos(user.login));
});
const [isRefreshing, setIsRefreshing] = useState(false);
const [error, setError] = useState('');
Expand All @@ -34,9 +34,9 @@ export const Dashboard: React.FC<DashboardProps> = ({ token, user, onRepoSelect,
});
// Initialize issues from cache for instant display
const [repoIssues, setRepoIssues] = useState<Record<number, Issue[]>>(() => {
const cachedRepos = getCached<Repository[]>(CacheKeys.repos());
const cachedRepos = getCached<Repository[]>(CacheKeys.repos(user.login));
if (!cachedRepos) return {};

const issuesMap: Record<number, Issue[]> = {};
for (const repo of cachedRepos.slice(0, 4)) {
const cachedIssues = getCached<Issue[]>(CacheKeys.repoIssues(repo.owner.login, repo.name));
Expand Down Expand Up @@ -91,7 +91,7 @@ export const Dashboard: React.FC<DashboardProps> = ({ token, user, onRepoSelect,
const data = await fetchRepositories(token);
setRepos(data);
// Cache the repos for instant display on next visit
setCache(CacheKeys.repos(), data);
setCache(CacheKeys.repos(user.login), data);

// Load issues for first 4 repos - reuse cache when available
const reposToShow = data.slice(0, 4);
Expand Down
11 changes: 6 additions & 5 deletions views/RepoDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import { getCached, setCache, CacheKeys } from '../services/cacheService';

interface RepoDetailProps {
token: string;
user: { login: string };
repo: Repository;
onBack: () => void;
onIssueSelect: (issue: Issue) => void;
}

export const RepoDetail: React.FC<RepoDetailProps> = ({ token, repo, onBack, onIssueSelect }) => {
export const RepoDetail: React.FC<RepoDetailProps> = ({ token, user, repo, onBack, onIssueSelect }) => {
const { toasts, dismissToast, showError } = useToast();
const cacheKey = CacheKeys.repoIssues(repo.owner.login, repo.name);

Expand All @@ -36,7 +37,7 @@ export const RepoDetail: React.FC<RepoDetailProps> = ({ token, repo, onBack, onI

// Workflow Files State
const [workflowFiles, setWorkflowFiles] = useState<WorkflowFile[]>(() => {
return getCached<WorkflowFile[]>(CacheKeys.workflowFiles()) || [];
return getCached<WorkflowFile[]>(CacheKeys.workflowFiles(user.login)) || [];
});
const [loadingWorkflows, setLoadingWorkflows] = useState(false);
const [workflowsExpanded, setWorkflowsExpanded] = useState(false);
Expand Down Expand Up @@ -99,7 +100,7 @@ export const RepoDetail: React.FC<RepoDetailProps> = ({ token, repo, onBack, onI
};

const loadWorkflowFiles = React.useCallback(async () => {
const cachedWorkflows = getCached<WorkflowFile[]>(CacheKeys.workflowFiles());
const cachedWorkflows = getCached<WorkflowFile[]>(CacheKeys.workflowFiles(user.login));
if (cachedWorkflows && cachedWorkflows.length > 0) {
setWorkflowFiles(cachedWorkflows);
return;
Expand All @@ -108,11 +109,11 @@ export const RepoDetail: React.FC<RepoDetailProps> = ({ token, repo, onBack, onI
setLoadingWorkflows(true);
try {
// Fetch repos first if needed
const repos = getCached<Repository[]>(CacheKeys.repos()) || [];
const repos = getCached<Repository[]>(CacheKeys.repos(user.login)) || [];
if (repos.length > 0) {
const workflows = await fetchAllWorkflowFiles(token, repos);
setWorkflowFiles(workflows);
setCache(CacheKeys.workflowFiles(), workflows);
setCache(CacheKeys.workflowFiles(user.login), workflows);
}
} catch (err) {
console.error('Failed to load workflow files:', err);
Expand Down