Skip to content

refactor: Abstract display blocks with self-contained data fetching and rendering #21

@unhappychoice

Description

@unhappychoice

Summary

Refactor the codebase to encapsulate each display block so that it can declare required resources and render its own output.

Current State

  • Data fetching is centralized in SteamClient
  • Display rendering is handled separately in display.rs
  • Adding new blocks requires changes in multiple places

Proposed Design

Each display block should:

  • Declare what resources it needs (not fetch directly)
  • Render its own output using fetched resources
// Example concept
enum Resource {
    Player,
    OwnedGames,
    Achievements,
    SteamLevel,
    RecentlyPlayed,
}

trait DisplayBlock {
    fn required_resources(&self) -> Vec<Resource>;
    fn render(&self, resources: &ResourceStore) -> Vec<String>;
}

// Fetcher collects all required resources from blocks,
// deduplicates, and fetches them once
struct ResourceFetcher { ... }

Benefits

  • Shared resources (e.g., OwnedGames) fetched only once
  • Easier to add/remove/reorder display blocks
  • Better separation of concerns
  • Each block can manage its own caching strategy
  • More testable components

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions