src/main/ChatController.js
/**
 * For each chat to open, loads all its data and saves it to use it when needed.
 */
For each chat to open, loads all its data and saves it to use it when needed.
For each chat to open loads all its data and saves it to use it when needed .
async function startChat() {
    var selfPhoto = await baseService.getPhoto(userWebId);
    if (!selfPhoto) {
        selfPhoto = "https://www.azquotes.com/public/pictures/authors/c3/10/c310c1b5df6fa4f117bf320814e9f39e/5434efd94977a_benedict_of_nursia.jpg";
    }
    $("#selfphoto").attr("src", selfPhoto);
    afterChatOption();
    openChats.forEach(async (chat) => {
        interlocWebId = chat.interlocutor;
        const friendName = await baseService.getFormattedName(chat.interlocutor);
        var friendPhoto;
        if (chat.interlocutor.includes("Group")) {
            friendPhoto = "main/resources/static/img/group.jpg";
        } else {
            friendPhoto = await baseService.getPhoto(chat.interlocutor);
        }
        if (!friendPhoto) {
            friendPhoto = baseService.getDefaultFriendPhoto();
        }
        userDataUrl = chat.storeUrl;
        var semanticChat = await openService.loadChatFromUrl(chat.chatUrl.split("#")[0], userWebId, userDataUrl, chat.interlocutor);
        semanticChat.interlocutorWebId = chat.interlocutor;
        semanticChat.interlocutorName = friendName;
        semanticChat.photo = friendPhoto;
        semanticChats.push(semanticChat);
    });
    openChat = true;
}
async function startChat ( ) { var selfPhoto = await baseService . getPhoto ( userWebId ) ; if ( ! selfPhoto ) { selfPhoto = "https://www.azquotes.com/public/pictures/authors/c3/10/c310c1b5df6fa4f117bf320814e9f39e/5434efd94977a_benedict_of_nursia.jpg" ; } $ ( "#selfphoto" ) . attr ( "src" , selfPhoto ) ; afterChatOption ( ) ; openChats . forEach ( async ( chat ) => { interlocWebId = chat . interlocutor ; const friendName = await baseService . getFormattedName ( chat . interlocutor ) ; var friendPhoto ; if ( chat . interlocutor . includes ( "Group" ) ) { friendPhoto = "main/resources/static/img/group.jpg" ; } else { friendPhoto = await baseService . getPhoto ( chat . interlocutor ) ; } if ( ! friendPhoto ) { friendPhoto = baseService . getDefaultFriendPhoto ( ) ; } userDataUrl = chat . storeUrl ; var semanticChat = await openService . loadChatFromUrl ( chat . chatUrl . split ( "#" ) [ 0 ] , userWebId , userDataUrl , chat . interlocutor ) ; semanticChat . interlocutorWebId = chat . interlocutor ; semanticChat . interlocutorName = friendName ; semanticChat . photo = friendPhoto ; semanticChats . push ( semanticChat ) ; } ) ; openChat = true ; }
For each chat to open, loads all its data and saves it to use it when needed.
For each chat to open loads all its data and saves it to use it when needed .
/* If user has no photo, default is used */ /* If group, default group photo is used */