Refactor PollHandler

Refactor PollHandler to make it more reliable. This ended up with much more code than I expected as the original intent was just to stop a crash when switching rooms.
- Using a event string was flaky, changing to using an event reference is more reliable.
- Since we're only creating them from NeoChatRoom there is no need to to be able to set properties from QML so only read properties.
- Pass from the MessageEventModel rather than an invokable method.
- Create a basic test suite
- Create properties in PollHandler to remove the need to use content in PollDelegate, this means content is no longer a required role.
This commit is contained in:
James Graham
2024-01-02 21:22:08 +00:00
parent 7ad362225f
commit 356e8eefe0
10 changed files with 259 additions and 116 deletions

View File

@@ -14,6 +14,7 @@
#include <Quotient/user.h>
#include "enums/pushrule.h"
#include "events/pollevent.h"
#include "pollhandler.h"
namespace Quotient
@@ -733,7 +734,14 @@ public:
*
* @sa PollHandler
*/
Q_INVOKABLE PollHandler *poll(const QString &eventId);
PollHandler *poll(const QString &eventId) const;
/**
* @brief Create a PollHandler object for the given event.
*
* @sa PollHandler
*/
void createPollHandler(const Quotient::PollStartEvent *event);
/**
* @brief Get the full Json data for a given room account data event.