review-fixes

pull/1225/head
Vincent 5 years ago
parent 4a13b1e6bb
commit 6cb05c3677

@ -2377,6 +2377,10 @@
"displayName": { "displayName": {
"message": "Display Name" "message": "Display Name"
}, },
"anonymous": {
"message": "Anonymous",
"description": "The name of currently unidentified users"
},
"enterDisplayName": { "enterDisplayName": {
"message": "Enter a display name" "message": "Enter a display name"
}, },

@ -1093,7 +1093,9 @@
// Attempts a connection to an open group server // Attempts a connection to an open group server
window.attemptConnection = async (serverURL, channelId) => { window.attemptConnection = async (serverURL, channelId) => {
let completeServerURL = serverURL.toLowerCase(); let completeServerURL = serverURL.toLowerCase();
const valid = window.libsession.Types.OpenGroup.validate(completeServerURL); const valid = window.libsession.Types.OpenGroup.validate(
completeServerURL
);
if (!valid) { if (!valid) {
return new Promise((_resolve, reject) => { return new Promise((_resolve, reject) => {
reject(window.i18n('connectToServerFail')); reject(window.i18n('connectToServerFail'));
@ -1101,7 +1103,9 @@
} }
// Add http or https prefix to server // Add http or https prefix to server
completeServerURL = window.libsession.Types.OpenGroup.prefixify(completeServerURL); completeServerURL = window.libsession.Types.OpenGroup.prefixify(
completeServerURL
);
const rawServerURL = serverURL const rawServerURL = serverURL
.replace(/^https?:\/\//i, '') .replace(/^https?:\/\//i, '')

@ -475,36 +475,34 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
} }
// Connect to server // Connect to server
const successPromise = OpenGroup.join(serverUrl, async () => { try {
if (await OpenGroup.serverExists(serverUrl)) { await OpenGroup.join(serverUrl, async () => {
window.pushToast({ if (await OpenGroup.serverExists(serverUrl)) {
title: window.i18n('connectingToServer'), window.pushToast({
id: 'connectToServerSuccess', title: window.i18n('connectingToServer'),
type: 'success', id: 'connectToServerSuccess',
}); type: 'success',
});
this.setState({ loading: true });
} this.setState({ loading: true });
}); }
});
successPromise this.handleToggleOverlay(undefined);
.then(() => { this.setState({
this.handleToggleOverlay(undefined); loading: false,
this.setState({ });
loading: false, } catch (e) {
}); this.setState({
}) loading: false,
.catch(() => { });
this.setState({
loading: false,
});
window.pushToast({ window.pushToast({
title: window.i18n('connectToServerFail'), title: window.i18n('connectToServerFail'),
id: 'connectToServerFail', id: 'connectToServerFail',
type: 'error', type: 'error',
});
}); });
}
} }
private async onCreateClosedGroup( private async onCreateClosedGroup(

@ -69,7 +69,7 @@ export class SessionClosableOverlay extends React.Component<Props, State> {
const contactsList = this.props.contacts ?? []; const contactsList = this.props.contacts ?? [];
return contactsList.map((d: any) => { return contactsList.map((d: any) => {
const name = d.name ?? 'Anonymous'; const name = d.name ?? window.i18n('anonymous');
// TODO: should take existing members into account // TODO: should take existing members into account
const existingMember = false; const existingMember = false;

@ -1,3 +1,5 @@
import { ConversationModel } from '../../../js/models/conversations';
interface OpenGroupParams { interface OpenGroupParams {
server: string; server: string;
channel: number; channel: number;
@ -144,7 +146,9 @@ export class OpenGroup {
* @param server The server URL * @param server The server URL
* @returns BackBone conversation model corresponding to the server if it exists, otherwise `undefined` * @returns BackBone conversation model corresponding to the server if it exists, otherwise `undefined`
*/ */
public static async getConversation(server: string): Promise<any> { public static async getConversation(
server: string
): Promise<ConversationModel | undefined> {
if (!OpenGroup.validate(server)) { if (!OpenGroup.validate(server)) {
return; return;
} }
@ -161,17 +165,6 @@ export class OpenGroup {
return serverInfo.channels[0].conversation; return serverInfo.channels[0].conversation;
} }
/**
* Get the conversation model of a server from conversation ID
*
* @param conversationId The server's conversation ID
* @returns BackBone conversation model corresponding to the server if it exists, otherwise `undefined`
*/
public static getConversationByCID(conversationId: string): any {
const { ConversationController } = window;
return ConversationController.get(conversationId);
}
/** /**
* Check if the server exists. * Check if the server exists.
* This does not compare against your conversations with the server. * This does not compare against your conversations with the server.

Loading…
Cancel
Save