Merge branch 'develop' into beta

This commit is contained in:
diegolmello 2019-06-17 11:39:23 -03:00
commit 10042f7cc2
14 changed files with 376 additions and 223 deletions

View File

@ -58,6 +58,7 @@ export const SERVER = createRequestTypes('SERVER', [
...defaultTypes, ...defaultTypes,
'SELECT_SUCCESS', 'SELECT_SUCCESS',
'SELECT_REQUEST', 'SELECT_REQUEST',
'SELECT_FAILURE',
'INIT_ADD', 'INIT_ADD',
'FINISH_ADD' 'FINISH_ADD'
]); ]);

View File

@ -17,6 +17,12 @@ export function selectServerSuccess(server, version) {
}; };
} }
export function selectServerFailure() {
return {
type: SERVER.SELECT_FAILURE
};
}
export function serverRequest(server) { export function serverRequest(server) {
return { return {
type: SERVER.REQUEST, type: SERVER.REQUEST,

View File

@ -81,6 +81,7 @@ export default {
Add_Reaction: 'Reaktion hinzufügen', Add_Reaction: 'Reaktion hinzufügen',
Add_Server: 'Server hinzufügen', Add_Server: 'Server hinzufügen',
Add_user: 'Nutzer hinzufügen', Add_user: 'Nutzer hinzufügen',
Admin_Panel: 'Admin Panel',
Alert: 'Warnen', Alert: 'Warnen',
alert: 'warnen', alert: 'warnen',
alerts: 'Warnungen', alerts: 'Warnungen',
@ -124,7 +125,9 @@ export default {
Connect: 'Verbinden', Connect: 'Verbinden',
Connect_to_a_server: 'Verbinden Sie sich mit einem Server', Connect_to_a_server: 'Verbinden Sie sich mit einem Server',
Connected: 'Verbunden', Connected: 'Verbunden',
connecting_server: 'verbinde zum Server',
Connecting: 'Verbinden ...', Connecting: 'Verbinden ...',
Contact_us: 'Kontaktiere uns',
Continue_with: 'Weitermachen mit', Continue_with: 'Weitermachen mit',
Copied_to_clipboard: 'In die Zwischenablage kopiert!', Copied_to_clipboard: 'In die Zwischenablage kopiert!',
Copy: 'Kopieren', Copy: 'Kopieren',
@ -140,24 +143,29 @@ export default {
DELETE: 'LÖSCHEN', DELETE: 'LÖSCHEN',
description: 'Beschreibung', description: 'Beschreibung',
Description: 'Beschreibung', Description: 'Beschreibung',
Disable_notifications: 'Benachrichtigungen ausschalten', Directory: 'Verzeichnis',
Direct_Messages: 'Direkte Nachrichten', Direct_Messages: 'Direkte Nachrichten',
Disable_notifications: 'Benachrichtigungen deaktiveren',
Discussions: 'Diskussionen',
Dont_Have_An_Account: 'Sie haben noch kein Konto?', Dont_Have_An_Account: 'Sie haben noch kein Konto?',
Do_you_really_want_to_key_this_room_question_mark: 'Möchten Sie diesen Raum wirklich {{key}}?', Do_you_really_want_to_key_this_room_question_mark: 'Möchten Sie diesen Raum wirklich {{key}}?',
edit: 'bearbeiten', edit: 'bearbeiten',
erasing_room: 'Raum löschen', edited: 'bearbeitet',
Edit: 'Bearbeiten', Edit: 'Bearbeiten',
Email_or_password_field_is_empty: 'Das E-Mail- oder Passwortfeld ist leer', Email_or_password_field_is_empty: 'Das E-Mail- oder Passwortfeld ist leer',
Email: 'Email', Email: 'Email',
email: 'Email', email: 'Email',
Enable_markdown: 'Markdown aktivieren',
Enable_notifications: 'Benachrichtigungen aktivieren', Enable_notifications: 'Benachrichtigungen aktivieren',
Everyone_can_access_this_channel: 'Jeder kann auf diesen Kanal zugreifen', Everyone_can_access_this_channel: 'Jeder kann auf diesen Kanal zugreifen',
erasing_room: 'lösche Raum',
Error_uploading: 'Fehler beim Hochladen', Error_uploading: 'Fehler beim Hochladen',
Favorites: 'Favoriten', Favorites: 'Favoriten',
Files: 'Dateien', Files: 'Dateien',
File_description: 'Dateibeschreibung', File_description: 'Dateibeschreibung',
File_name: 'Dateiname', File_name: 'Dateiname',
Finish_recording: 'Beenden Sie die Aufnahme', Finish_recording: 'Beenden Sie die Aufnahme',
Following_thread: 'Thread folgen',
For_your_security_you_must_enter_your_current_password_to_continue: 'Zu Ihrer Sicherheit müssen Sie Ihr aktuelles Passwort eingeben, um fortzufahren', For_your_security_you_must_enter_your_current_password_to_continue: 'Zu Ihrer Sicherheit müssen Sie Ihr aktuelles Passwort eingeben, um fortzufahren',
Forgot_my_password: 'Ich habe mein Passwort vergessen', Forgot_my_password: 'Ich habe mein Passwort vergessen',
Forgot_password_If_this_email_is_registered: 'Wenn diese E-Mail registriert ist, senden wir Anweisungen zum Zurücksetzen Ihres Passworts. Wenn Sie in Kürze keine E-Mail erhalten, kommen Sie bitte zurück und versuchen Sie es erneut.', Forgot_password_If_this_email_is_registered: 'Wenn diese E-Mail registriert ist, senden wir Anweisungen zum Zurücksetzen Ihres Passworts. Wenn Sie in Kürze keine E-Mail erhalten, kommen Sie bitte zurück und versuchen Sie es erneut.',
@ -166,6 +174,7 @@ export default {
Group_by_favorites: 'Nach Favoriten gruppieren', Group_by_favorites: 'Nach Favoriten gruppieren',
Group_by_type: 'Gruppieren nach Typ', Group_by_type: 'Gruppieren nach Typ',
Has_joined_the_channel: 'Ist dem Kanal beigetreten', Has_joined_the_channel: 'Ist dem Kanal beigetreten',
Has_joined_the_conversation: 'Hat sich dem Gespräch angeschlossen',
Has_left_the_channel: 'Hat den Kanal verlassen', Has_left_the_channel: 'Hat den Kanal verlassen',
Invisible: 'Unsichtbar', Invisible: 'Unsichtbar',
Invite: 'Einladen', Invite: 'Einladen',
@ -182,6 +191,7 @@ export default {
leaving_room: 'Raum verlassen', leaving_room: 'Raum verlassen',
leave: 'verlassen', leave: 'verlassen',
Legal: 'Rechtliches', Legal: 'Rechtliches',
License: 'Lizenz',
Livechat: 'Live-Chat', Livechat: 'Live-Chat',
Login: 'Anmeldung', Login: 'Anmeldung',
Login_error: 'Ihre Referenzen wurden abgelehnt! Bitte versuche es erneut.', Login_error: 'Ihre Referenzen wurden abgelehnt! Bitte versuche es erneut.',
@ -196,7 +206,10 @@ export default {
Message_actions: 'Nachrichtenaktionen', Message_actions: 'Nachrichtenaktionen',
Message_pinned: 'Eine Nachricht wurde angeheftet', Message_pinned: 'Eine Nachricht wurde angeheftet',
Message_removed: 'Nachricht entfernt', Message_removed: 'Nachricht entfernt',
message: 'Nachricht',
messages: 'Nachrichten',
Messages: 'Mitteilungen', Messages: 'Mitteilungen',
Message_Reported: 'Nachricht gemeldet',
Microphone_Permission_Message: 'Rocket Chat benötigt Zugriff auf Ihr Mikrofon, damit Sie eine Audionachricht senden können.', Microphone_Permission_Message: 'Rocket Chat benötigt Zugriff auf Ihr Mikrofon, damit Sie eine Audionachricht senden können.',
Microphone_Permission: 'Mikrofonberechtigung', Microphone_Permission: 'Mikrofonberechtigung',
Mute: 'Stumm', Mute: 'Stumm',
@ -215,11 +228,14 @@ export default {
No_pinned_messages: 'Keine angehefteten Nachrichten', No_pinned_messages: 'Keine angehefteten Nachrichten',
No_results_found: 'keine Ergebnisse gefunden', No_results_found: 'keine Ergebnisse gefunden',
No_starred_messages: 'Keine markierten Nachrichten', No_starred_messages: 'Keine markierten Nachrichten',
No_thread_messages: 'Keine Threadnachrichten',
No_announcement_provided: 'Keine Ankündigung erfolgt.', No_announcement_provided: 'Keine Ankündigung erfolgt.',
No_description_provided: 'Keine Beschreibung angegeben.', No_description_provided: 'Keine Beschreibung angegeben.',
No_topic_provided: 'Kein Thema bereitgestellt', No_topic_provided: 'Kein Thema bereitgestellt',
No_Message: 'Keine Nachricht', No_Message: 'Keine Nachricht',
No_messages_yet: 'Noch keine Nachrichten',
No_Reactions: 'Keine Reaktionen', No_Reactions: 'Keine Reaktionen',
No_Read_Receipts: 'Keine Lesebestätigungen',
Not_logged: 'Nicht protokolliert', Not_logged: 'Nicht protokolliert',
Nothing_to_save: 'Nichts zu speichern!', Nothing_to_save: 'Nichts zu speichern!',
Notify_active_in_this_room: 'Aktive Benutzer in diesem Raum benachrichtigen', Notify_active_in_this_room: 'Aktive Benutzer in diesem Raum benachrichtigen',
@ -252,9 +268,14 @@ export default {
Reactions: 'Reaktionen', Reactions: 'Reaktionen',
Read_Only_Channel: 'Nur-Lese-Kanal', Read_Only_Channel: 'Nur-Lese-Kanal',
Read_Only: 'Schreibgeschützt', Read_Only: 'Schreibgeschützt',
Read_Receipt: 'Lesebestätigung',
Register: 'Registrieren', Register: 'Registrieren',
Repeat_Password: 'Wiederhole das Passwort', Repeat_Password: 'Wiederhole das Passwort',
Replied_on: 'Antwortete am:',
replies: 'Antworten',
reply: 'Antworten',
Reply: 'Antworten', Reply: 'Antworten',
Report: 'Bericht',
Resend: 'Erneut senden', Resend: 'Erneut senden',
Reset_password: 'Passwort zurücksetzen', Reset_password: 'Passwort zurücksetzen',
resetting_password: 'Passwort zurücksetzen', resetting_password: 'Passwort zurücksetzen',
@ -278,35 +299,47 @@ export default {
saving_settings: 'Einstellungen speichern', saving_settings: 'Einstellungen speichern',
Search_Messages: 'Nachrichten suchen', Search_Messages: 'Nachrichten suchen',
Search: 'Suche', Search: 'Suche',
Search_by: 'Suche nach',
Search_global_users: 'Suche nach globalen Benutzern',
Search_global_users_description: 'Beim Einschalten können Sie nach Benutzern von anderen Unternehmen oder Servern suchen.',
Select_Avatar: 'Wählen Sie einen Avatar aus', Select_Avatar: 'Wählen Sie einen Avatar aus',
Select_Users: 'Wählen Sie einen Benutzer aus', Select_Users: 'Wählen Sie einen Benutzer aus',
Send: 'Senden', Send: 'Senden',
Send_audio_message: 'Audio-Nachricht senden', Send_audio_message: 'Audio-Nachricht senden',
Send_crash_report: 'Absturzbericht senden',
Send_message: 'Nachricht senden', Send_message: 'Nachricht senden',
Sent_an_attachment: 'Sende einen Anhang',
Server: 'Server', Server: 'Server',
Servers: 'Server', Servers: 'Server',
Server_version: 'Server version: {{version}}',
Set_username_subtitle: 'Der Benutzername wird verwendet, damit andere Personen Sie in Nachrichten erwähnen können', Set_username_subtitle: 'Der Benutzername wird verwendet, damit andere Personen Sie in Nachrichten erwähnen können',
Settings: 'Einstellungen', Settings: 'Einstellungen',
Settings_succesfully_changed: 'Einstellungen erfolgreich geändert!', Settings_succesfully_changed: 'Einstellungen erfolgreich geändert!',
Share: 'Teilen', Share: 'Teilen',
Share_this_app: 'Teile diese App',
Sign_in_your_server: 'Melden Sie sich bei Ihrem Server an', Sign_in_your_server: 'Melden Sie sich bei Ihrem Server an',
Sign_Up: 'Anmelden', Sign_Up: 'Anmelden',
Some_field_is_invalid_or_empty: 'Ein Feld ist ungültig oder leer', Some_field_is_invalid_or_empty: 'Ein Feld ist ungültig oder leer',
Sorting_by: 'Sortierung nach {{key}}', Sorting_by: 'Sortierung nach {{key}}',
Star_room: 'Favorisierter Raum', Star_room: 'Favorisierter Raum',
Star: 'Favoriten',
Starred_Messages: 'Favorisierte Nachrichten', Starred_Messages: 'Favorisierte Nachrichten',
starred: 'favorisiert', starred: 'favorisiert',
Starred: 'Favorisiert', Starred: 'Favorisiert',
Start_of_conversation: 'Beginn des Gesprächs', Start_of_conversation: 'Beginn des Gesprächs',
Started_discussion: 'Hat eine Diskussion gestartet:',
Submit: 'einreichen', Submit: 'einreichen',
Take_a_photo: 'Mach ein Foto', Take_a_photo: 'Foto aufnehmen',
tap_to_change_status: 'Tippen um den Status zu ändern', tap_to_change_status: 'Tippen um den Status zu ändern',
Tap_to_view_servers_list: 'Tippen Sie hier, um die Serverliste anzuzeigen', Tap_to_view_servers_list: 'Tippen Sie hier, um die Serverliste anzuzeigen',
Terms_of_Service: ' Nutzungsbedingungen', Terms_of_Service: ' Nutzungsbedingungen',
Theme: 'Theme',
The_URL_is_invalid: 'Die eingegebene URL ist ungültig. Überprüfen Sie es und versuchen Sie es erneut, bitte!', The_URL_is_invalid: 'Die eingegebene URL ist ungültig. Überprüfen Sie es und versuchen Sie es erneut, bitte!',
There_was_an_error_while_action: 'Während {{action}} ist ein Fehler aufgetreten!', There_was_an_error_while_action: 'Während {{action}} ist ein Fehler aufgetreten!',
This_room_is_blocked: 'Dieser Raum ist gesperrt', This_room_is_blocked: 'Dieser Raum ist gesperrt',
This_room_is_read_only: 'Dieser Raum kann nur gelesen werden', This_room_is_read_only: 'Dieser Raum kann nur gelesen werden',
Thread: 'Thread',
Threads: 'Threads',
Timezone: 'Zeitzone', Timezone: 'Zeitzone',
topic: 'Thema', topic: 'Thema',
Topic: 'Thema', Topic: 'Thema',
@ -316,6 +349,7 @@ export default {
unarchive: 'wiederherstellen', unarchive: 'wiederherstellen',
UNARCHIVE: 'WIEDERHERSTELLEN', UNARCHIVE: 'WIEDERHERSTELLEN',
Unblock_user: 'Nutzer entblockieren', Unblock_user: 'Nutzer entblockieren',
Unfollowed_thread: 'Thread nicht mehr folgen',
Unmute: 'Stummschaltung aufheben', Unmute: 'Stummschaltung aufheben',
unmuted: 'Stummschaltung aufgehoben', unmuted: 'Stummschaltung aufgehoben',
Unpin: 'Nachricht nicht mehr anheften', Unpin: 'Nachricht nicht mehr anheften',
@ -326,6 +360,7 @@ export default {
Updating: 'Aktualisierung...', Updating: 'Aktualisierung...',
Uploading: 'Hochladen', Uploading: 'Hochladen',
Upload_file_question_mark: 'Datei hochladen?', Upload_file_question_mark: 'Datei hochladen?',
Users: 'Benutzer',
User_added_by: 'Benutzer {{userAdded}} hinzugefügt von {{userBy}}', User_added_by: 'Benutzer {{userAdded}} hinzugefügt von {{userBy}}',
User_has_been_key: 'Benutzer wurde {{key}}!', User_has_been_key: 'Benutzer wurde {{key}}!',
User_is_no_longer_role_by_: '{{user}} ist nicht länger {{role}} von {{userBy}}', User_is_no_longer_role_by_: '{{user}} ist nicht länger {{role}} von {{userBy}}',
@ -343,7 +378,7 @@ export default {
Welcome: 'Herzlich willkommen', Welcome: 'Herzlich willkommen',
Welcome_to_RocketChat: 'Willkommen bei Rocket.Chat', Welcome_to_RocketChat: 'Willkommen bei Rocket.Chat',
Whats_your_2fa: 'Wie ist dein 2FA-Code?', Whats_your_2fa: 'Wie ist dein 2FA-Code?',
Yes_action_it: 'Ja, {{action}} es!', Yes_action_it: 'Ja, {{action}}!',
Yesterday: 'Gestern', Yesterday: 'Gestern',
You_are_in_preview_mode: 'Sie befinden sich im Vorschaumodus', You_are_in_preview_mode: 'Sie befinden sich im Vorschaumodus',
You_are_offline: 'Sie sind offline', You_are_offline: 'Sie sind offline',
@ -352,5 +387,8 @@ export default {
you_were_mentioned: 'Sie wurden erwähnt', you_were_mentioned: 'Sie wurden erwähnt',
you: 'sie', you: 'sie',
You: 'Sie', You: 'Sie',
You_will_not_be_able_to_recover_this_message: 'Sie können diese Nachricht nicht wiederherstellen!' Version_no: 'Version: {{version}}',
You_will_not_be_able_to_recover_this_message: 'Sie können diese Nachricht nicht wiederherstellen!',
Change_Language: 'Sprache ändern',
Crash_report_disclaimer: 'Wir verfolgen niemals den Inhalt Ihrer Chats. Der Crash-Report enthält nur für uns relevante Informationen in der Reihenfolge '
}; };

View File

@ -23,57 +23,62 @@ const create = (customEmojis) => {
}; };
export default async function() { export default function() {
try { return new Promise(async(resolve) => {
const serverVersion = reduxStore.getState().server.version; try {
const updatedSince = getUpdatedSince(); const serverVersion = reduxStore.getState().server.version;
const updatedSince = getUpdatedSince();
// if server version is lower than 0.75.0, fetches from old api // if server version is lower than 0.75.0, fetches from old api
if (semver.lt(serverVersion, '0.75.0')) { if (semver.lt(serverVersion, '0.75.0')) {
// RC 0.61.0 // RC 0.61.0
const result = await this.sdk.get('emoji-custom'); const result = await this.sdk.get('emoji-custom');
InteractionManager.runAfterInteractions(() => { InteractionManager.runAfterInteractions(() => {
let { emojis } = result; let { emojis } = result;
emojis = emojis.filter(emoji => !updatedSince || emoji._updatedAt > updatedSince); emojis = emojis.filter(emoji => !updatedSince || emoji._updatedAt > updatedSince);
database.write(() => { database.write(() => {
create(emojis); create(emojis);
});
return resolve();
}); });
}); } else {
} else { const params = {};
const params = {}; if (updatedSince) {
if (updatedSince) { params.updatedSince = updatedSince;
params.updatedSince = updatedSince; }
}
// RC 0.75.0 // RC 0.75.0
const result = await this.sdk.get('emoji-custom.list', params); const result = await this.sdk.get('emoji-custom.list', params);
if (!result.success) { if (!result.success) {
return; return resolve();
} }
InteractionManager.runAfterInteractions( InteractionManager.runAfterInteractions(
() => database.write(() => { () => database.write(() => {
const { emojis } = result; const { emojis } = result;
create(emojis.update); create(emojis.update);
if (emojis.delete && emojis.delete.length) { if (emojis.delete && emojis.delete.length) {
emojis.delete.forEach((emoji) => { emojis.delete.forEach((emoji) => {
try { try {
const emojiRecord = database.objectForPrimaryKey('customEmojis', emoji._id); const emojiRecord = database.objectForPrimaryKey('customEmojis', emoji._id);
if (emojiRecord) { if (emojiRecord) {
database.delete(emojiRecord); database.delete(emojiRecord);
}
} catch (e) {
log('err_get_emojis_delete', e);
} }
} catch (e) { });
log('err_get_emojis_delete', e); }
} return resolve();
}); })
} );
}) }
); } catch (e) {
log('err_get_custom_emojis', e);
return resolve();
} }
} catch (e) { });
log('err_get_custom_emojis', e);
}
} }

View File

@ -22,55 +22,60 @@ const create = (permissions) => {
} }
}; };
export default async function() { export default function() {
try { return new Promise(async(resolve) => {
const serverVersion = reduxStore.getState().server.version; try {
const serverVersion = reduxStore.getState().server.version;
// if server version is lower than 0.73.0, fetches from old api // if server version is lower than 0.73.0, fetches from old api
if (semver.lt(serverVersion, '0.73.0')) { if (semver.lt(serverVersion, '0.73.0')) {
// RC 0.66.0 // RC 0.66.0
const result = await this.sdk.get('permissions.list'); const result = await this.sdk.get('permissions.list');
if (!result.success) { if (!result.success) {
return; return resolve();
} }
InteractionManager.runAfterInteractions(() => { InteractionManager.runAfterInteractions(() => {
database.write(() => { database.write(() => {
create(result.permissions); create(result.permissions);
});
return resolve();
}); });
}); } else {
} else { const params = {};
const params = {}; const updatedSince = getUpdatedSince();
const updatedSince = getUpdatedSince(); if (updatedSince) {
if (updatedSince) { params.updatedSince = updatedSince;
params.updatedSince = updatedSince; }
} // RC 0.73.0
// RC 0.73.0 const result = await this.sdk.get('permissions.listAll', params);
const result = await this.sdk.get('permissions.listAll', params);
if (!result.success) { if (!result.success) {
return; return resolve();
} }
InteractionManager.runAfterInteractions( InteractionManager.runAfterInteractions(
() => database.write(() => { () => database.write(() => {
create(result.update); create(result.update);
if (result.delete && result.delete.length) { if (result.delete && result.delete.length) {
result.delete.forEach((p) => { result.delete.forEach((p) => {
try { try {
const permission = database.objectForPrimaryKey('permissions', p._id); const permission = database.objectForPrimaryKey('permissions', p._id);
if (permission) { if (permission) {
database.delete(permission); database.delete(permission);
}
} catch (e) {
log('err_get_permissions_delete', e);
} }
} catch (e) { });
log('err_get_permissions_delete', e); }
} return resolve();
}); })
} );
}) }
); } catch (e) {
log('err_get_permissions', e);
return resolve();
} }
} catch (e) { });
log('err_get_permissions', e);
}
} }

View File

@ -3,29 +3,33 @@ import { InteractionManager } from 'react-native';
import database from '../realm'; import database from '../realm';
import log from '../../utils/log'; import log from '../../utils/log';
export default async function() { export default function() {
try { return new Promise(async(resolve) => {
// RC 0.70.0 try {
const result = await this.sdk.get('roles.list'); // RC 0.70.0
const result = await this.sdk.get('roles.list');
if (!result.success) { if (!result.success) {
return; return resolve();
}
const { roles } = result;
if (roles && roles.length) {
InteractionManager.runAfterInteractions(() => {
database.write(() => roles.forEach((role) => {
try {
database.create('roles', role, true);
} catch (e) {
log('err_get_roles_create', e);
}
}));
return resolve();
});
}
} catch (e) {
log('err_get_roles', e);
return resolve();
} }
});
const { roles } = result;
if (roles && roles.length) {
InteractionManager.runAfterInteractions(() => {
database.write(() => roles.forEach((role) => {
try {
database.create('roles', role, true);
} catch (e) {
log('err_get_roles_create', e);
}
}));
});
}
} catch (e) {
log('err_get_roles', e);
}
} }

View File

@ -3,29 +3,34 @@ import { InteractionManager } from 'react-native';
import database from '../realm'; import database from '../realm';
import log from '../../utils/log'; import log from '../../utils/log';
export default async function() { export default function() {
try { return new Promise(async(resolve) => {
// RC 0.60.2 try {
const result = await this.sdk.get('commands.list'); // RC 0.60.2
const result = await this.sdk.get('commands.list');
if (!result.success) { if (!result.success) {
return log('getSlashCommand fetch', result); log('getSlashCommand fetch', result);
return resolve();
}
const { commands } = result;
if (commands && commands.length) {
InteractionManager.runAfterInteractions(() => {
database.write(() => commands.forEach((command) => {
try {
database.create('slashCommand', command, true);
} catch (e) {
log('get_slash_command', e);
}
}));
return resolve();
});
}
} catch (e) {
log('err_get_slash_command', e);
return resolve();
} }
});
const { commands } = result;
if (commands && commands.length) {
InteractionManager.runAfterInteractions(() => {
database.write(() => commands.forEach((command) => {
try {
database.create('slashCommand', command, true);
} catch (e) {
log('get_slash_command', e);
}
}));
});
}
} catch (e) {
log('err_get_slash_command', e);
}
} }

View File

@ -13,6 +13,7 @@ const removeListener = listener => listener.stop();
let connectedListener; let connectedListener;
let disconnectedListener; let disconnectedListener;
let streamListener; let streamListener;
let subServer;
export default async function subscribeRooms() { export default async function subscribeRooms() {
let timer = null; let timer = null;
@ -41,6 +42,10 @@ export default async function subscribeRooms() {
}; };
const handleStreamMessageReceived = protectedFunction((ddpMessage) => { const handleStreamMessageReceived = protectedFunction((ddpMessage) => {
// check if the server from variable is the same as the js sdk client
if (this.sdk && this.sdk.client && this.sdk.client.host !== subServer) {
return;
}
if (ddpMessage.msg === 'added') { if (ddpMessage.msg === 'added') {
return; return;
} }
@ -149,6 +154,8 @@ export default async function subscribeRooms() {
streamListener = this.sdk.onStreamData('stream-notify-user', handleStreamMessageReceived); streamListener = this.sdk.onStreamData('stream-notify-user', handleStreamMessageReceived);
try { try {
// set the server that started this task
subServer = this.sdk.client.host;
await this.sdk.subscribeNotifyUser(); await this.sdk.subscribeNotifyUser();
} catch (e) { } catch (e) {
log('err_subscribe_rooms', e); log('err_subscribe_rooms', e);

View File

@ -8,7 +8,6 @@ import messagesStatus from '../constants/messagesStatus';
import database from './realm'; import database from './realm';
import log from '../utils/log'; import log from '../utils/log';
import { isIOS, getBundleId } from '../utils/deviceInfo'; import { isIOS, getBundleId } from '../utils/deviceInfo';
import EventEmitter from '../utils/events';
import { import {
setUser, setLoginServices, loginRequest, loginFailure, logout setUser, setLoginServices, loginRequest, loginFailure, logout
@ -24,7 +23,7 @@ import getSettings from './methods/getSettings';
import getRooms from './methods/getRooms'; import getRooms from './methods/getRooms';
import getPermissions from './methods/getPermissions'; import getPermissions from './methods/getPermissions';
import getCustomEmoji from './methods/getCustomEmojis'; import getCustomEmojis from './methods/getCustomEmojis';
import getSlashCommands from './methods/getSlashCommands'; import getSlashCommands from './methods/getSlashCommands';
import getRoles from './methods/getRoles'; import getRoles from './methods/getRoles';
import canOpenRoom from './methods/canOpenRoom'; import canOpenRoom from './methods/canOpenRoom';
@ -37,7 +36,6 @@ import sendMessage, { getMessage, sendMessageCall } from './methods/sendMessage'
import { sendFileMessage, cancelUpload, isUploadActive } from './methods/sendFileMessage'; import { sendFileMessage, cancelUpload, isUploadActive } from './methods/sendFileMessage';
import { getDeviceToken } from '../notifications/push'; import { getDeviceToken } from '../notifications/push';
import { roomsRequest } from '../actions/rooms';
const TOKEN_KEY = 'reactnativemeteor_usertoken'; const TOKEN_KEY = 'reactnativemeteor_usertoken';
const SORT_PREFS_KEY = 'RC_SORT_PREFS_KEY'; const SORT_PREFS_KEY = 'RC_SORT_PREFS_KEY';
@ -141,23 +139,6 @@ const RocketChat = {
}; };
} }
}, },
async loginSuccess({ user }) {
EventEmitter.emit('connected');
reduxStore.dispatch(setUser(user));
reduxStore.dispatch(roomsRequest());
if (this.roomsSub) {
this.roomsSub.stop();
}
this.roomsSub = await this.subscribeRooms();
this.getPermissions();
this.getCustomEmoji();
this.getRoles();
this.getSlashCommands();
this.registerPushToken().catch(e => console.log(e));
this.getUserPresence();
},
connect({ server, user }) { connect({ server, user }) {
return new Promise((resolve) => { return new Promise((resolve) => {
database.setActiveDB(server); database.setActiveDB(server);
@ -167,6 +148,10 @@ const RocketChat = {
clearTimeout(this.connectTimeout); clearTimeout(this.connectTimeout);
} }
if (this.roomsSub) {
this.roomsSub.stop();
}
if (this.sdk) { if (this.sdk) {
this.sdk.disconnect(); this.sdk.disconnect();
this.sdk = null; this.sdk = null;
@ -195,10 +180,10 @@ const RocketChat = {
this.sdk.onStreamData('connected', () => { this.sdk.onStreamData('connected', () => {
reduxStore.dispatch(connectSuccess()); reduxStore.dispatch(connectSuccess());
const { isAuthenticated } = reduxStore.getState().login; // const { isAuthenticated } = reduxStore.getState().login;
if (isAuthenticated) { // if (isAuthenticated) {
this.getUserPresence(); // this.getUserPresence();
} // }
}); });
this.sdk.onStreamData('close', () => { this.sdk.onStreamData('close', () => {
@ -349,7 +334,7 @@ const RocketChat = {
} }
}, },
registerPushToken() { registerPushToken() {
return new Promise((resolve) => { return new Promise(async(resolve) => {
const token = getDeviceToken(); const token = getDeviceToken();
if (token) { if (token) {
const type = isIOS ? 'apn' : 'gcm'; const type = isIOS ? 'apn' : 'gcm';
@ -358,8 +343,12 @@ const RocketChat = {
type, type,
appName: getBundleId appName: getBundleId
}; };
// RC 0.60.0 try {
return this.sdk.post('push.token', data); // RC 0.60.0
await this.sdk.post('push.token', data);
} catch (error) {
console.log(error);
}
} }
return resolve(); return resolve();
}); });
@ -468,7 +457,7 @@ const RocketChat = {
isUploadActive, isUploadActive,
getSettings, getSettings,
getPermissions, getPermissions,
getCustomEmoji, getCustomEmojis,
getSlashCommands, getSlashCommands,
getRoles, getRoles,
parseSettings: settings => settings.reduce((ret, item) => { parseSettings: settings => settings.reduce((ret, item) => {
@ -824,41 +813,45 @@ const RocketChat = {
command, params, roomId, previewItem command, params, roomId, previewItem
}); });
}, },
async getUserPresence() { getUserPresence() {
const serverVersion = reduxStore.getState().server.version; return new Promise(async(resolve) => {
const serverVersion = reduxStore.getState().server.version;
// if server is lower than 1.1.0 // if server is lower than 1.1.0
if (semver.lt(semver.coerce(serverVersion), '1.1.0')) { if (semver.lt(semver.coerce(serverVersion), '1.1.0')) {
if (this.activeUsersSubTimeout) { if (this.activeUsersSubTimeout) {
clearTimeout(this.activeUsersSubTimeout); clearTimeout(this.activeUsersSubTimeout);
this.activeUsersSubTimeout = false; this.activeUsersSubTimeout = false;
} }
this.activeUsersSubTimeout = setTimeout(() => { this.activeUsersSubTimeout = setTimeout(() => {
this.sdk.subscribe('activeUsers'); this.sdk.subscribe('activeUsers');
}, 5000); }, 5000);
} else { return resolve();
const params = {}; } else {
if (this.lastUserPresenceFetch) { const params = {};
params.from = this.lastUserPresenceFetch.toISOString(); // if (this.lastUserPresenceFetch) {
} // params.from = this.lastUserPresenceFetch.toISOString();
// }
// RC 1.1.0 // RC 1.1.0
const result = await this.sdk.get('users.presence', params); const result = await this.sdk.get('users.presence', params);
if (result.success) { if (result.success) {
this.lastUserPresenceFetch = new Date(); // this.lastUserPresenceFetch = new Date();
database.memoryDatabase.write(() => { database.memoryDatabase.write(() => {
result.users.forEach((item) => { result.users.forEach((item) => {
try { try {
item.id = item._id; item.id = item._id;
database.memoryDatabase.create('activeUsers', item, true); database.memoryDatabase.create('activeUsers', item, true);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
});
}); });
}); this.sdk.subscribe('stream-notify-logged', 'user-status');
this.sdk.subscribe('stream-notify-logged', 'user-status'); return resolve();
}
} }
} });
}, },
getDirectory({ getDirectory({
query, count, offset, sort query, count, offset, sort

View File

@ -44,6 +44,13 @@ export default function server(state = initialState, action) {
connected: true, connected: true,
loading: false loading: false
}; };
case SERVER.SELECT_FAILURE:
return {
...state,
connecting: false,
connected: false,
loading: false
};
case SERVER.INIT_ADD: case SERVER.INIT_ADD:
return { return {
...state, ...state,

View File

@ -1,16 +1,18 @@
import { AsyncStorage } from 'react-native'; import { AsyncStorage } from 'react-native';
import { import {
put, call, takeLatest, select put, call, takeLatest, select, take, fork, cancel
} from 'redux-saga/effects'; } from 'redux-saga/effects';
import * as types from '../actions/actionsTypes'; import * as types from '../actions/actionsTypes';
import { appStart } from '../actions'; import { appStart } from '../actions';
import { serverFinishAdd, selectServerRequest } from '../actions/server'; import { serverFinishAdd, selectServerRequest } from '../actions/server';
import { loginFailure, loginSuccess } from '../actions/login'; import { loginFailure, loginSuccess, setUser } from '../actions/login';
import { roomsRequest } from '../actions/rooms';
import RocketChat from '../lib/rocketchat'; import RocketChat from '../lib/rocketchat';
import log from '../utils/log'; import log from '../utils/log';
import I18n from '../i18n'; import I18n from '../i18n';
import database from '../lib/realm'; import database from '../lib/realm';
import EventEmitter from '../utils/events';
const getServer = state => state.server.server; const getServer = state => state.server.server;
const loginWithPasswordCall = args => RocketChat.loginWithPassword(args); const loginWithPasswordCall = args => RocketChat.loginWithPassword(args);
@ -31,27 +33,59 @@ const handleLoginRequest = function* handleLoginRequest({ credentials }) {
} }
}; };
const handleLoginSuccess = function* handleLoginSuccess({ user }) { const fetchPermissions = function* fetchPermissions() {
const adding = yield select(state => state.server.adding); yield RocketChat.getPermissions();
yield AsyncStorage.setItem(RocketChat.TOKEN_KEY, user.token); };
const server = yield select(getServer); const fetchCustomEmojis = function* fetchCustomEmojis() {
yield RocketChat.getCustomEmojis();
};
const fetchRoles = function* fetchRoles() {
yield RocketChat.getRoles();
};
const fetchSlashCommands = function* fetchSlashCommands() {
yield RocketChat.getSlashCommands();
};
const registerPushToken = function* registerPushToken() {
yield RocketChat.registerPushToken();
};
const fetchUserPresence = function* fetchUserPresence() {
yield RocketChat.getUserPresence();
};
const handleLoginSuccess = function* handleLoginSuccess({ user }) {
try { try {
RocketChat.loginSuccess({ user }); const adding = yield select(state => state.server.adding);
yield AsyncStorage.setItem(RocketChat.TOKEN_KEY, user.token);
const server = yield select(getServer);
yield put(roomsRequest());
yield fork(fetchPermissions);
yield fork(fetchCustomEmojis);
yield fork(fetchRoles);
yield fork(fetchSlashCommands);
yield fork(registerPushToken);
yield fork(fetchUserPresence);
I18n.locale = user.language; I18n.locale = user.language;
yield AsyncStorage.setItem(`${ RocketChat.TOKEN_KEY }-${ server }`, JSON.stringify(user)); yield AsyncStorage.setItem(`${ RocketChat.TOKEN_KEY }-${ server }`, JSON.stringify(user));
} catch (error) { yield put(setUser(user));
console.log('loginSuccess saga -> error', error); EventEmitter.emit('connected');
}
if (!user.username) { if (!user.username) {
RocketChat.loginSuccess({ user }); yield put(appStart('setUsername'));
yield put(appStart('setUsername')); } else if (adding) {
} else if (adding) { yield put(serverFinishAdd());
yield put(serverFinishAdd()); yield put(appStart('inside'));
yield put(appStart('inside')); } else {
} else { yield put(appStart('inside'));
yield put(appStart('inside')); }
} catch (e) {
log('err_handle_login_success', e);
} }
}; };
@ -93,8 +127,14 @@ const handleSetUser = function handleSetUser({ user }) {
const root = function* root() { const root = function* root() {
yield takeLatest(types.LOGIN.REQUEST, handleLoginRequest); yield takeLatest(types.LOGIN.REQUEST, handleLoginRequest);
yield takeLatest(types.LOGIN.SUCCESS, handleLoginSuccess);
yield takeLatest(types.LOGOUT, handleLogout); yield takeLatest(types.LOGOUT, handleLogout);
yield takeLatest(types.USER.SET, handleSetUser); yield takeLatest(types.USER.SET, handleSetUser);
while (true) {
const params = yield take(types.LOGIN.SUCCESS);
const loginSuccessTask = yield fork(handleLoginSuccess, params);
yield take(types.SERVER.SELECT_REQUEST);
yield cancel(loginSuccessTask);
}
}; };
export default root; export default root;

View File

@ -1,6 +1,7 @@
import { import {
put, takeLatest, select put, select, race, take, fork, cancel, takeLatest
} from 'redux-saga/effects'; } from 'redux-saga/effects';
import { BACKGROUND } from 'redux-enhancer-react-native-appstate';
import * as types from '../actions/actionsTypes'; import * as types from '../actions/actionsTypes';
import { roomsSuccess, roomsFailure } from '../actions/rooms'; import { roomsSuccess, roomsFailure } from '../actions/rooms';
@ -9,8 +10,18 @@ import log from '../utils/log';
import mergeSubscriptionsRooms from '../lib/methods/helpers/mergeSubscriptionsRooms'; import mergeSubscriptionsRooms from '../lib/methods/helpers/mergeSubscriptionsRooms';
import RocketChat from '../lib/rocketchat'; import RocketChat from '../lib/rocketchat';
let roomsSub;
const removeSub = function removeSub() {
if (roomsSub && roomsSub.stop) {
roomsSub.stop();
}
};
const handleRoomsRequest = function* handleRoomsRequest() { const handleRoomsRequest = function* handleRoomsRequest() {
try { try {
removeSub();
roomsSub = yield RocketChat.subscribeRooms();
const newRoomsUpdatedAt = new Date(); const newRoomsUpdatedAt = new Date();
const server = yield select(state => state.server.server); const server = yield select(state => state.server.server);
const [serverRecord] = database.databases.serversDB.objects('servers').filtered('id = $0', server); const [serverRecord] = database.databases.serversDB.objects('servers').filtered('id = $0', server);
@ -42,7 +53,21 @@ const handleRoomsRequest = function* handleRoomsRequest() {
} }
}; };
const handleLogout = function handleLogout() {
removeSub();
};
const root = function* root() { const root = function* root() {
yield takeLatest(types.ROOMS.REQUEST, handleRoomsRequest); yield takeLatest(types.LOGOUT, handleLogout);
while (true) {
const params = yield take(types.ROOMS.REQUEST);
const roomsRequestTask = yield fork(handleRoomsRequest, params);
yield race({
serverReq: take(types.SERVER.SELECT_REQUEST),
background: take(BACKGROUND),
logout: take(types.LOGOUT)
});
yield cancel(roomsRequestTask);
}
}; };
export default root; export default root;

View File

@ -1,10 +1,14 @@
import { put, takeLatest } from 'redux-saga/effects'; import {
put, take, takeLatest, fork, cancel, race
} from 'redux-saga/effects';
import { AsyncStorage, Alert } from 'react-native'; import { AsyncStorage, Alert } from 'react-native';
import Navigation from '../lib/Navigation'; import Navigation from '../lib/Navigation';
import { SERVER } from '../actions/actionsTypes'; import { SERVER } from '../actions/actionsTypes';
import * as actions from '../actions'; import * as actions from '../actions';
import { serverFailure, selectServerRequest, selectServerSuccess } from '../actions/server'; import {
serverFailure, selectServerRequest, selectServerSuccess, selectServerFailure
} from '../actions/server';
import { setUser } from '../actions/login'; import { setUser } from '../actions/login';
import RocketChat from '../lib/rocketchat'; import RocketChat from '../lib/rocketchat';
import database from '../lib/realm'; import database from '../lib/realm';
@ -58,6 +62,7 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch
// Return server version even when offline // Return server version even when offline
yield put(selectServerSuccess(server, (serverInfo && serverInfo.version) || version)); yield put(selectServerSuccess(server, (serverInfo && serverInfo.version) || version));
} catch (e) { } catch (e) {
yield put(selectServerFailure());
log('err_select_server', e); log('err_select_server', e);
} }
}; };
@ -81,7 +86,17 @@ const handleServerRequest = function* handleServerRequest({ server }) {
}; };
const root = function* root() { const root = function* root() {
yield takeLatest(SERVER.SELECT_REQUEST, handleSelectServer);
yield takeLatest(SERVER.REQUEST, handleServerRequest); yield takeLatest(SERVER.REQUEST, handleServerRequest);
while (true) {
const params = yield take(SERVER.SELECT_REQUEST);
const selectServerTask = yield fork(handleSelectServer, params);
yield race({
request: take(SERVER.SELECT_REQUEST),
success: take(SERVER.SELECT_SUCCESS),
failure: take(SERVER.SELECT_FAILURE)
});
yield cancel(selectServerTask);
}
}; };
export default root; export default root;

View File

@ -29,6 +29,7 @@ import RoomsListHeaderView from './Header';
import { DrawerButton, CustomHeaderButtons, Item } from '../../containers/HeaderButton'; import { DrawerButton, CustomHeaderButtons, Item } from '../../containers/HeaderButton';
import StatusBar from '../../containers/StatusBar'; import StatusBar from '../../containers/StatusBar';
import ListHeader from './ListHeader'; import ListHeader from './ListHeader';
import { selectServerRequest as selectServerRequestAction } from '../../actions/server';
const SCROLL_OFFSET = 56; const SCROLL_OFFSET = 56;
@ -56,7 +57,8 @@ const keyExtractor = item => item.rid;
openSearchHeader: () => dispatch(openSearchHeaderAction()), openSearchHeader: () => dispatch(openSearchHeaderAction()),
closeSearchHeader: () => dispatch(closeSearchHeaderAction()), closeSearchHeader: () => dispatch(closeSearchHeaderAction()),
appStart: () => dispatch(appStartAction()), appStart: () => dispatch(appStartAction()),
roomsRequest: () => dispatch(roomsRequestAction()) roomsRequest: () => dispatch(roomsRequestAction()),
selectServerRequest: server => dispatch(selectServerRequestAction(server))
})) }))
export default class RoomsListView extends React.Component { export default class RoomsListView extends React.Component {
static navigationOptions = ({ navigation }) => { static navigationOptions = ({ navigation }) => {