[FIX] Join Room (#1769)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
9220f9e9e4
commit
5c974990ba
|
@ -1,10 +1,12 @@
|
|||
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) {
|
||||
|
|
Loading…
Reference in New Issue