/[LeafOK_CVS]/lbbs/src/section_list_display.c
ViewVC logotype

Diff of /lbbs/src/section_list_display.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.29 by sysadm, Mon Jun 16 14:30:44 2025 UTC Revision 1.30 by sysadm, Tue Jun 17 02:22:45 2025 UTC
# Line 40  enum select_cmd_t Line 40  enum select_cmd_t
40          EXIT_SECTION = 0,          EXIT_SECTION = 0,
41          VIEW_ARTICLE = 1,          VIEW_ARTICLE = 1,
42          CHANGE_PAGE = 2,          CHANGE_PAGE = 2,
43          REFRESH_SCREEN = 3,          SHOW_HELP = 3,
44          CHANGE_NAME_DISPLAY = 4,          CHANGE_NAME_DISPLAY = 4,
45          POST_ARTICLE = 5,          POST_ARTICLE = 5,
46          EDIT_ARTICLE = 6,          EDIT_ARTICLE = 6,
47          DELETE_ARTICLE = 7,          DELETE_ARTICLE = 7,
         SHOW_HELP = 8,  
48  };  };
49    
50  static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname)  static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname)
# Line 165  static enum select_cmd_t section_list_se Line 164  static enum select_cmd_t section_list_se
164          int old_page_id = *p_page_id;          int old_page_id = *p_page_id;
165          int old_selected_index = *p_selected_index;          int old_selected_index = *p_selected_index;
166          int ch;          int ch;
167            time_t last_refresh_tm = time(NULL);
         BBS_last_access_tm = time(0);  
168    
169          if (item_count > 0 && *p_selected_index >= 0)          if (item_count > 0 && *p_selected_index >= 0)
170          {          {
# Line 181  static enum select_cmd_t section_list_se Line 179  static enum select_cmd_t section_list_se
179    
180                  switch (ch)                  switch (ch)
181                  {                  {
                 case KEY_NULL: // broken pipe  
182                  case KEY_ESC:                  case KEY_ESC:
183                  case KEY_LEFT:                  case KEY_LEFT:
184                            BBS_last_access_tm = time(NULL);
185                    case KEY_NULL:                   // broken pipe
186                          return EXIT_SECTION; // exit section                          return EXIT_SECTION; // exit section
187                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
188                          if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)
189                          {                          {
190                                  return EXIT_SECTION; // exit section                                  return EXIT_SECTION; // exit section
191                          }                          }
192                          continue;                          continue;
193                  case 'n':                  case 'n':
194                            BBS_last_access_tm = time(NULL);
195                          return CHANGE_NAME_DISPLAY;                          return CHANGE_NAME_DISPLAY;
196                  case CR:                  case CR:
197                          igetch_reset();                          igetch_reset();
# Line 199  static enum select_cmd_t section_list_se Line 199  static enum select_cmd_t section_list_se
199                  case KEY_RIGHT:                  case KEY_RIGHT:
200                          if (item_count > 0)                          if (item_count > 0)
201                          {                          {
202                                    BBS_last_access_tm = time(NULL);
203                                  return VIEW_ARTICLE;                                  return VIEW_ARTICLE;
204                          }                          }
205                          break;                          break;
# Line 286  static enum select_cmd_t section_list_se Line 287  static enum select_cmd_t section_list_se
287                          old_selected_index = *p_selected_index;                          old_selected_index = *p_selected_index;
288                  }                  }
289    
290                  BBS_last_access_tm = time(0);                  BBS_last_access_tm = time(NULL);
291                    if (BBS_last_access_tm - last_refresh_tm >= BBS_section_list_load_interval)
292                    {
293                            return CHANGE_PAGE; // force section list refresh
294                    }
295          }          }
296    
297          return EXIT_SECTION;          return EXIT_SECTION;
# Line 596  int section_list_display(const char *sna Line 601  int section_list_display(const char *sna
601    
602                          // Update current topic                          // Update current topic
603                          section_topic_view_tid = (p_articles[selected_index]->tid == 0 ? p_articles[selected_index]->aid : p_articles[selected_index]->tid);                          section_topic_view_tid = (p_articles[selected_index]->tid == 0 ? p_articles[selected_index]->aid : p_articles[selected_index]->tid);
                 case REFRESH_SCREEN:  
                         if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)  
                         {  
                                 log_error("section_list_draw_screen() error\n");  
                                 return -2;  
                         }  
                         break;  
604                  case CHANGE_NAME_DISPLAY:                  case CHANGE_NAME_DISPLAY:
605                          display_nickname = !display_nickname;                          display_nickname = !display_nickname;
606                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
# Line 612  int section_list_display(const char *sna Line 610  int section_list_display(const char *sna
610                          }                          }
611                          break;                          break;
612                  case POST_ARTICLE:                  case POST_ARTICLE:
613                          ret = article_post(p_section, &article_new);                          if ((ret = article_post(p_section, &article_new)) < 0)
                         if (ret < 0)  
614                          {                          {
615                                  log_error("article_post(sid=%d) error\n", p_section->sid);                                  log_error("article_post(sid=%d) error\n", p_section->sid);
616                          }                          }
# Line 654  int section_list_display(const char *sna Line 651  int section_list_display(const char *sna
651                          {                          {
652                                  break; // No permission                                  break; // No permission
653                          }                          }
654                          if (article_del(p_section, p_articles[selected_index]) < 0)                          if ((ret = article_del(p_section, p_articles[selected_index])) < 0)
655                          {                          {
656                                  log_error("article_del(aid=%d) error\n", p_articles[selected_index]->aid);                                  log_error("article_del(aid=%d) error\n", p_articles[selected_index]->aid);
657                          }                          }
658                            else if (ret > 0) // Article deleted
659                            {
660                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count);
661                                    if (ret < 0)
662                                    {
663                                            log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
664                                            return -3;
665                                    }
666                            }
667                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
668                          {                          {
669                                  log_error("section_list_draw_screen() error\n");                                  log_error("section_list_draw_screen() error\n");


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1