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

Improve avatar loading #1204

Merged
merged 8 commits into from
Sep 29, 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
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ module.exports = {
destructuring: 'all'
}
],
'vue/component-name-in-template-casing': ['error', 'kebab-case'],
'vue/multi-word-component-names': 'off',
'vue/no-use-v-if-with-v-for': 'off'
'vue/no-use-v-if-with-v-for': 'off',
'vue/prop-name-casing': ['error', 'camelCase']
},
globals: {
Canny: true
Expand Down
6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"vue-drag-drop": "1.1.4",
"vue-feather-icons": "5.1.0",
"vue-i18n": "8.28.2",
"vue-lazyload": "1.3.5",
"vue-meta": "2.4.0",
"vue-router": "3.6.5",
"vue-scroll": "2.1.13",
Expand Down
2 changes: 1 addition & 1 deletion src/components/cells/TimeSliderCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default {
},

props: {
'task-id': {
taskId: {
type: String,
default: ''
},
Expand Down
63 changes: 14 additions & 49 deletions src/components/cells/ValidationCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@click="onClick"
>
<div class="wrapper" v-if="!minimized">
<span v-if="task">
<template v-if="task">
<span
class="tag"
:title="taskStatus.name"
Expand Down Expand Up @@ -59,31 +59,17 @@
>
&nbsp; &nbsp; &nbsp; &nbsp;
</span>
</span>
<span> </span>
</template>
<span
class="avatar has-text-centered"
:title="personMap.get(personId).full_name"
:style="{
background: personMap.get(personId).color,
width: '20px',
height: '20px',
'font-size': '10px'
}"
:key="'avatar-' + personId"
v-for="personId in assignees"
:title="person.full_name"
:style="{ background: person.color }"
:key="`avatar-${person.id}`"
v-for="person in assignees"
v-if="isAssignees && !isCurrentUserClient && !disabled"
>
<img
v-lazy="avatarPath(personId)"
:key="avatarKey(personId)"
width="20"
height="20"
v-if="personMap.get(personId).has_avatar"
/>
<span v-else>
{{ personMap.get(personId).initials }}
</span>
<img loading="lazy" :src="person.avatarPath" v-if="person.has_avatar" />
<template v-else>{{ person.initials }}</template>
</span>
<span class="subscribed" v-if="task && task.is_subscribed">
<eye-icon size="0.8x" />
Expand Down Expand Up @@ -216,11 +202,9 @@ export default {
]),

assignees() {
if (this.task) {
return this.task.assignees
} else {
return []
}
return (
this.task?.assignees.map(personId => this.personMap.get(personId)) || []
)
},

backgroundColor() {
Expand Down Expand Up @@ -346,24 +330,6 @@ export default {
}
},

avatarPath(personId) {
const person = this.personMap.get(personId)
if (person) {
return person.avatarPath + '?unique=' + person.uniqueHash
} else {
return ''
}
},

avatarKey(personId) {
const person = this.personMap.get(personId)
if (person) {
return person.id + '-' + person.uniqueHash
} else {
return ''
}
},

changeStyleBasedOnSelected() {
if (this.selected) {
const background = this.isDarkTheme ? '#5E60BA' : '#BFC1FF'
Expand Down Expand Up @@ -445,10 +411,9 @@ span.person-avatar:nth-child(2) {
align-items: center;
justify-content: center;
margin-right: 2px;
}

.avatar span {
flex: 1;
width: 20px;
height: 20px;
font-size: 10px;
}

.avatar img {
Expand Down
3 changes: 1 addition & 2 deletions src/components/modals/EditCommentModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{{ $t('comments.edit_title') }}
</h1>

<form v-on:submit.prevent>
<form @submit.prevent>
<combo-box-status
:label="$t('task_status.title')"
:task-status-list="taskStatusForCurrentUser"
Expand All @@ -31,7 +31,6 @@
class="flexrow-item"
:person="team.item"
:size="20"
:no-cache="true"
/>
<span class="flexrow-item">
{{ team.item.full_name }}
Expand Down
1 change: 0 additions & 1 deletion src/components/pages/Episode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
:empty-width="103"
:empty-height="103"
:with-link="false"
:no-cache="true"
/>
<div class="break-word">
{{ asset.asset_name }}
Expand Down
5 changes: 2 additions & 3 deletions src/components/pages/Logs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
</li>
</ul>
</div>

<Events v-if="isActiveTab('events')" />
<PreviewFiles v-if="isActiveTab('preview_files')" />
<events v-if="isActiveTab('events')" />
<preview-files v-if="isActiveTab('preview_files')" />
</div>
</template>

Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/MyChecks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
{{ nbTasksToCheck }} tasks to check
</h1>
<div class="filler"></div>
<ButtonSimple
<button-simple
class="flexrow-item"
@click="isPlaylist = true"
text="Build playlist from list"
Expand Down
9 changes: 2 additions & 7 deletions src/components/pages/People.vue
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,8 @@ export default {
},

deleteText() {
const person = this.personToDelete
if (person !== undefined) {
const personName = `${person.first_name} ${person.last_name}`
return this.$t('people.delete_text', { personName })
} else {
return ''
}
const personName = this.personToDelete?.full_name
return personName ? this.$t('people.delete_text', { personName }) : ''
},

filteredPeople() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/ProductionSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</div>

<div class="tab" v-show="isActiveTab('brief')">
<ProductionBrief />
<production-brief />
</div>

<div class="tab" v-show="isActiveTab('assetTypes')">
Expand Down
18 changes: 9 additions & 9 deletions src/components/pages/Profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
<div class="has-text-centered profile-header">
<div class="profile-header-content has-text-centered">
<people-avatar
ref="avatar"
:no-cache="true"
:is-lazy="false"
:person="this.user"
:size="150"
:font-size="60"
Expand Down Expand Up @@ -1071,14 +1070,15 @@ export default {
uploadAvatarFile() {
this.changeAvatar.isLoading = true
this.changeAvatar.isError = false
this.uploadAvatar(err => {
if (err) {
this.uploadAvatar()
.catch(err => {
console.error(err)
this.changeAvatar.isError = true
}
this.changeAvatar.isLoading = false
this.$refs.avatar.reloadAvatar()
this.hideAvatarModal()
})
})
.finally(() => {
this.changeAvatar.isLoading = false
this.hideAvatarModal()
})
},

hideAvatarModal() {
Expand Down
1 change: 0 additions & 1 deletion src/components/pages/Sequence.vue
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@
:empty-width="103"
:empty-height="103"
:with-link="false"
:no-cache="true"
/>
<div class="break-word">
{{ asset.asset_name }}
Expand Down
1 change: 0 additions & 1 deletion src/components/pages/Shot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@
:empty-width="103"
:empty-height="103"
:with-link="false"
:no-cache="true"
/>
<div class="break-word">
{{ asset.asset_name }}
Expand Down
1 change: 0 additions & 1 deletion src/components/pages/TaskType.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,6 @@ export default {
avatar: true,
has_avatar: person.has_avatar,
avatarPath: person.avatarPath,
uniqueHash: person.uniqueHash,
initials: person.initials,
id: person.id,
name: person.full_name,
Expand Down
8 changes: 2 additions & 6 deletions src/components/pages/breakdown/AssetBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@
<div class="asset-add" @click="removeOneAsset" v-if="!readOnly">- 1</div>
<div class="asset-picture" v-if="asset.preview_file_id">
<img
v-lazy="
'/api/pictures/thumbnails-square/preview-files/' +
asset.preview_file_id +
'.png'
"
alt=""
loading="lazy"
:src="`/api/pictures/thumbnails-square/preview-files/${asset.preview_file_id}.png`"
/>
<span class="nb-occurences" v-if="nbOccurences > 1">
{{ nbOccurences }}
Expand Down
8 changes: 2 additions & 6 deletions src/components/pages/breakdown/AvailableAssetBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@
<div class="asset-add-10" @click="addTenAssets">+ 10</div>
<div class="asset-picture" v-if="asset.preview_file_id.length > 0">
<img
v-lazy="
'/api/pictures/thumbnails-square/preview-files/' +
asset.preview_file_id +
'.png'
"
alt=""
loading="lazy"
:src="`/api/pictures/thumbnails-square/preview-files/${asset.preview_file_id}.png`"
/>
</div>
<div class="asset-picture" v-else>
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/playlists/RawVideoPlayer.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div ref="container" class="video-wrapper filler flexrow-item">
<div class="video-loader" v-show="isLoading">
<Spinner class="mt2" style="color: white" />
<spinner class="mt2" style="color: white" />
</div>
<video
ref="player1"
Expand Down
1 change: 0 additions & 1 deletion src/components/pages/schedule/Schedule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
:is-link="false"
:font-size="14"
:size="28"
:no-cache="true"
v-else
/>
</span>
Expand Down
2 changes: 1 addition & 1 deletion src/components/sides/PeopleQuotaInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>

<div class="flexrow">
<people-avatar class="flexrow-item" :person="person" :no-cache="true" />
<people-avatar class="flexrow-item" :person="person" :is-lazy="false" />
<page-title class="flexrow-item" :text="person.full_name" />
</div>
<div class="info-date" v-if="isMonthInfo">{{ monthString }} {{ year }}</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/sides/PeopleTimesheetInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>

<div class="flexrow">
<people-avatar class="flexrow-item" :person="person" :no-cache="true" />
<people-avatar class="flexrow-item" :person="person" :is-lazy="false" />
<page-title class="flexrow-item" :text="person.full_name" />
</div>

Expand Down
7 changes: 3 additions & 4 deletions src/components/tops/GlobalSearchField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,9 @@ export default {
this.searchData({ query: this.searchQuery })
.then(results => {
this.assets = results.assets
results.persons.forEach(person => {
peopleStore.helpers.addAdditionalInformation(person)
})
this.persons = results.persons
this.persons = results.persons.map(
peopleStore.helpers.addAdditionalInformation
)
this.shots = results.shots
})
.catch(console.error)
Expand Down
13 changes: 3 additions & 10 deletions src/components/tops/Topbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div
id="c-mask-user-menu"
@click="toggleUserMenu()"
v-bind:class="{ 'is-active': !isUserMenuHidden }"
:class="{ 'is-active': !isUserMenuHidden }"
></div>

<nav class="nav">
Expand Down Expand Up @@ -121,11 +121,10 @@
@click="toggleUserMenu"
>
<people-avatar
ref="avatar"
class="avatar"
:no-cache="true"
:person="user"
:is-lazy="false"
:is-link="false"
:person="user"
/>
</div>
</div>
Expand Down Expand Up @@ -809,12 +808,6 @@ export default {
) {
this.incrementNotificationCounter()
}
},

'person:update'(eventData) {
if (this.user.id === eventData.person_id) {
this.$refs.avatar.reloadAvatar()
}
}
}
}
Expand Down
Loading