added reorder state changing

This commit is contained in:
Nicolas Constant 2023-08-20 01:33:07 -04:00
parent b41c31b4ac
commit 335cbf4956
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
2 changed files with 17 additions and 4 deletions

View File

@ -7,7 +7,7 @@ import { faCommentAlt, faCalendarAlt } from "@fortawesome/free-regular-svg-icons
import { HotkeysService, Hotkey } from 'angular2-hotkeys';
import { AccountWrapper } from "../../models/account.models";
import { AccountInfo, SelectAccount } from "../../states/accounts.state";
import { AccountInfo, ReorderAccounts, SelectAccount } from "../../states/accounts.state";
import { NavigationService, LeftPanelType } from "../../services/navigation.service";
import { UserNotificationService, UserNotification } from '../../services/user-notification.service';
import { ToolsService } from '../../services/tools.service';
@ -169,14 +169,12 @@ export class LeftSideBarComponent implements OnInit, OnDestroy {
}
onDrop(event: CdkDragDrop<AccountWithNotificationWrapper[]>) {
console.warn(event);
if (event.previousContainer === event.container) {
moveItemInArray(event.container.data,
event.previousIndex,
event.currentIndex);
console.warn(this.accounts);
this.store.dispatch([new ReorderAccounts(this.accounts.map(x => x.info))])
}
}

View File

@ -6,6 +6,11 @@ export class AddAccount {
constructor(public account: AccountInfo) {}
}
export class ReorderAccounts {
static readonly type = '[Accounts] Reorder';
constructor(public accounts: AccountInfo[]) {}
}
export class SelectAccount {
static readonly type = '[Accounts] Select account';
constructor(public account: AccountInfo, public multiselection: boolean = false) {}
@ -46,6 +51,16 @@ export class AccountsState {
});
}
@Action(ReorderAccounts)
ReorderAccounts(ctx: StateContext<AccountsStateModel>, action: ReorderAccounts){
// const state = ctx.getState();
const reorderedAccounts = action.accounts;
ctx.patchState({
accounts: [...reorderedAccounts]
});
}
@Action(UpdateAccount)
UpdateAccount(ctx: StateContext<AccountsStateModel>, action: UpdateAccount){
const state = ctx.getState();