Skip to content
Snippets Groups Projects
Commit 4a27b977 authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Add invites to initial sync

parent 6addc8e4
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,7 @@ int main(int argc, char *argv[]) {
Sync sync(rooms, &login);
QObject::connect(&login, &Login::loginSuccess, &sync, &Sync::startSync);
QObject::connect(&sync, &Sync::newRoom, &rooms, &RoomModel::addRoom, Qt::QueuedConnection);
QObject::connect(&sync, &Sync::newInvite, &rooms, &RoomModel::addInvite, Qt::QueuedConnection);
QSharedPointer<Room> a = QSharedPointer<Room>(new Room);
a->tag = "group";
......@@ -60,7 +61,7 @@ int main(int argc, char *argv[]) {
i->lastMessage = "Hey, Nico hier!";
i->unreadNotifications = 3;
i->name = "Example invite";
rooms.addRoom(i);
rooms.addInvite(i);
v->rootContext()->setContextProperty("rooms", &rooms);
// If you wish to publish your app on the Jolla harbour, it is recommended
......
......@@ -10,7 +10,7 @@
struct Room {
std::string name, lastMessage, picture, tag;
int unreadNotifications;
int unreadNotifications = 0;
};
class RoomModel : public QAbstractListModel {
......
......@@ -17,10 +17,10 @@ void Sync::startSync() {
for (const std::pair<std::string, mtx::responses::JoinedRoom> &join : res.rooms.join) {
const mtx::responses::JoinedRoom &r = join.second;
QSharedPointer<Room> room = QSharedPointer<Room>(new Room);
room->name = join.first;
qDebug() << QString::fromStdString(room->name);
// room.picture = r.avatar();
......@@ -28,5 +28,16 @@ void Sync::startSync() {
room->unreadNotifications = r.unread_notifications.highlight_count;
emit newRoom(room);
}
for (const std::pair<std::string, mtx::responses::InvitedRoom> &invite : res.rooms.invite) {
const mtx::responses::InvitedRoom &r = invite.second;
QSharedPointer<Room> room = QSharedPointer<Room>(new Room);
room->name = invite.first;
room->tag = "invite";
qDebug() << QString::fromStdString(room->name);
emit newInvite(room);
}
});
}
......@@ -15,6 +15,7 @@ class Sync : public QObject {
signals:
void newRoom(QSharedPointer<Room> room);
void newInvite(QSharedPointer<Room> room);
private:
RoomModel &rooms;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment