Skip to content

Commit

Permalink
perf: Already pass board list as initial state
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Nov 12, 2023
1 parent 339ec86 commit b3cea01
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
14 changes: 9 additions & 5 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@

namespace OCA\Deck\Controller;

use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use \OCP\AppFramework\Http\RedirectResponse;
use OCA\Deck\AppInfo\Application;
use OCA\Deck\Db\Acl;
use OCA\Deck\Db\CardMapper;
use OCA\Deck\Service\BoardService;
use OCA\Deck\Service\CardService;
use OCA\Deck\Service\ConfigService;
use OCA\Deck\Service\PermissionService;
use OCA\Files\Event\LoadSidebar;
use OCA\Text\Event\LoadEditor;
use OCA\Viewer\Event\LoadViewer;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent as CollaborationResourcesEvent;
Expand All @@ -53,6 +54,7 @@ public function __construct(
IRequest $request,
private PermissionService $permissionService,
IInitialStateService $initialStateService,
private BoardService $boardService,
private ConfigService $configService,
private IEventDispatcher $eventDispatcher,
private CardMapper $cardMapper,
Expand All @@ -77,6 +79,8 @@ public function index() {
$this->initialState->provideInitialState(Application::APP_ID, 'canCreate', $this->permissionService->canCreate());
$this->initialState->provideInitialState(Application::APP_ID, 'config', $this->configService->getAll());

$this->initialState->provideInitialState(Application::APP_ID, 'initialBoards', $this->boardService->findAll());

$this->eventDispatcher->dispatchTyped(new LoadSidebar());
$this->eventDispatcher->dispatchTyped(new CollaborationResourcesEvent());
if (class_exists(LoadEditor::class)) {
Expand Down Expand Up @@ -110,19 +114,19 @@ public function indexList(): TemplateResponse {
#[NoAdminRequired]
#[NoCSRFRequired]
public function indexBoard(int $boardId): TemplateResponse {
return $this->index($boardId);
return $this->index();
}

#[NoAdminRequired]
#[NoCSRFRequired]
public function indexBoardDetails(int $boardId): TemplateResponse {
return $this->index($boardId);
return $this->index();
}

#[NoAdminRequired]
#[NoCSRFRequired]
public function indexCard(int $cardId): TemplateResponse {
return $this->index(cardId: $cardId);
return $this->index();
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import AppNavigation from './components/navigation/AppNavigation.vue'
import { NcModal, NcContent, NcAppContent } from '@nextcloud/vue'
import { BoardApi } from './services/BoardApi.js'
import { emit, subscribe } from '@nextcloud/event-bus'
import { loadState } from '@nextcloud/initial-state'
const boardApi = new BoardApi()
Expand Down Expand Up @@ -108,7 +109,10 @@ export default {
},
},
created() {
this.$store.dispatch('loadBoards')
const initialState = loadState('deck', 'initialBoards', null)
if (initialState !== null) {
this.$store.dispatch('loadBoards')
}
this.$store.dispatch('loadSharees')
},
mounted() {
Expand Down
3 changes: 3 additions & 0 deletions src/components/navigation/AppNavigationBoardCategory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,8 @@ export default {
}
},
},
mounted() {
this.opened = this.boards.length > 0
},
}
</script>
2 changes: 1 addition & 1 deletion src/store/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default new Vuex.Store({
sidebarShown: false,
currentBoard: null,
currentCard: null,
boards: [],
boards: loadState('deck', 'initialBoards', []),
sharees: [],
assignableUsers: [],
boardFilter: BOARD_FILTERS.ALL,
Expand Down

0 comments on commit b3cea01

Please sign in to comment.