use crate::fetch::discovery::DiscoveredFeed;
use crate::store::models::{Entry, Feed, Group};

#[derive(Debug, Clone)]
pub enum Action {
    LoadFeeds,
    LoadEntriesFiltered {
        feed_id: i64,
        unread_only: bool,
        saved_only: bool,
        since: Option<i64>,
    },
    LoadAllEntries {
        unread_only: bool,
        saved_only: bool,
        since: Option<i64>,
    },
    LoadEntriesForGroup {
        group_id: Option<i64>,
        unread_only: bool,
        saved_only: bool,
        since: Option<i64>,
    },
    RefreshFeeds,
    RefreshFeed(i64),
    RefreshFeedsByGroup(Option<i64>),
    RefreshUnreadCounts,
    FeedsLoaded(Vec<Feed>),
    EntriesLoaded(Vec<Entry>),
    EntriesMerged(Vec<Entry>),
    SelectFeed(Option<i64>),
    SelectEntry(Option<i64>),
    FocusEntries,
    FocusPreview,
    FocusFeeds,
    AddFeed {
        title: Option<String>,
        url: String,
        group_id: Option<i64>,
    },
    DeleteFeed(i64),
    RenameFeed {
        id: i64,
        title: Option<String>,
    },
    MarkRead(i64),
    MarkUnread(i64),
    MarkAllRead(Vec<i64>),
    MarkAllUnread(Vec<i64>),
    MarkFeedRead(i64),
    MarkSaved(i64),
    MarkUnsaved(i64),
    MarkAllSaved(Vec<i64>),
    MarkAllUnsaved(Vec<i64>),
    ToggleUnreadFilter,
    ToggleSavedFilter,
    SetSearchQuery(String),
    MoveUp,
    MoveDown,
    PageUp,
    PageDown,
    ScrollTop,
    ScrollBottom,
    UpdateUnreadCounts(Vec<(i64, i64)>),
    UpdateTotalUnread(i64),
    SetStatus(String),
    ClearStatus,
    DbError(String),
    LoadGroups,
    GroupsLoaded(Vec<Group>),
    AddGroup {
        name: String,
    },
    DeleteGroup(i64),
    RenameGroup {
        id: i64,
        name: String,
    },
    AssignFeedToGroup {
        feed_id: i64,
        group_id: Option<i64>,
    },
    SwapGroupOrder {
        id_a: i64,
        id_b: i64,
    },
    ToggleGroupCollapse(i64),
    ResizePanel(i8),
    ToggleLayout,
    UpdateTotalEntryCount(i64),
    AddDiscoveredFeed {
        url: String,
        group_id: Option<i64>,
    },
    DiscoveryResult {
        feeds: Vec<DiscoveredFeed>,
        group_id: Option<i64>,
    },
}
