1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2025-09-06 02:32:44 +00:00

WIP: Experimenting with Lager for Redux like implementation

This commit is contained in:
Chris Josten 2021-03-23 02:13:56 +01:00
parent b9b08ab384
commit 1f09650721
14 changed files with 465 additions and 17 deletions

View file

@ -0,0 +1,41 @@
/*
Sailfin: a Jellyfin client written using Qt
Copyright (C) 2021 Chris Josten
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef JELLYFIN_LIBRARY_ACTIONS_H
#define JELLYFIN_LIBRARY_ACTIONS_H
#include <string>
#include <variant>
namespace Jellyfin {
namespace Library {
struct fetchItem {
std::string itemId;
};
struct fetchItemChildren {
std::string parentItemId;
};
using Action = std::variant<fetchItem, fetchItemChildren>;
} // NS Library
} // NS Jellyfin
#endif //JELLYFIN_LIBRARY_ACTIONS_H

View file

@ -0,0 +1,41 @@
/*
Sailfin: a Jellyfin client written using Qt
Copyright (C) 2021 Chris Josten
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef JELLYFIN_LIBRARY_REDUCER_H
#define JELLYFIN_LIBRARY_REDUCER_H
#include <utility>
#include <lager/context.hpp>
#include <lager/util.hpp>
#include "actions.h"
#include "store.h"
namespace Jellyfin {
namespace Library {
using ItemListResult = std::pair<ItemListStore, lager::effect<Action>>;
ItemListResult update(ItemListStore store, Action action);
}
}
#endif // JELLYFIN_LIBRARY_REDUCER_H

View file

@ -0,0 +1,46 @@
/*
* Sailfin: a Jellyfin client written using Qt
* Copyright (C) 2021 Chris Josten and the Sailfin Contributors.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef JELLYFIN_LIBRARY_STORE_H
#define JELLYFIN_LIBRARY_STORE_H
#include <string>
#include <immer/map.hpp>
#include "../DTO/baseitemdto.h"
namespace Jellyfin {
namespace Library {
/**
* @brief Stores information about one Jellyfin Item.
*/
struct ItemStore {
std::string id;
std::string name;
};
struct ItemListStore {
immer::map<std::string, ItemStore> itemList;
};
}
}
#endif // JELLYFIN_LIBRARY_STORE_H

View file

@ -0,0 +1,39 @@
/*
* Sailfin: a Jellyfin client written using Qt
* Copyright (C) 2021 Chris Josten and the Sailfin Contributors.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef JELLYFIN_NETWORK_ACTIONS_H
#define JELLYFIN_NETWORK_ACTIONS_H
#include <variant>
#include "reducer.h"
namespace Jellyfin {
namespace Network {
struct makeRequest {
};
using Action = std::variant<makeRequest, int>;
} // NS Network
} // NS Jellyfin
#endif // JELLYFIN_NETWORK_ACTIONS_H

View file

@ -0,0 +1,44 @@
/*
* Sailfin: a Jellyfin client written using Qt
* Copyright (C) 2021 Chris Josten and the Sailfin Contributors.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef JELLYFIN_NETWORK_NETWORKREQUEST_H
#define JELLYFIN_NETWORK_NETWORKREQUEST_H
#include <string>
namespace Jellyfin {
namespace Network {
enum HttpMethod {
GET,
PUT,
POST,
DELETE
};
struct NetworkRequest {
std::string url;
HttpMethod method;
};
} // NS Network
} // NS Jellyfin
#endif // JELLYFIN_NETWORK_NETWORKREQUEST_H

View file

@ -0,0 +1,32 @@
/*
* Sailfin: a Jellyfin client written using Qt
* Copyright (C) 2021 Chris Josten and the Sailfin Contributors.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef JELLYFIN_NETWORK_REDUCER_H
#define JELLYFIN_NETWORK_REDUCER_H
namespace Jellyfin {
namespace Network {
} // NS Network
} // NS Jellyfin
#endif // JELLYFIN_NETWORK_REDUCER_H

View file

@ -0,0 +1,38 @@
/*
* Sailfin: a Jellyfin client written using Qt
* Copyright (C) 2021 Chris Josten and the Sailfin Contributors.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef JELLYFIN_NETWORK_STORE_H
#define JELLYFIN_NETWORK_STORE_H
#include <string>
#include "networkrequest.h"
namespace Jellyfin {
namespace Network {
struct NetworkRequestStore {
};
} // NS Network
} // NS Jellyfin
#endif // JELLYFIN_NETWORK_STORE_H

View file

@ -0,0 +1,40 @@
/*
* Sailfin: a Jellyfin client written using Qt
* Copyright (C) 2021 Chris Josten and the Sailfin Contributors.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef JELLYFIN_NETWORK_STORE_H
#define JELLYFIN_NETWORK_STORE_H
#include <string>
#include <immer/vector.hpp>
#include "networkrequest.h"
namespace Jellyfin {
namespace Network {
struct NetworkRequestStore {
immer::vector
};
} // NS Network
} // NS Jellyfin
#endif // JELLYFIN_NETWORK_STORE_H