Skip to content
Snippets Groups Projects
Commit c55041ba authored by Titus Netland's avatar Titus Netland
Browse files

Merge branch 'bugfix' into 'main'

fix community load times

See merge request !95
parents e830c199 a029578d
No related branches found
No related tags found
1 merge request!95fix community load times
Pipeline #180374 passed
...@@ -32,15 +32,9 @@ ...@@ -32,15 +32,9 @@
<!-- Search field --> <!-- Search field -->
<div class="relative mt-1 mx-2" id="searchComponent"> <div class="relative mt-1 mx-2" id="searchComponent">
<span class="absolute inset-y-0 left-0 flex items-center pl-3"> <span class="absolute inset-y-0 left-0 flex items-center pl-3">
<svg class="w-5 h-5 text-gray-400" viewBox="0 0 24 24" fill="none"> <div class="w-5 h-5 text-gray-400">
<path <SearchIcon />
d="M21 21L15 15M17 10C17 13.866 13.866 17 10 17C6.13401 17 3 13.866 3 10C3 6.13401 6.13401 3 10 3C13.866 3 17 6.13401 17 10Z" </div>
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
></path>
</svg>
</span> </span>
<input <input
...@@ -75,7 +69,7 @@ ...@@ -75,7 +69,7 @@
<script> <script>
import CommunityList from "@/components/CommunityComponents/CommunityList.vue"; import CommunityList from "@/components/CommunityComponents/CommunityList.vue";
import { getMyGroups, getVisibleGroups } from "@/utils/apiutil"; import { getMyGroups, getVisibleGroups } from "@/utils/apiutil";
import { UserAddIcon } from "@heroicons/vue/outline"; import { UserAddIcon, SearchIcon } from "@heroicons/vue/outline";
import PaginationTemplate from "@/components/BaseComponents/PaginationTemplate"; import PaginationTemplate from "@/components/BaseComponents/PaginationTemplate";
export default { export default {
...@@ -102,6 +96,7 @@ export default { ...@@ -102,6 +96,7 @@ export default {
CommunityList, CommunityList,
UserAddIcon, UserAddIcon,
PaginationTemplate, PaginationTemplate,
SearchIcon,
}, },
computed: { computed: {
searchPublicCommunities() { searchPublicCommunities() {
...@@ -152,26 +147,21 @@ export default { ...@@ -152,26 +147,21 @@ export default {
this.updatePageMyCommunities(this.currentPageMyCommunities - 1); this.updatePageMyCommunities(this.currentPageMyCommunities - 1);
} }
}, },
//Triggers when search field input is changed searchWritten() {
searchWritten: function () {
//This method triggers when search input field is changed //This method triggers when search input field is changed
if (this.search.length > 0) { this.showPaginated = this.search.length < 1;
this.showPaginated = false; this.showSearched = this.search.length > 0;
this.showSearched = true; },
} else { async load() {
this.showPaginated = true; this.publicCommunities = await getVisibleGroups();
this.showSearched = false; this.loggedIn = this.$store.state.user.token !== null;
} if (!this.loggedIn) return;
this.myCommunities = await getMyGroups();
}, },
}, },
async beforeMount() { async mounted() {
this.publicCommunities = await getVisibleGroups(); await this.load();
this.loggedIn = this.$store.state.user.token !== null; //Double loop not bad :)
if (!this.loggedIn) return;
this.myCommunities = await getMyGroups();
// Double loop is bad; find a better way to do this
// Loops through both arrays and removes myCommunities from public
for (var i = 0; i < this.publicCommunities.length; i++) { for (var i = 0; i < this.publicCommunities.length; i++) {
for (var j = 0; j < this.myCommunities.length; j++) { for (var j = 0; j < this.myCommunities.length; j++) {
if ( if (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment