load-conv-public

pull/1225/head
Vincent 5 years ago
parent a005aa8a2e
commit e72970fdc7

@ -2194,8 +2194,11 @@
"connectToServerFail": {
"message": "Failed to connect to server. Check URL"
},
"connectingToServer": {
"message": "Connecting to server..."
},
"connectToServerSuccess": {
"message": "Successfully connected to new open group server"
"message": "Successfully connected to open group"
},
"setPasswordFail": {
"message": "Failed to set password"

@ -59,7 +59,6 @@ interface State {
loading: boolean;
overlay: false | SessionComposeToType;
valuePasted: string;
connectSuccess: boolean;
}
export class LeftPaneMessageSection extends React.Component<Props, State> {
@ -73,7 +72,6 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
loading: false,
overlay: false,
valuePasted: '',
connectSuccess: false,
};
const conversations = this.getCurrentConversations();
@ -474,25 +472,50 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
}
// Connect to server
const successPromise = OpenGroup.join(serverUrl, () => {
this.setState({ loading: true });
const successPromise = OpenGroup.join(serverUrl, async () => {
if (await OpenGroup.serverExists(serverUrl)) {
window.pushToast({
title: window.i18n('connectingToServer'),
id: 'connectToServerSuccess',
type: 'success',
});
this.setState({loading: true});
// Call conversationRenderedResolve when the conversation is rendered.
let conversationRenderedResolve: any;
const conversationRenderedPromise = async () =>
// tslint:disable-next-line: promise-must-complete
new Promise(resolve => {
conversationRenderedResolve = resolve;
});
// STOP IT AT THE SOURCE; SELECTORS/CONVERSATIONS.TS
const isRenderedInterval = setInterval(async () => {
// The conversation is shown in LeftPane when lastMessage is set.
// Notify the user when we're ready to render in LeftPane.
if ((await OpenGroup.getConversation(serverUrl))?.lastMessage) {
conversationRenderedResolve();
window.pushToast({
title: window.i18n('connectToServerFail'),
id: 'connectToServerFail',
type: 'error',
});
}
}, 100);
}
});
successPromise.then(() => {
this.handleToggleOverlay(undefined);
this.setState({
loading: false,
connectSuccess: true,
});
window.pushToast({
title: window.i18n('connectToServerSuccess'),
id: 'connectToServerSuccess',
type: 'success',
});
}).catch(() => {
this.setState({
connectSuccess: false,
loading: false,
});

@ -131,6 +131,15 @@ export class OpenGroup {
return serverInfo.channels[0].conversation;
}
public static async serverExists(server: string): Promise<boolean> {
if (!OpenGroup.validate(server)) {
return false;
}
const prefixedServer = this.prefixify(server);
return Boolean(await window.lokiPublicChatAPI.findOrCreateServer(prefixedServer));
}
public static getConversationByCID(conversationId: string): any {
const { ConversationController } = window;
return ConversationController.get(conversationId);

@ -120,6 +120,12 @@ export const _getLeftPaneLists = (
};
}
const isPublic = conversation.isPublic;
console.log('[vince] isPublic:', isPublic);
console.log('[vince] isPublic:', isPublic);
console.log('[vince] isPublic:', isPublic);
console.log('[vince] isPublic:', isPublic);
// Remove all invalid conversations and conversatons of devices associated with cancelled attempted links
if (!conversation.timestamp) {
continue;

Loading…
Cancel
Save