Unverified Commit 5c974990 authored by Djorkaeff Alexandre's avatar Djorkaeff Alexandre Committed by GitHub
Browse files

[FIX] Join Room (#1769)


Co-authored-by: default avatarDiego Mello <diegolmello@gmail.com>
parent 9220f9e9
import {
select, put, call, take, takeLatest
} from 'redux-saga/effects';
import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord';
import { CREATE_CHANNEL, LOGIN } from '../actions/actionsTypes';
import { createChannelSuccess, createChannelFailure } from '../actions/createChannel';
import RocketChat from '../lib/rocketchat';
import database from '../lib/database';
const create = function* create(data) {
return yield RocketChat.createChannel(data);
......@@ -16,8 +18,22 @@ const handleRequest = function* handleRequest({ data }) {
if (!auth) {
yield take(LOGIN.SUCCESS);
}
const result = yield call(create, data);
yield put(createChannelSuccess(result));
const sub = yield call(create, data);
try {
const db = database.active;
const subCollection = db.collections.get('subscriptions');
yield db.action(async() => {
await subCollection.create((s) => {
s._raw = sanitizedRaw({ id: sub.rid }, subCollection.schema);
Object.assign(s, sub);
});
});
} catch {
// do nothing
}
yield put(createChannelSuccess(sub));
} catch (err) {
yield put(createChannelFailure(err));
}
......
......@@ -372,8 +372,9 @@ class RoomView extends React.Component {
if (this.t !== 'd') {
console.log('Room not found');
this.internalSetState({ joined: false });
} else if (this.rid) {
// We navigate to RoomView before the DM is inserted to the local db
}
if (this.rid) {
// We navigate to RoomView before the Room is inserted to the local db
// So we retry just to make sure we have the right content
this.retryFindCount = this.retryFindCount + 1 || 1;
if (this.retryFindCount <= 3) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment