Skip to content

Commit

Permalink
small refactor & fix safe dropdown options
Browse files Browse the repository at this point in the history
  • Loading branch information
gsteenkamp89 committed Apr 25, 2024
1 parent 4e80970 commit 895b0e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/plugins/oSnap/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ onMounted(async () => {
<CreateSafe
v-for="(safe, i) in newPluginData.safes"
:key="`${safe.network}:${safe.safeAddress}`"
:safe-index="i"
:safe="safe"
@remove-safe="removeSafe"
@update-safe="updateSafe"
:all-safes="allSafes"
:unconfigured-safes="unconfiguredSafes"
@remove-safe="() => removeSafe(i)"
@update-safe="safe => updateSafe(safe, i)"
/>
</div>
<TuneButton
Expand Down
18 changes: 9 additions & 9 deletions src/plugins/oSnap/CreateSafe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import BotSupportWarning from './components/BotSupportWarning.vue';
// PROPS
const props = defineProps<{
allSafes: GnosisSafe[];
unconfiguredSafes: GnosisSafe[];
safe: GnosisSafe;
safeIndex: number;
}>();
// VARS
const configuredSafe = ref<GnosisSafe | null>(null);
const configuredSafe = ref<GnosisSafe>();
const tokens = ref<Token[]>([]);
const collectibles = ref<NFT[]>([]);
const isLoading = ref(false);
Expand All @@ -24,20 +24,20 @@ const isLoading = ref(false);
// emits an event with the shape expected by the parent of the plugin component
const emit = defineEmits<{
updateSafe: [value: GnosisSafe, index: number];
updateSafe: [value: GnosisSafe];
addSafe: [value: GnosisSafe];
removeSafe: [value: number];
removeSafe: [];
}>();
// METHODS
function update(newlyConfiguredSafe: GnosisSafe) {
emit('updateSafe', newlyConfiguredSafe, props.safeIndex);
emit('updateSafe', newlyConfiguredSafe);
}
// METHODS
function removeSafe() {
if (configuredSafe.value) {
emit('removeSafe', props.safeIndex);
emit('removeSafe');
}
}
Expand All @@ -49,7 +49,7 @@ function replaceSafe(safe: GnosisSafe | null) {
}
function addTransaction(transaction: Transaction) {
if (configuredSafe.value === null) return;
if (!configuredSafe.value) return;
configuredSafe.value.transactions.push(transaction);
}
Expand Down Expand Up @@ -108,8 +108,8 @@ onMounted(async () => {
<h2 class="text-md">Add oSnap transactions</h2>
<h3 class="text-base">Pick a safe</h3>
<SelectSafe
:safes="allSafes"
:selectedSafe="configuredSafe"
:safes="[...unconfiguredSafes, configuredSafe ?? props.safe]"
:selectedSafe="configuredSafe ?? props.safe"
@updateSafe="replaceSafe($event)"
/>
<BotSupportWarning
Expand Down

0 comments on commit 895b0e9

Please sign in to comment.