base_page: Finish notifs or call directly
FossilOrigin-Name: 940805ebcea555253f5b98a7cb108c56cbb428a1796cd9bd2257db351c4eb33e
This commit is contained in:
parent
519941f54a
commit
a08a43e7dc
2 changed files with 33 additions and 4 deletions
|
@ -58,8 +58,16 @@ request_cb_base_page(mstdnt_request_cb_data* cb_data,
|
|||
void* args)
|
||||
{
|
||||
struct mstdnt_notifications* notifs = MSTDNT_CB_DATA(cb_data);
|
||||
struct path_args_data* path_data = args;
|
||||
|
||||
|
||||
// ->data is the page data
|
||||
_render_base_page(path_data->data,
|
||||
path_data->req,
|
||||
path_data->ssn,
|
||||
notifs);
|
||||
|
||||
path_args_data_destroy(path_data);
|
||||
return MSTDNT_REQUEST_DONE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -76,10 +84,13 @@ render_base_page(struct base_page* page,
|
|||
keystr(ssn->cookies.access_token) &&
|
||||
!ssn->config.notif_embed)
|
||||
{
|
||||
struct path_args_data* path_data =
|
||||
path_args_data_create(req, ssn, api, page);
|
||||
|
||||
mstdnt_get_notifications(
|
||||
api,
|
||||
&m_args,
|
||||
request_cb_base_page, NULL,
|
||||
request_cb_base_page, path_data,
|
||||
(struct mstdnt_notifications_args)
|
||||
{
|
||||
.exclude_types = 0,
|
||||
|
@ -95,7 +106,9 @@ render_base_page(struct base_page* page,
|
|||
});
|
||||
}
|
||||
else {
|
||||
|
||||
// Render it as is, if IFrame is disabled
|
||||
// TODO might get account data at this point
|
||||
_render_base_page(page, req, ssn, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
18
src/path.h
18
src/path.h
|
@ -31,12 +31,28 @@ struct path_args_data
|
|||
void* data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Allocates a path_args_data struct.
|
||||
*
|
||||
* Used for mastodont-c callbacks essentially.
|
||||
*
|
||||
* @param req Request.
|
||||
* @param ssn Session data.
|
||||
* @param api API data. Usually a reference.
|
||||
* @param data Any custom data, must be manually free'd
|
||||
* @return Allocated struct, or NULL on error. Free with path_args_data_destroy
|
||||
*/
|
||||
struct path_args_data* path_args_data_create(REQUEST_T req,
|
||||
struct session* ssn,
|
||||
mastodont_t* api,
|
||||
void* data);
|
||||
|
||||
void path_args_ref_destroy(struct path_args_data* refs);
|
||||
/**
|
||||
* Destroys the path args and struct created by @struct path_args_data_create
|
||||
*
|
||||
* @param ref To be destroyed.
|
||||
*/
|
||||
void path_args_data_destroy(struct path_args_data* ref);
|
||||
|
||||
int handle_paths(
|
||||
REQUEST_T req,
|
||||
|
|
Loading…
Reference in a new issue