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

Animated avatar in user card #1112

Merged
merged 2 commits into from
Nov 14, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG-nightly.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 3.1.5.2000

- Added animated avatars to 7TV user card

### 3.1.5.1000

- Entitlements like paints and badges should now better reflect what the user has equipped
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### 3.1.5

- Entitlements like paints and badges should now better reflect what the user has equipped
- Fixed an issue with entitlements on accounts with multiple connections
- Fixed an issue with causing animated avatars to not work
- Added animated avatars to 7TV user card

### 3.1.4

- Fixed an issue with avatars not loading
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Improve your viewing experience on Twitch & YouTube with new features, emotes, vanity and performance.",
"private": true,
"version": "3.1.5",
"dev_version": "1.0",
"dev_version": "2.0",
"scripts": {
"start": "cross-env NODE_ENV=dev yarn build:dev && cross-env NODE_ENV=dev vite --mode dev",
"build:section:app": "vite build --config vite.config.mts",
Expand Down
18 changes: 15 additions & 3 deletions src/app/chat/UserCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
</div>

<div class="seventv-user-card-avatar">
<img v-if="data.targetUser.avatarURL" :src="data.targetUser.avatarURL" />
<img v-if="avatarURL" :src="avatarURL" />
<img v-else-if="data.targetUser.avatarURL" :src="data.targetUser.avatarURL" />
</div>
<div class="seventv-user-card-usertag-container">
<a :href="getProfileURL()" target="_blank" class="seventv-user-card-usertag">
Expand Down Expand Up @@ -123,7 +124,7 @@
</template>

<script setup lang="ts">
import { nextTick, onMounted, reactive, ref, watch, watchEffect } from "vue";
import { computed, nextTick, onMounted, reactive, ref, watch, watchEffect } from "vue";
import { useI18n } from "vue-i18n";
import { storeToRefs } from "pinia";
import { useStore } from "@/store/main";
Expand All @@ -137,6 +138,7 @@ import { useChatMessages } from "@/composable/chat/useChatMessages";
import { useChatTools } from "@/composable/chat/useChatTools";
import { useApollo } from "@/composable/useApollo";
import { useCosmetics } from "@/composable/useCosmetics";
import { getModuleRef } from "@/composable/useModule";
import { TwTypeChatBanStatus, TwTypeModComment } from "@/assets/gql/tw.gql";
import {
twitchUserCardMessagesQuery,
Expand Down Expand Up @@ -230,6 +232,14 @@ const data = reactive({
},
});

const avatarURL = computed(() => {
if (!data.targetUser.username) return;
const aMod = getModuleRef("avatars").value;
if (!aMod?.instance?.avatars) return;
const avatar = aMod.instance.avatars[data.targetUser.username] as SevenTV.Cosmetic<"AVATAR"> | undefined;
return avatar?.data.user.avatar_url;
});

function getActiveTimeline(): Record<string, ChatMessage[]> {
return data.timelines[data.activeTab];
}
Expand Down Expand Up @@ -674,8 +684,10 @@ main.seventv-user-card-container {
display: grid;
align-content: center;
justify-content: center;
padding: 0.5rem;
padding: 1rem;
grid-area: avatar;
height: 8rem;
width: 8rem;

img {
clip-path: circle(50% at 50% 50%);
Expand Down
2 changes: 2 additions & 0 deletions src/site/twitch.tv/modules/avatars/AvatarsModule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ onUnmounted(() => {
}
});

defineExpose({ avatars });

markAsReady();
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/types/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ declare namespace SevenTV {

interface CosmeticAvatar {
id: ObjectID;
user: Pick<User, "id" | "username" | "display_name" | "connections">;
user: Pick<User, "id" | "username" | "display_name" | "connections" | "avatar_url">;
host: ImageHost;
}

Expand Down
Loading