Skip to content

Commit

Permalink
[CHORE] Migrate to Watermelon (#1171)
Browse files Browse the repository at this point in the history
* Install

* Create subscriptions

* Subscription observing and sorting

* Saving last message

* Stash

* Stash

* stash

* Stash

* Rooms list listing :)

* Animated set state

* Search working

* Fix load rooms on login

* stash db class

* set active db with path

* Remove db on logout

* stash

* Created updateMessages

* Inserting/updating threads

* Persisting thread messages

* Removed unused list

* Loading messages from watermelon

* Debounce updates and rerender message

* optional fields

* Fix realm conflict issues

* Fix some render issues

* stash

* List mount

* stash

* fix message id

* Fix tmsg

* - Save subscription.rid as id on watermelon and _id as _id
- Send room as param to room view

* Throttle room updates

* stash

* comment removeClippedSubviews

* Fetch thread name

* try/catch updateMessages

* Show loading while RoomView.init is still running

* stash

* Fix updateMessages

* Threads

* Delete message

* Permalink

* Pin

* Star

* Report

* MessageActions refactor

* Edit message

* Reply message

* Add reaction

* Auto translate

* Fix connection issues

* Mark message as error if something happened on the call

* Error actions

* get custom emoji

* Always run console.log when __DEV__

* Try to create serversDB

* Don't call updateMessages. Execute that entire logic for one message id instead.

* Refactor update messages

* ServersDB User [Realm -> Watermelon]

* Fix models

* Custom emojis

* Custom emojis on emoji picker

* Frequently used emojis

* Fix add reaction on message

* stash

* Fix

* Read messages

* Fix thread

* Fetch thread header

* Follow/unfollow thread

* Fix thread

* Upload file

* Thread tweak

* Realm -> Watermelon [Share Extension]

* Add RoomsUpdatedAt to Servers Table

* Settings

* Settings

* Fix logout

* SendFileMessage ServersDB

* ServersDB on serverDropdown

* Remove serversDB from Realm

* Load thread messages

* Delete message

* Improve getSettings

* Improve

* Remove subscription

* Remove update

* Update room via socket

* Small refactor

* Fix logout and improve migration

* Refactor updateMessages

* Improve migration

* Remove unnecessary update

* Revert remove runAfterInteractions

* Fix serverDropdown

* Fix merge

* Init room actions Watermelon

* Room actions Watermelon

* Remove realm on room members

* Room swipe -> Watermelon

* Fix hideChannel

* Get roles watermelon

* Get permissions watermelon

* Users typing + memory db

* Auto translate watermelon

* New Message View

* Selected Users View

* try/catch

* Get Slash Commands watermelon

* Slash Commands message box

* Custom emojis message box

* Get rooms message box

* Room info view

* Room info edit

* Save active users

* Small refactor

* Message Actions

* hasPermission await

* last hasPermission fix

* Active users on redux

* Add user roles

* Users typing on redux and remove memory db

* Fix saga delay

* Fix few issues

* Fix slash commands preview

* Draft message

* Add muted

* Unread count watermelon

* Remove realm

* Fiz RoomItem rerenders

* Remove realm config

* Rerender status update on RoomItem

* Refactor RoomsListView

* Fix load missed messages

* Fix room update

* Message refactor

* Fixing lint

* removeClippedSubviews on iOS only

* Added few interaction managers

* Fix few rerenders

* Fix RoomItem status typo

* Fix RoomView.SCU

* Fix broadcast

* Fix user status on RoomActionsView

* Fix RocketChat.hasPermission

* Fix database inconsistencies

* Fix few update issues

* Add rxjs and remove with observables

* Fix tests

* Remove subscriptions

* Fix RoomsListView SCU

* Change database structure and set all schemas to 1

* Fix RoomsListView search

* Fixed errors, removed rerenders and added animation

* Fixed a few errors

* Fix lint

* Fix issues caught by LGTM

* fix ios build

* Fix load unjoined channel messages

* Log on database path on startup

* Fix join channel

* Remove react-native-realm-path

* Set user status on login.user reducer

* Fix status not rendering on RoomsListView

* Fix few reducers

* Fix users going offline

* Never use "watermelon" term directly. Replaced by "database"

* Fix custom emoji

* Creating room from app must update roomUpdatedAt

* Log subscribeRoom start

* Fix room subscribe right after creating a DM

* Refactor is read only on messages actions

* Fix typo

* Fix typo

* Review

* Fix schema

* Fix muted & freq emoji & unpin & unstar

* Remove throttleTime to room info & fix reset on edit room

* Fix openServerDropdown spec & Fix unarchive

* Fix MessageAction

* Refactor RoomInfoEditView

* Remove unnecessary condition

* Remove unnecessary condition

* Remove unnecessary condition

* Remove get database

* Rename Command.js to SlashCommand.js

* Create sanitizer util

* Fix indentation

* Create subscription.t index

* Refactor queries on RoomsListView

* Create subscription.name index

* Fix getPermissions

* Fix indentation

* Add missing await

