mirror of
https://github.com/HenkKalkwater/harbour-sailfin.git
synced 2025-09-06 10:32:44 +00:00
WIP: Experimenting with Lager for Redux like implementation
This commit is contained in:
parent
b9b08ab384
commit
1f09650721
14 changed files with 465 additions and 17 deletions
41
core/include/JellyfinQt/library/actions.h
Normal file
41
core/include/JellyfinQt/library/actions.h
Normal 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
|
41
core/include/JellyfinQt/library/reducer.h
Normal file
41
core/include/JellyfinQt/library/reducer.h
Normal 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
|
46
core/include/JellyfinQt/library/store.h
Normal file
46
core/include/JellyfinQt/library/store.h
Normal 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
|
39
core/include/JellyfinQt/network/actions.h
Normal file
39
core/include/JellyfinQt/network/actions.h
Normal 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
|
44
core/include/JellyfinQt/network/networkrequest.h
Normal file
44
core/include/JellyfinQt/network/networkrequest.h
Normal 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
|
32
core/include/JellyfinQt/network/reducer.h
Normal file
32
core/include/JellyfinQt/network/reducer.h
Normal 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
|
38
core/include/JellyfinQt/network/store.h
Normal file
38
core/include/JellyfinQt/network/store.h
Normal 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
|
40
core/include/JellyfinQt/network/store.h.autosave
Normal file
40
core/include/JellyfinQt/network/store.h.autosave
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue