Skip to content

Commit

Permalink
added paging
Browse files Browse the repository at this point in the history
  • Loading branch information
aNaOH committed Jan 1, 2024
1 parent 3e66f16 commit 064ea40
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ Currently supports:
**TODO**

- Upload mods
- Paging

## How to use

var modio = ModIO.new()
modio.connect(api_key, game_id)
var mods = modio.get_mods(query)
var mods = modio.get_mods(query, page, per_page)
get_mods() returns an array of dictioraries, the dictionary is formed by:

- id
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ impl ModIO {
self.client.is_some()
}

async fn get_mods_async_inner(&self, query: GString, tags: GString) -> Option<Array<Dictionary>> {
async fn get_mods_async_inner(&self, query: GString, tags: GString, per_page: usize, page: usize) -> Option<Array<Dictionary>> {
if let Some(ref client) = self.client {
// Example: Get mods (replace with your actual parameters)
let mut f = Filter::default();
let mut f = Filter::default().and(with_limit(per_page).offset(per_page*page));

if query != "".into() {
f = Fulltext::eq(query).and(Tags::_in(tags));
Expand Down Expand Up @@ -200,11 +200,11 @@ impl ModIO {

// Función #[func] que invoca la función asíncrona intermedia
#[func]
fn get_mods(&self, query: GString) -> Array<Dictionary> {
fn get_mods(&self, query: GString, page: u16, per_page: u16) -> Array<Dictionary> {

// Crear una nueva tarea y ejecutarla
let result = async {
match self.get_mods_async_inner(query, "".into()).await {
match self.get_mods_async_inner(query, "".into(), per_page.into(), page.into()).await {
Some(mods) => {
// Imprimir información sobre los mods
godot_print!("Mods found");
Expand Down

0 comments on commit 064ea40

Please sign in to comment.