Skip to content

Commit

Permalink
display name is being properly set now.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian committed Nov 28, 2023
1 parent 6f8b814 commit d487931
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 67 deletions.
21 changes: 13 additions & 8 deletions frontend/components/ThreadPreview/ThreadPreview.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import Conversation from '../conversation/Conversation.vue';
import { MessageData } from '../../lib/global'
import { MessageData, emitter } from '../../lib/global'
import { RouterLink } from 'vue-router';
export type ThreadPreviewInterface = {
Expand All @@ -14,7 +14,7 @@ export type ThreadPreviewInterface = {
type: String,
},
timestamp: {
type: Date,
type: String,
},
remoteNumber: {
type: String,
Expand Down Expand Up @@ -96,16 +96,21 @@ export default {
},
methods: {
routerLinkClickHandler(event) {
if (this.remoteNumber) {
this.$emit("thread-change", this.remoteNumber)
console.log("Hey! you clicked me!")
if(this.displayName){
emitter.emit("thread-change", this.displayName)
console.log(`Hey! you clicked me! I have displayName: ${this.displayName}`)
updateActiveComponent(event)
}
else if (this.remoteNumber) {
emitter.emit("thread-change", this.remoteNumber)
console.log(`Hey! you clicked me! I have remoteNumber: ${this.remoteNumber}`)
updateActiveComponent(event)
}
else if (this.groupUUID) {
this.$emit("thread-change", this.groupUUID)
console.log("Hey! you clicked me!")
updateActiveComponent(event)
emitter.emit("thread-change", this.groupUUID)
console.log(`Hey! you clicked me! I have groupUUID: ${this.groupUUID}`)
updateActiveComponent(event)
}
Expand Down
79 changes: 48 additions & 31 deletions frontend/components/WebTextingContainer/WebTextingContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Conversation from '../conversation/Conversation.vue';
import ThreadList from '../ThreadList/ThreadList.vue'
import ConvoPlaceholder from '../ConvoPlaceholder.vue';
import { RouterView } from 'vue-router';
import { MessageData } from '../../lib/global';
import { emitter } from '../../lib/global';
Expand Down Expand Up @@ -33,34 +33,51 @@ export default {
// type: Array<String>,
// }
// },
name:'WebTextingContainer',
props:{
name: 'WebTextingContainer',
props: {
ownNumber: String,
username:String,
username: String,
threads: Array<Object>,
threadPreviews:Array<Object>
threadPreviews: Array<Object>
},
computed: {
// a computed getter
conversationSelected() {
// `this` points to the component instance
let selectedConvo = false;
if (this.$route.query.number || this.$route.query.group) {
selectedConvo = true;
}
return selectedConvo;
},
},
components: { Conversation, ThreadList },
beforeUpdate() {
console.log(this.props.threadPreviews);
},
methods:{
calculateDisplayName(){
if(this.$route.query.group){
for(let m in this.$props.threadPreviews){
methods: {
calculateDisplayName() {
if (this.$route.query.group) {
for (let m in this.$props.threadPreviews) {
console.log(`group: ${m}`);
}
}
else{
for(let m in this.$props.threadPreviews){
else {
for (let m in this.$props.threadPreviews) {
console.log(`contact: ${m}`);
}
}
console.log("display name calculated");
return "tested";
}
}
},
mounted() {
emitter.on('thread-change', (newDisplayName: String) => {
console.log("WTC event get", newDisplayName)
emitter.emit('thread-changed', newDisplayName);
})
},
}
</script>

Expand All @@ -70,24 +87,24 @@ The blank space should notify the user that they can select a thread to display
<RouterView>


<div id="WEB_TEXT_ROOT">
<link type="text/css" href="../../../js/style.css">
<RouterView name="leftSide" :ownNumber="this.$props.ownNumber"
:threads="this.$props.threads"
:threadPreviews="this.$props.threadPreviews"/>

<suspense>
<RouterView name="rightSide"
:extension_uuid="this.$route.query.extension_uuid"
:remoteNumber="this.$route.query.number"
:groupUUID="this.$route.query.group"
:ownNumber="this.$props.ownNumber"
:displayName="this.$props.threadPreviews"
v-bind="calculateDisplayName"/>
</suspense>
</div>
</RouterView>
<div id="WEB_TEXT_ROOT">
<link type="text/css" href="../../../js/style.css">
<RouterView name="leftSide" :ownNumber="this.$props.ownNumber" :threads="this.$props.threads"
:threadPreviews="this.$props.threadPreviews" />


<suspense>
<RouterView name="rightSide"
:extension_uuid="this.$route.query.extension_uuid"
:remoteNumber="this.$route.query.number"
:groupUUID="this.$route.query.group"
:ownNumber="this.$props.ownNumber"
:displayName="this.$props.displayName"
:selectedConvo="this.conversationSelected"
v-bind="calculateDisplayName" />
</suspense>
</div>
</RouterView>
</template>

<style scoped></style>
50 changes: 30 additions & 20 deletions frontend/components/conversation/Conversation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ export default {
},
groupMembers: {
type: Array<String>,
}
},
selectedConvo: {
type:Boolean,
},
},
components: { Message, SendBox },
async setup(props) {
Expand All @@ -128,22 +131,22 @@ export default {
data() {
let title = "";
if (this.displayName) {
title = this.displayName;
} else if (this.groupMembers) {
title = this.groupMembers.join(", ");
}
if (this.remoteNumber) {
if (title.length > 0) {
title += " (" + this.remoteNumber + ")";
} else {
title += this.remoteNumber;
}
}
else if(this.groupUUID){
title+= this.groupUUID;
}
// if (this.displayName) {
// title = this.displayName;
// } else if (this.groupMembers) {
// title = this.groupMembers.join(", ");
// }
// if (this.remoteNumber) {
// if (title.length > 0) {
// title += " (" + this.remoteNumber + ")";
// } else {
// title += this.remoteNumber;
// }
// }
// else if(this.groupUUID){
// title+= this.groupUUID;
// }
let conversationKey = this.remoteNumber ? this.remoteNumber : this.groupUUID;
return {
bottomVisible: true,
Expand Down Expand Up @@ -207,6 +210,11 @@ export default {
console.log('preventing future backfilling attempts, this conversation has been fully backfilled');
this.backfillAvailable = false;
})
emitter.on('thread-changed', (newDisplayName:String) => {
console.log(`thread changed new display name is ${newDisplayName}`);
this.title = newDisplayName;
})
//console.log(this.state.messages);
//console.log("Conversation.vue mounted with props:\nremoteNumber:", this.remoteNumber, "\ngroupUUID:", this.groupUUID, "\ndisplayName:", this.displayName, "\nownNumber:", this.ownNumber);
},
Expand All @@ -223,7 +231,7 @@ export default {
watch: {
//this fires when we set remoteNumber to null or w/e
remoteNumber: async function (rN) {
this.title = rN;
//this.title = rN;
this.messages = [];
this.backfillAvailable = true;
Expand Down Expand Up @@ -341,7 +349,7 @@ export default {
</script>

<template>
<div class="thread-container" id="THREAD">
<div class="thread-container" v-bind:class="selectedConvo ? 'show-convo': 'hide-if-no-thread'" id="THREAD">
<div class="thread-header">
<router-link class="back-link" :to="`/threadlist.php?extension_uuid=${this.$route.query.extension_uuid}`">Go Back!</router-link>
{{ title }}
Expand Down Expand Up @@ -378,7 +386,9 @@ export default {
}
/* these are for conversation which we are sidestepping for now */
.hide-if-no-thread{
display:none;
}
.messages {
height: 80vh;
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/message/Message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default {
this.text = this.message.cpim.bodyText;
return;
}
console.log(this.message.cpim.fileContentType);
//console.log(this.message.cpim.fileContentType);
switch (this.message.cpim.fileContentType) {
case "text/plain":
this.text = await this.message.cpim.getTextBody()
Expand Down
8 changes: 4 additions & 4 deletions frontend/lib/backfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export async function backfillMessages(extensionUUID: string, remoteNumber?: str
return;
}
if(group){
console.log(`group = ${group}`);
//console.log(`group = ${group}`);
}
if(remoteNumber){
console.log(`group = ${remoteNumber}`);
//console.log(`group = ${remoteNumber}`);
}
fetching = true;
try {
Expand All @@ -48,8 +48,8 @@ export async function backfillMessages(extensionUUID: string, remoteNumber?: str
if (group) {
params.group = group;
}
console.log(`backfilling conversations array, ${state.conversations}`)
console.log(`backfill key: ${key}`)
//console.log(`backfilling conversations array, ${state.conversations}`)
//console.log(`backfill key: ${key}`)
//if state.conversations[key] exists we have already backfilled at least once
const stateMessages = state.conversations[key];
if(stateMessages){
Expand Down
4 changes: 2 additions & 2 deletions frontend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ export const initializeWebTextingContainer = function initializeWebTextingContai
//console.log(`main.ts backfill key ${key}`)
//key is either a uuid or phone number. uuid length is at least 16
if(key.length<15){
//console.log("backfill using remotenumber")
console.log(`backfill using remotenumber: ${key}`)
backfillMessages(opts.extensionUUID, key, null);
}
else{
//console.log("backfill using group")
console.log(`backfill using group ${key}`)
backfillMessages(opts.extensionUUID, null, key);
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const router = createRouter({
path:"/threadlist.php",
components:{
leftSide: ThreadList,
rightSide: ConvoPlaceholderVue,
rightSide: ConversationVue,
},
},
{
Expand Down
8 changes: 8 additions & 0 deletions threadlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,16 @@
$link .= "number=".$number;
}
$thread_preview_opts[$z]['link'] = $link;

//Thread preview area
$body_preview = $last_message['content_type'] == "text/plain" ? $last_message['message'] : "[media]";
/* this is where we need to change stuff to see the removal of [media] as the default preview
if ($last_message['content_type'] == "text/plain" ) {
$body_preview = $last_message['message'];
} else {
$body_preview = s3 retrieve nonsense logic;
}
*/
$thread_preview_opts[$z]['bodyPreview'] = $body_preview;
$thread_preview_opts[$z]['ownNumber'] = $ownNumber;
$thread_preview_opts[$z]['displayName']= $display_name;
Expand Down

0 comments on commit d487931

Please sign in to comment.