Don't explicitly store the video count in the channel object anymore
This commit is contained in:
parent
fa4fec5f81
commit
00d0e6946b
3
main.cpp
3
main.cpp
|
@ -147,7 +147,6 @@ void fetch_videos_for_channel(Channel &channel, bool name_in_title=false)
|
||||||
if(channel.is_virtual) {
|
if(channel.is_virtual) {
|
||||||
std::vector<Video> &channelVideos = videos[channel.id];
|
std::vector<Video> &channelVideos = videos[channel.id];
|
||||||
channelVideos = Video::get_all_with_flag_value(channel.virtual_flag, channel.virtual_flag_value);
|
channelVideos = Video::get_all_with_flag_value(channel.virtual_flag, channel.virtual_flag_value);
|
||||||
channel.video_count = channelVideos.size();
|
|
||||||
for(Video &video: channelVideos) {
|
for(Video &video: channelVideos) {
|
||||||
video.tui_title_width = string_width(video.title);
|
video.tui_title_width = string_width(video.title);
|
||||||
}
|
}
|
||||||
|
@ -191,8 +190,8 @@ void select_channel_by_index(const int index) {
|
||||||
selected_channel = index;
|
selected_channel = index;
|
||||||
const Channel &channel = channels.at(selected_channel);
|
const Channel &channel = channels.at(selected_channel);
|
||||||
selected_video = 0;
|
selected_video = 0;
|
||||||
current_video_count = channel.video_count;
|
|
||||||
load_videos_for_channel(channel, clear_channels_on_change);
|
load_videos_for_channel(channel, clear_channels_on_change);
|
||||||
|
current_video_count = videos[channel.id].size();
|
||||||
clear_channels_on_change = channel.is_virtual;
|
clear_channels_on_change = channel.is_virtual;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
yt.cpp
2
yt.cpp
|
@ -239,7 +239,6 @@ void Channel::fetch_new_videos(sqlite3 *db, progress_info *info, std::optional<s
|
||||||
|
|
||||||
void Channel::load_info(sqlite3 *db)
|
void Channel::load_info(sqlite3 *db)
|
||||||
{
|
{
|
||||||
video_count = 0;
|
|
||||||
unwatched = 0;
|
unwatched = 0;
|
||||||
|
|
||||||
if(is_virtual) {
|
if(is_virtual) {
|
||||||
|
@ -253,7 +252,6 @@ void Channel::load_info(sqlite3 *db)
|
||||||
const int flags = sqlite3_column_int(query, 0);
|
const int flags = sqlite3_column_int(query, 0);
|
||||||
const int count = sqlite3_column_int(query, 1);
|
const int count = sqlite3_column_int(query, 1);
|
||||||
|
|
||||||
video_count += count;
|
|
||||||
if((flags & kWatched) == 0)
|
if((flags & kWatched) == 0)
|
||||||
unwatched += count;
|
unwatched += count;
|
||||||
}
|
}
|
||||||
|
|
1
yt.h
1
yt.h
|
@ -39,7 +39,6 @@ public:
|
||||||
void load_info(sqlite3 *db);
|
void load_info(sqlite3 *db);
|
||||||
bool is_valid() const;
|
bool is_valid() const;
|
||||||
|
|
||||||
unsigned int video_count;
|
|
||||||
unsigned int unwatched;
|
unsigned int unwatched;
|
||||||
private:
|
private:
|
||||||
Channel(const std::string &id, const std::string &name);
|
Channel(const std::string &id, const std::string &name);
|
||||||
|
|
Loading…
Reference in New Issue