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

[#2123] Fix zoom bug if zUser is undefined #2126

Merged
merged 6 commits into from
Mar 16, 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: 3 additions & 1 deletion frontend/src/views/c-summary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,9 @@ export default defineComponent({
if (zIsMerged) {
this.mergeGroupByIndex(filtered, 0);
}
[[info.zUser]] = filtered;

if (filtered.length) [[info.zUser]] = filtered;

info.zFileTypeColors = this.fileTypeColors;
info.isRefreshing = false;
this.$store.commit('updateTabZoomInfo', info);
Expand Down
20 changes: 14 additions & 6 deletions frontend/src/views/c-zoom.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang="pug">
#zoom
#zoom(v-if="filteredUser")
.panel-title
span Commits Panel
.toolbar--multiline(v-if="filteredUser.commits.length && totalCommitMessageBodyCount")
Expand Down Expand Up @@ -199,13 +199,13 @@ export default defineComponent({
return (a: Commit, b: Commit) => (this.toReverseSortedCommits ? -1 : 1)
* window.comparator(commitSortFunction)(a, b);
},
filteredUser(): User {
filteredUser(): User | undefined {
const {
zUser, zSince, zUntil, zTimeFrame,
} = this.info;

if (!zUser) {
throw new Error('zUser is not defined');
return undefined;
}

const filteredUser: User = Object.assign({}, zUser);
Expand Down Expand Up @@ -242,11 +242,11 @@ export default defineComponent({

selectedCommits(): Array<Commit> {
if (this.isSelectAllChecked) {
return this.filteredUser.commits;
return this.filteredUser?.commits ?? [];
}

const commits = [] as Array<Commit>;
this.filteredUser.commits.forEach((commit) => {
this.filteredUser?.commits.forEach((commit) => {
const filteredCommit = { ...commit };
filteredCommit.commitResults = [];
commit.commitResults.forEach((slice) => {
Expand Down Expand Up @@ -318,6 +318,12 @@ export default defineComponent({
},
},
created() {
// return if filteredUser is undefined since it won't make sense to render zoom tab
// #zoom-tab is also rendered only if filteredUser is defined
if (!this.filteredUser) {
this.removeZoomHashes();
return;
}
this.initiate();
this.retrieveHashes();
this.setInfoHash();
Expand All @@ -328,7 +334,6 @@ export default defineComponent({

methods: {
initiate() {
// This code crashes if info.zUser is not defined
this.updateFileTypes();
this.selectedFileTypes = this.fileTypes.slice();
},
Expand Down Expand Up @@ -404,6 +409,8 @@ export default defineComponent({
},

updateFileTypes() {
if (!this.filteredUser) return;

const commitsFileTypes = new Set<string>();
this.filteredUser.commits.forEach((commit) => {
commit.commitResults.forEach((slice) => {
Expand Down Expand Up @@ -499,6 +506,7 @@ export default defineComponent({
window.removeHash('zFT');
window.removeHash('zCST');
window.removeHash('zRSC');
window.removeHash('zFR');
window.encodeHash();
},

Expand Down
Loading