Skip to content

Commit

Permalink
Minor corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
markalbrand56 committed Aug 26, 2024
1 parent 118cc02 commit d56724c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"RedesProyecto/backend/models"
"context"
"fmt"
"gosrc.io/xmpp/stanza"
"log"
)

Expand Down Expand Up @@ -236,3 +237,19 @@ func (a *App) ProbeContacts() {
func (a *App) GetCurrentStatus() string {
return chat.User.Status
}

// GetCurrentShow returns the current status message of the user
func (a *App) GetCurrentShow() int {
switch chat.User.Show {
case stanza.PresenceShowChat:
return 0
case stanza.PresenceShowAway:
return 1
case stanza.PresenceShowDND:
return 2
case stanza.PresenceShowXA:
return 3
default:
return 4
}
}
10 changes: 10 additions & 0 deletions cmd/frontend/src/components/LeftPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
UpdateContacts,
SetStatusMessage,
GetCurrentStatus,
GetCurrentShow
} from '../../wailsjs/go/main/App.js'
import Contact from "./Contact.vue";
Expand Down Expand Up @@ -79,6 +80,13 @@ const getStatusMessage = async () => {
User.statusMessage = statusMessage;
}
const getPresence = async () => {
const presence = await GetCurrentShow();
console.log("Presence: ", presence);
User.status = presence;
}
function handleContactClicked(jid) {
console.log("Contact clicked: ", jid);
Expand Down Expand Up @@ -187,7 +195,9 @@ onMounted(() => {
getCurrentUser();
getContacts();
getConferences();
getStatusMessage();
getPresence();
// Event listeners
listenPresenceUpdate();
Expand Down
2 changes: 2 additions & 0 deletions cmd/frontend/wailsjs/go/main/App.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export function GetConferences():Promise<Array<{[key: string]: string}>>;

export function GetContacts():Promise<Array<string>>;

export function GetCurrentShow():Promise<number>;

export function GetCurrentStatus():Promise<string>;

export function GetCurrentUser():Promise<string>;
Expand Down
4 changes: 4 additions & 0 deletions cmd/frontend/wailsjs/go/main/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export function GetContacts() {
return window['go']['main']['App']['GetContacts']();
}

export function GetCurrentShow() {
return window['go']['main']['App']['GetCurrentShow']();
}

export function GetCurrentStatus() {
return window['go']['main']['App']['GetCurrentStatus']();
}
Expand Down

0 comments on commit d56724c

Please sign in to comment.