Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show what a user is watching in the user info menu #385

Merged
merged 3 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions assets/chat/js/menus/ChatUserInfoMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export default class ChatUserInfoMenu extends ChatMenuFloating {

this.header = this.ui.find('.toolbar span');

this.watchingSubheader = this.ui.find(
'.user-info h5.watching-subheader',
)[0];

this.createdDateSubheader = this.ui.find('.user-info h5.date-subheader')[0];

this.tagSubheader = this.ui.find('.user-info h5.tag-subheader')[0];
Expand Down Expand Up @@ -237,6 +241,15 @@ export default class ChatUserInfoMenu extends ChatMenuFloating {
const tagNote = this.chat.taggednotes.get(this.clickedNick);
const usernameFeatures = selectedUser.classList.value;

const watchingEmbed = this.buildWatchingEmbed(this.clickedNick);
if (watchingEmbed !== '') {
this.watchingSubheader.style.display = '';
this.watchingSubheader.replaceChildren('Watching: ', watchingEmbed);
} else {
this.watchingSubheader.style.display = 'none';
this.watchingSubheader.replaceChildren();
}

const formattedDate = this.buildCreatedDate(this.clickedNick);
if (formattedDate) {
this.createdDateSubheader.style.display = '';
Expand Down Expand Up @@ -292,6 +305,14 @@ export default class ChatUserInfoMenu extends ChatMenuFloating {
this.redraw();
}

buildWatchingEmbed(nick) {
const user = this.chat.users.get(nick);
if (!user?.watching) {
return '';
}
return `${user.watching.id} on ${user.watching.platform}`;
}

buildCreatedDate(nick) {
const user = this.chat.users.get(nick.toLowerCase());
if (!user?.createdDate) {
Expand Down
1 change: 1 addition & 0 deletions assets/views/embed.html
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ <h5><span>Users</span> <i class="chat-menu-close"></i></h5>
<h5><span>User Info</span> <i class="chat-menu-close"></i></h5>
</div>
<div class="user-info">
<h5 class="watching-subheader">Watching:</h5>
<h5 class="date-subheader"></h5>
<h5 class="tag-subheader"></h5>
<h5 class="flairs-subheader">Flairs:</h5>
Expand Down