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 3 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 @@ -899,7 +899,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
22 changes: 15 additions & 7 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 Down Expand Up @@ -404,15 +410,16 @@ export default defineComponent({
},

updateFileTypes() {
// Assert that this.filteredUser is not undefined since this method is called in the created hook
const commitsFileTypes = new Set<string>();
this.filteredUser.commits.forEach((commit) => {
this.filteredUser!.commits.forEach((commit) => {
commit.commitResults.forEach((slice) => {
Object.keys(slice.fileTypesAndContributionMap).forEach((fileType) => {
commitsFileTypes.add(fileType);
});
});
});
this.fileTypes = Object.keys(this.filteredUser.fileTypeContribution).filter(
this.fileTypes = Object.keys(this.filteredUser!.fileTypeContribution).filter(
vvidday marked this conversation as resolved.
Show resolved Hide resolved
(fileType) => commitsFileTypes.has(fileType),
);
},
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