diff --git a/android/app/src/main/assets/public/blah/en-cat.json b/android/app/src/main/assets/public/blah/en-cat.json
index 01daccfb..9364849d 100644
--- a/android/app/src/main/assets/public/blah/en-cat.json
+++ b/android/app/src/main/assets/public/blah/en-cat.json
@@ -144,5 +144,11 @@
"title.settings": "cat settings",
"title.logout": "log out",
"action.edit.profile": "edit cat profile",
- "action.open.dm": "open direct meowchat"
+ "action.open.dm": "open direct meowchat",
+ "action.invite.accept": "accept meow invite",
+ "action.invite.cancel": "hiss away invite",
+ "action.invite.send": "invite to meowchat",
+ "action.profile.loading": "sniffing profile...",
+ "error.profile.load.failed": "failed to sniff profile.",
+ "unknown.author": "somecat"
}
\ No newline at end of file
diff --git a/android/app/src/main/assets/public/blah/en-us.json b/android/app/src/main/assets/public/blah/en-us.json
index 7b26bfb5..4fd12f81 100644
--- a/android/app/src/main/assets/public/blah/en-us.json
+++ b/android/app/src/main/assets/public/blah/en-us.json
@@ -144,5 +144,11 @@
"title.settings": "Settings",
"title.logout": "Log out",
"action.edit.profile": "Edit profile",
- "action.open.dm": "Open DM"
+ "action.open.dm": "Open DM",
+ "action.invite.accept": "Accept invite",
+ "action.invite.cancel": "Cancel invite",
+ "action.invite.send": "Invite to DM",
+ "action.profile.loading": "Loading profile...",
+ "error.profile.load.failed": "Failed to load profile.",
+ "unknown.author": "Someone"
}
\ No newline at end of file
diff --git a/android/app/src/main/assets/public/main.js b/android/app/src/main/assets/public/main.js
index 3c769c62..41253048 100644
--- a/android/app/src/main/assets/public/main.js
+++ b/android/app/src/main/assets/public/main.js
@@ -1467,7 +1467,7 @@ async function openProfile(accountId) {
let popupInner = document.getElementById("profile-popup-inner");
//show loading
- popupInner.innerHTML = '
';
+ popupInner.innerHTML = `${processBlah('action.profile.loading')}
`;
popupContainer.style.display = "flex";
//force reflow
@@ -1496,9 +1496,77 @@ async function openProfile(accountId) {
let bioHtml = bio && bio.trim() !== "" ? `${bio.replace(//g, ">")}
` : "";
let isOwnProfile = accountId === id;
- let actionBtnHtml = isOwnProfile ?
- `` :
- ``;
+ let actionBtnHtml = "";
+ if (isOwnProfile) {
+ actionBtnHtml = ``;
+ } else {
+ let hasDm = false;
+ let dmRoomId = "";
+ if (window.cachedDms) {
+ try {
+ let parsedDms = JSON.parse(window.cachedDms);
+ if (parsedDms.dms) {
+ for (let dmId in parsedDms.dms) {
+ let parts = dmId.split('_');
+ if (parts.length >= 2) {
+ let accStandard = accountId.replace(':', ';');
+ if (!accStandard.includes(';')) accStandard += ';' + host;
+
+ let p0Standard = parts[0].replace(':', ';');
+ if (!p0Standard.includes(';')) p0Standard += ';' + host;
+
+ let p1Standard = parts[1].replace(':', ';');
+ if (!p1Standard.includes(';')) p1Standard += ';' + host;
+
+ if (p0Standard === accStandard || p1Standard === accStandard) {
+ hasDm = true;
+ dmRoomId = dmId;
+ break;
+ }
+ }
+ }
+ }
+ } catch(e){}
+ }
+
+ if (hasDm) {
+ actionBtnHtml = ``;
+ } else {
+ let sentInvite = false;
+ let receivedInvite = false;
+ if (window.cachedInvites) {
+ let checkInvite = (type) => {
+ if (window.cachedInvites[type]) {
+ try {
+ let invites = JSON.parse(window.cachedInvites[type]);
+ if (invites.dms) {
+ for(let key in invites.dms) {
+ let accStandard = accountId.replace(':', ';');
+ if (!accStandard.includes(';')) accStandard += ';' + host;
+
+ let keyStandard = key.replace(':', ';');
+ if (!keyStandard.includes(';')) keyStandard += ';' + host;
+
+ if (keyStandard === accStandard) return true;
+ }
+ }
+ } catch(e){}
+ }
+ return false;
+ };
+ sentInvite = checkInvite('sent');
+ receivedInvite = checkInvite('received');
+ }
+
+ if (receivedInvite) {
+ actionBtnHtml = ``;
+ } else if (sentInvite) {
+ actionBtnHtml = ``;
+ } else {
+ actionBtnHtml = ``;
+ }
+ }
+ }
popupInner.innerHTML = `
${bannerHtml}
@@ -1508,14 +1576,14 @@ async function openProfile(accountId) {
${profileName}
-
${profileName}:${profileHost} (${accountId})
+
${profileName}:${profileHost} (${accountId.split(':')[0]})
${bioHtml}
${actionBtnHtml}
`;
} catch (e) {
- popupInner.innerHTML = '';
+ popupInner.innerHTML = `${processBlah('error.profile.load.failed')}
`;
console.error(e);
}
}
@@ -1608,7 +1676,8 @@ async function renderInvites(res, type) {
.replaceAll("{username}", username.split(':')[0])
.replaceAll("{pfp}", pfp)
.replaceAll("{desc}", desc)
- .replaceAll("{actions}", actions);
+ .replaceAll("{actions}", actions)
+ .replaceAll("{id}", id);
html += entry;
}
@@ -1659,6 +1728,19 @@ async function switchInvitesTab(tab) {
await loadInvites(tab);
}
+async function sendInviteTo(targetId) {
+ try {
+ showAction("action.invite.sending", "invite.action");
+ let res = await fetchEncrypted("user/dm/invite", targetId);
+ clearAction("invite.action");
+ showBlahNotification(res || "success:invite.sent");
+ if (typeof loadInvites === 'function') await loadInvites('sent');
+ } catch (e) {
+ clearAction("invite.action");
+ showBlahNotification("error:something.wrong");
+ }
+}
+
async function acceptInvite(targetId) { //TODO: Implement key generation
try {
showAction("action.invite.accepting", "invite.action");
@@ -1769,10 +1851,12 @@ function gotoJoinSpace() {
switchRoomContent("title.join.space", joinSpaceScreen, false);
}
-async function gotoHome() {
+async function gotoHome(splash = true) {
if (roomsBarContainer) roomsBarContainer.style.display = ""; //show roombar
setActiveSidebarIndicator(sidebarHomeIndicator);
- switchRoomContent("title.splash", splashScreen, false);
+ if (splash) {
+ switchRoomContent("title.splash", splashScreen, false);
+ }
switchRoomsBar("title.home", homeRoomBar);
setActiveRoombarItem(null);
setupWebSocket();
@@ -2010,6 +2094,11 @@ async function openDm(dmId, username, targetId) {
let pfp = await getAvatarUrl(targetId, username);
let iconHtml = `
`;
+
+ if (currentRoomsBarTitle !== "title.home") {
+ gotoHome(false);
+ }
+
await switchRoomContent(username.split(':')[0], chatScreen, true, iconHtml);
let msgContainer = document.getElementById("chat-messages");
@@ -2155,7 +2244,7 @@ async function renderMessages(messages, isPrepend = false) {
respondedAuthorId = parts[1];
}
- let replyAuthor = "Someone";
+ let replyAuthor = processBlah('unknown.author');
let needsAsyncFetch = false;
if (loadedMessages[respondedId] && loadedMessages[respondedId].author !== "0") {
@@ -2183,7 +2272,7 @@ async function renderMessages(messages, isPrepend = false) {
window.replyIdCounter = (window.replyIdCounter || 0) + 1;
if (window.replyIdCounter > 1000000) window.replyIdCounter = 0;
randId = "reply-author-" + window.replyIdCounter;
- replyAuthor = "Someone";
+ replyAuthor = processBlah('unknown.author');
setTimeout(async () => {
try {
let aId = respondedAuthorId;
@@ -2262,10 +2351,10 @@ async function renderMessages(messages, isPrepend = false) {
html += `