Skip to content

Commit

Permalink
inline media has background color white to enhance png transparency
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian committed Nov 8, 2023
1 parent 193e176 commit 648ae2d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
20 changes: 10 additions & 10 deletions frontend/components/conversation/Conversation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ type MessageQuery={
group?: string,
older_than?: string,
}
//i think this is the offending function
const messagesFromState=(key:string) =>{
//console.log(`message from state ${key}`);
return state.conversations[key];
}
const getMessages = async (queryParams: MessageQuery) => {
if(fetchingActive){
//console.log("skipping duplicate message fetches");
Expand All @@ -43,9 +39,11 @@ const getMessages = async (queryParams: MessageQuery) => {
}
if(queryParams.number){
params.number = queryParams.number
//emitter.emit('backfill-requested',params.number);
}
if(queryParams.group){
params.group = queryParams.group
//emitter.emit('backfill-requested',params.group);
}
let key ='';
//console.log(params);
Expand Down Expand Up @@ -74,7 +72,7 @@ const getMessages = async (queryParams: MessageQuery) => {
key = m.from_number
}
}
emitter.emit('backfill-requested',key);
}
fetchingActive = false;
Expand Down Expand Up @@ -118,10 +116,10 @@ const getMessages = async (queryParams: MessageQuery) => {
number: props.remoteNumber });
//const messages = await getMessages(initialQueryParams);
if(props.remoteNumber){
emitter.emit('backfill-requested',props.remoteNumber);
//emitter.emit('backfill-requested',props.remoteNumber);
}
else if(props.groupUUID){
emitter.emit('backfill-requested',props.groupUUID);
//emitter.emit('backfill-requested',props.groupUUID);
}
//console.log(`setup ${messages}`);
Expand Down Expand Up @@ -183,14 +181,15 @@ const getMessages = async (queryParams: MessageQuery) => {
}
if (this.topVisible && this.bottomVisible) {
//console.log('top and bottom of conversation visible, attempting to backfill immediately');
console.log('top and bottom of conversation visible, attempting to backfill immediately');
emitter.emit('backfill-requested',this.conversationKey);
return;
}
//console.log('will backfill if top is still visible in 1 second');
setTimeout(() => {
if (this.topVisible) {
console.log("top still visible backfill")
emitter.emit('backfill-requested',this.conversationKey);
}
}, 5000);
Expand Down Expand Up @@ -227,7 +226,7 @@ const getMessages = async (queryParams: MessageQuery) => {
this.messages = this.state.conversations[rN];
}
this.conversationKey=rN;
emitter.emit("backfill-requested",rN)
//emitter.emit("backfill-requested",rN)
//console.log(observedChangeQueryParams)
}
Expand Down Expand Up @@ -286,6 +285,7 @@ const getMessages = async (queryParams: MessageQuery) => {
case this.$refs.top:
this.topVisible = e.isIntersecting;
if (e.isIntersecting && this.backfillAvailable) {
console.log("isIntersecting and backfillavailable");
emitter.emit('backfill-requested',this.conversationKey);
}
//console.log("top is", e.isIntersecting ? "visible" : "hidden");
Expand Down
2 changes: 2 additions & 0 deletions frontend/components/message/Message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ export default {
.message-body-inline-media {
max-width: 100%;
border-radius: 0.5em;
max-height: 300px;
background-color:white; /* This is for png transparency so the blue / orange message bubble doesn't ruin anything*/
}
/* MESSAGE STYLES */
Expand Down
7 changes: 4 additions & 3 deletions frontend/lib/SIP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function calculatePlainThreadID(message:Message, direction:string, originalTo: s
console.log(`outgoing message to ${originalTo} from ${messageFromUser}.`)
return message.to;
}
}message.request.from.uri.user
}


return'do not add';
Expand All @@ -36,12 +36,12 @@ function calculateCPIMThreadID(cpim:CPIM, direction:string, originalTo: string,
console.log(`calculateCPIMThreadID ${cpim}`);
if(cpim.getHeader("group-uuid")) {
console.log("message is for a group");
//return cpim.getHeader("group-uuid")
return cpim.getHeader("group-uuid")
}
else if ((originalTo || messageFromUser) ) {
console.log(`adding message to conversation between ${originalTo} and ${messageFromUser}.`)
//so addMessage it to the correct thread
//return;
return messageFromUser;
}
return 'do not add';
}
Expand Down Expand Up @@ -107,6 +107,7 @@ function RunSIPConnection(username: string, password: string, server: string, ow
//I think we can rewrite this in a way that just adds the message to the correct destination
// and ignores the conditional ignore situation all together if we implement our Record<threadID, Array<MessageData>> correctly
//TL;DR we need a determineThreadID function
console.log(message.request.getHeader("Content-Type"));
switch (message.request.getHeader("Content-Type")) {
case "text/plain":

Expand Down
21 changes: 9 additions & 12 deletions frontend/lib/backfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let active = false;

export async function backfillMessages(extensionUUID: string, remoteNumber?: string, group?: string) {
if (active) {
//console.log("skipping duplicate backfill request");
console.log("skipping duplicate backfill request");
return;
}

Expand All @@ -51,14 +51,14 @@ export async function backfillMessages(extensionUUID: string, remoteNumber?: str
if (stateMessages.length > 0 && stateMessages[0].id) {
params.older_than = stateMessages[0].id;
}
console.log(stateMessages[0])
console.log(stateMessages[stateMessages.length-1])
//console.log(stateMessages[0])
//console.log(stateMessages[stateMessages.length-1])
}
else{

}

console.log(params)
// console.log(params)
const response: BackfillResponse = await fetch('/app/webtexting/messages.php?' + new URLSearchParams(params).toString()).then(r => r.json());

console.log("received", response.messages.length, "message from backlog");
Expand All @@ -80,10 +80,11 @@ export async function backfillMessages(extensionUUID: string, remoteNumber?: str
case "message/cpim":
if(group){
key = group;
}
}
else{
key = remoteNumber;
}
console.log(`cpim ${m}`);
insertMessageInHistory(key,{
direction: m.direction,
contentType: m.content_type,
Expand Down Expand Up @@ -111,9 +112,7 @@ export async function backfillMessages(extensionUUID: string, remoteNumber?: str
}

export function insertMessageInHistory(key:string, message: MessageData) {
//console.log(`insertMessageInHistory message parameter, ${message}`);
//console.log(`Message Direction: ${message.direction}`)
//console.log(`Message Recipient: ${message.to}`)
//check for message in history
if(state.conversations[key]){
for (let i = 0; i < state.conversations[key].length; i++) {
if (state.conversations[key][i].id == message.id) {
Expand All @@ -127,13 +126,11 @@ export function insertMessageInHistory(key:string, message: MessageData) {
}
}
}
//add a new history if no history is found
else{
state.conversations[key] = new Array<MessageData>();
}


// no existing message matched, append to end
//console.log("before ", state.conversations[key].length);
// no existing message matched, append to end
state.conversations[key].push(message);
console.log("after:", state.conversations[key]);
}
2 changes: 1 addition & 1 deletion frontend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const initializeWebTextingContainer = function initializeWebTextingContai
RunSIPConnection(opts.username, opts.password, opts.server, opts.ownNumber, opts.remoteNumber, opts.groupUUID);

emitter.on('backfill-requested', (key:string) => {
console.log(`backfill key ${key}`)
console.log(`main.ts backfill key ${key}`)
//key is either a uuid or phone number uuid length is at least 16
if(key.length<12){
backfillMessages(opts.extensionUUID, key, opts.groupUUID);
Expand Down

0 comments on commit 648ae2d

Please sign in to comment.