* Fix rocketchat.hasPermission

* Unnecessary change

* Star, pin e delete message refactored

* Refactor customEmojis reducer

* Remove code

* Remove logs

* Remove throttle

* Call this.init on foreground focus on RoomView

* Bump servers schema migration

* Always mark message as sent after a success

* Fetch only messages needed on updateMessages

* Just leave a comment for now

* Fetch only subscriptions returned by fetch

* Set room param on RoomView header in find room

* Update kotlin

* Fix auto translate constructor

* Fix few setState on constructor

* Fix empty room image blinking while mounting

* Improve fetch/persist execution for custom emojis, permissions and settings

* Query only user tapped on RoomMembersView

* Fix typo on canOpenRoom
  • Loading branch information
diegolmello committed Sep 16, 2019
1 parent 2d8b1c5 commit 9ba3710
Show file tree
Hide file tree
Showing 127 changed files with 13,752 additions and 12,749 deletions.
26 changes: 0 additions & 26 deletions __mocks__/realm.js

This file was deleted.

2 changes: 2 additions & 0 deletions android/app/build.gradle
@@ -1,4 +1,5 @@
apply plugin: "com.android.application"
apply plugin: 'kotlin-android'
apply plugin: "io.fabric"
apply plugin: "com.google.firebase.firebase-perf"
apply plugin: 'com.bugsnag.android.gradle'
Expand Down Expand Up @@ -204,6 +205,7 @@ android {

dependencies {
addUnimodulesDependencies()
implementation project(':watermelondb')
implementation project(':reactnativenotifications')
implementation project(":reactnativekeyboardinput")
implementation fileTree(dir: "libs", include: ["*.jar"])
Expand Down
Expand Up @@ -31,6 +31,8 @@
import io.invertase.firebase.analytics.RNFirebaseAnalyticsPackage;
import io.invertase.firebase.perf.RNFirebasePerformancePackage;

import com.nozbe.watermelondb.WatermelonDBPackage;

import java.util.Arrays;
import java.util.List;

Expand All @@ -53,6 +55,7 @@ protected List<ReactPackage> getPackages() {
packages.add(new RNFirebasePerformancePackage());
packages.add(new KeyboardInputPackage(MainApplication.this));
packages.add(new RNNotificationsPackage(MainApplication.this));
packages.add(new WatermelonDBPackage());
packages.add(new ModuleRegistryAdapter(mModuleRegistryProvider));
return packages;
}
Expand Down
6 changes: 2 additions & 4 deletions android/build.gradle
Expand Up @@ -6,10 +6,7 @@ buildscript {
compileSdkVersion = 28
targetSdkVersion = 28
glideVersion = "4.9.0"
// googlePlayServicesVersion = "17.0.0"
// supportLibVersion = "1.0.2"
// mediaCompatVersion = '1.0.1'
// supportV4Version = '1.0.0'
kotlin_version = "1.3.50"
}
repositories {
mavenLocal()
Expand All @@ -24,6 +21,7 @@ buildscript {
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.28.1'
classpath 'com.google.firebase:perf-plugin:1.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.bugsnag:bugsnag-android-gradle-plugin:4.+'

// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 2 additions & 0 deletions android/settings.gradle
Expand Up @@ -2,6 +2,8 @@ apply from: '../node_modules/react-native-unimodules/gradle.groovy'
includeUnimodulesProjects()

rootProject.name = 'RocketChatRN'
include ':watermelondb'
project(':watermelondb').projectDir = new File(rootProject.projectDir, '../node_modules/@nozbe/watermelondb/native/android')
include ':reactnativenotifications'
project(':reactnativenotifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/android/app')
include ':reactnativekeyboardinput'
Expand Down
29 changes: 4 additions & 25 deletions app/actions/actionsTypes.js
Expand Up @@ -32,31 +32,7 @@ export const ROOMS = createRequestTypes('ROOMS', [
]);
export const ROOM = createRequestTypes('ROOM', ['LEAVE', 'ERASE', 'USER_TYPING']);
export const APP = createRequestTypes('APP', ['START', 'READY', 'INIT']);
export const MESSAGES = createRequestTypes('MESSAGES', [
...defaultTypes,
'ACTIONS_SHOW',
'ACTIONS_HIDE',
'ERROR_ACTIONS_SHOW',
'ERROR_ACTIONS_HIDE',
'DELETE_REQUEST',
'DELETE_SUCCESS',
'DELETE_FAILURE',
'EDIT_INIT',
'EDIT_CANCEL',
'EDIT_REQUEST',
'EDIT_SUCCESS',
'EDIT_FAILURE',
'TOGGLE_STAR_REQUEST',
'TOGGLE_STAR_SUCCESS',
'TOGGLE_STAR_FAILURE',
'TOGGLE_PIN_REQUEST',
'TOGGLE_PIN_SUCCESS',
'TOGGLE_PIN_FAILURE',
'REPLY_INIT',
'REPLY_CANCEL',
'TOGGLE_REACTION_PICKER',
'REPLY_BROADCAST'
]);
export const MESSAGES = createRequestTypes('MESSAGES', ['REPLY_BROADCAST']);
export const CREATE_CHANNEL = createRequestTypes('CREATE_CHANNEL', [...defaultTypes]);
export const SELECTED_USERS = createRequestTypes('SELECTED_USERS', ['ADD_USER', 'REMOVE_USER', 'RESET', 'SET_LOADING']);
export const SERVER = createRequestTypes('SERVER', [
Expand All @@ -75,3 +51,6 @@ export const SORT_PREFERENCES = createRequestTypes('SORT_PREFERENCES', ['SET_ALL
export const NOTIFICATION = createRequestTypes('NOTIFICATION', ['RECEIVED', 'REMOVE']);
export const TOGGLE_MARKDOWN = 'TOGGLE_MARKDOWN';
export const TOGGLE_CRASH_REPORT = 'TOGGLE_CRASH_REPORT';
export const SET_CUSTOM_EMOJIS = 'SET_CUSTOM_EMOJIS';
export const SET_ACTIVE_USERS = 'SET_ACTIVE_USERS';
export const USERS_TYPING = createRequestTypes('USERS_TYPING', ['ADD', 'REMOVE', 'CLEAR']);
8 changes: 8 additions & 0 deletions app/actions/activeUsers.js
@@ -0,0 +1,8 @@
import { SET_ACTIVE_USERS } from './actionsTypes';

export function setActiveUsers(activeUsers) {
return {
type: SET_ACTIVE_USERS,
activeUsers
};
}
8 changes: 8 additions & 0 deletions app/actions/customEmojis.js
@@ -0,0 +1,8 @@
import * as types from './actionsTypes';

export function setCustomEmojis(emojis) {
return {
type: types.SET_CUSTOM_EMOJIS,
emojis
};
}
138 changes: 0 additions & 138 deletions app/actions/messages.js
@@ -1,143 +1,5 @@
import * as types from './actionsTypes';

export function actionsShow(actionMessage) {
return {
type: types.MESSAGES.ACTIONS_SHOW,
actionMessage
};
}

export function actionsHide() {
return {
type: types.MESSAGES.ACTIONS_HIDE
};
}

export function errorActionsShow(actionMessage) {
return {
type: types.MESSAGES.ERROR_ACTIONS_SHOW,
actionMessage
};
}

export function errorActionsHide() {
return {
type: types.MESSAGES.ERROR_ACTIONS_HIDE
};
}

export function deleteRequest(message) {
return {
type: types.MESSAGES.DELETE_REQUEST,
message
};
}

export function deleteSuccess() {
return {
type: types.MESSAGES.DELETE_SUCCESS
};
}

export function deleteFailure() {
return {
type: types.MESSAGES.DELETE_FAILURE
};
}


export function editInit(message) {
return {
type: types.MESSAGES.EDIT_INIT,
message
};
}

export function editCancel() {
return {
type: types.MESSAGES.EDIT_CANCEL
};
}

export function editRequest(message) {
return {
type: types.MESSAGES.EDIT_REQUEST,
message
};
}

export function editSuccess() {
return {
type: types.MESSAGES.EDIT_SUCCESS
};
}

export function editFailure() {
return {
type: types.MESSAGES.EDIT_FAILURE
};
}

export function toggleStarRequest(message) {
return {
type: types.MESSAGES.TOGGLE_STAR_REQUEST,
message
};
}

export function toggleStarSuccess() {
return {
type: types.MESSAGES.TOGGLE_STAR_SUCCESS
};
}

export function toggleStarFailure() {
return {
type: types.MESSAGES.TOGGLE_STAR_FAILURE
};
}

export function togglePinRequest(message) {
return {
type: types.MESSAGES.TOGGLE_PIN_REQUEST,
message
};
}

export function togglePinSuccess() {
return {
type: types.MESSAGES.TOGGLE_PIN_SUCCESS
};
}

export function togglePinFailure(err) {
return {
type: types.MESSAGES.TOGGLE_PIN_FAILURE,
err
};
}

export function replyInit(message, mention) {
return {
type: types.MESSAGES.REPLY_INIT,
message,
mention
};
}

export function replyCancel() {
return {
type: types.MESSAGES.REPLY_CANCEL
};
}

export function toggleReactionPicker(message) {
return {
type: types.MESSAGES.TOGGLE_REACTION_PICKER,
message
};
}

export function replyBroadcast(message) {
return {
type: types.MESSAGES.REPLY_BROADCAST,
Expand Down
21 changes: 21 additions & 0 deletions app/actions/usersTyping.js
@@ -0,0 +1,21 @@
import { USERS_TYPING } from './actionsTypes';

export function addUserTyping(username) {
return {
type: USERS_TYPING.ADD,
username
};
}

export function removeUserTyping(username) {
return {
type: USERS_TYPING.REMOVE,
username
};
}

export function clearUserTyping() {
return {
type: USERS_TYPING.CLEAR
};
}

0 comments on commit 9ba3710

Please sign in to comment.