Compare commits

..

No commits in common. "48b4f9cda8d8139eaf4011fe3e6289af938ec841" and "fe9735fe58ad9777832ee0e722efa5a267bd3aa9" have entirely different histories.

3 changed files with 9 additions and 15 deletions

View File

@ -7,6 +7,8 @@
#include <cstring>
#include <curses.h>
#include <cwchar>
#include <fstream>
#include <iostream>
#include <menu.h>
#include <nlohmann/json.hpp>
#include <string>
@ -21,18 +23,14 @@ std::vector<allocation> komens_allocated;
void insert_content(WINDOW *content_window, size_t i, json &resp_from_api);
void komens_page(koment_type type) {
void komens_page() {
current_allocated = &komens_allocated;
json resp_from_api;
{
/*std::ifstream f("test-data/komens.json");
resp_from_api = json::parse(f);
f.close();*/
const char *types[] = {"/api/3/komens/messages/received",
"/api/3/komens/messages/sent",
"/api/3/komens/messages/noticeboard"};
const std::string endpoint = types[type];
const std::string endpoint = "/api/3/komens/messages/received";
resp_from_api = bakaapi::get_data_from_endpoint(endpoint, POST);
}
@ -96,7 +94,7 @@ void komens_page(koment_type type) {
komens_items[i] = new_item(title_bufs[i], name_bufs[i]);
}
max_item_lenght = 3 + max_title_lenght + 1 + max_name_lenght;
max_item_lenght = max_title_lenght + max_name_lenght;
}
komens_items[num_of_komens] = nullptr;

View File

@ -1,9 +1,4 @@
#ifndef _ba_ko_hg_
#define _ba_ko_hg_
enum koment_type {
RECEIVED,
SEND,
NOTICEBOARD,
};
void komens_page(koment_type type);
void komens_page();
#endif

View File

@ -9,8 +9,9 @@
void komens_menu() {
wchar_t *choices[] = {
L"received", L"sent", L"noticeboard", L"Exit", nullptr,
L"received", L"send", L"noticeboard", L"Exit", nullptr,
};
void (*choicesFuncs[])() = {komens_page, nullptr, nullptr, nullptr, nullptr};
ITEM **my_items;
int c;
@ -87,7 +88,7 @@ void komens_menu() {
if (item_index(current_item(my_menu)) == n_choices - 1) {
goto close_menu;
}
komens_page(static_cast<koment_type>(item_index(current_item(my_menu))));
choicesFuncs[item_index(current_item(my_menu))]();
pos_menu_cursor(my_menu);
refresh();
wrefresh(my_menu_win);