Skip to content

Commit

Permalink
Fix: locking period and selected tracks (#3070)
Browse files Browse the repository at this point in the history
* fix: locking period and unchange behavior
* fix: selected tracks
  • Loading branch information
Asmadek authored Jan 30, 2025
1 parent 4674a33 commit e45f6a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
21 changes: 5 additions & 16 deletions src/renderer/widgets/EditDelegationModal/model/form-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,12 @@ sample({
fn: (network, { activeDelegations, shards }) => {
const address = toAddress(shards[0].accountId, { prefix: network!.chain.addressPrefix });

return activeDelegations[address].conviction;
return { conviction: activeDelegations[address].conviction, isUnchanged: shards.length > 0 };
},
target: $delegateForm.fields.conviction.onChange,
target: spread({
conviction: $delegateForm.fields.conviction.onChange,
isUnchanged: $delegateForm.fields.isUnchanged.onChange,
}),
});

sample({
Expand All @@ -376,20 +379,6 @@ sample({
target: $delegateForm.fields.amount.onChange,
});

sample({
clock: formInitiated,
filter: ({ shards }) => Object.keys(shards).length > 1,
fn: () => true,
target: $delegateForm.fields.isUnchanged.onChange,
});

sample({
clock: $delegateForm.fields.isUnchanged.onChange,
filter: Boolean,
fn: (): Conviction => 'None',
target: $delegateForm.fields.conviction.onChange,
});

sample({
clock: formInitiated,
source: $networkStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ const $votedTracks = createStore<string[]>([]).reset(formInitiated);
const $delegatedTracks = createStore<string[]>([]).reset(formInitiated);
const $votesToRemove = createStore<VotesToRemove[]>([]).reset(formInitiated);

const $accounts = createStore<Account[]>([]);
const $availableAccounts = createStore<Account[]>([]);
const $delegate = createStore<DelegateAccount | null>(null);
const $isMaxWeightReached = createStore(false);
const $accounts = createStore<Account[]>([]).reset(formInitiated);
const $availableAccounts = createStore<Account[]>([]).reset(formInitiated);
const $delegate = createStore<DelegateAccount | null>(null).reset(formInitiated);
const $isMaxWeightReached = createStore(false).reset(formInitiated);

const $availableTracks = combine(tracksAggregate.$tracks, (tracks) => {
return Object.keys(tracks);
Expand Down

0 comments on commit e45f6a4

Please sign in to comment.