about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorDokterKaj <54882101+DokterKaj@users.noreply.github.com>2024-09-26 15:31:05 +0800
committerGitHub <noreply@github.com>2024-09-26 15:31:05 +0800
commitf167e6ee7d3a2385d3d9a1c354e89509056d2d4c (patch)
treea56dc039e72d48b7a6de0e8f5f443b45a357120b /src
parent3.0.1 => 3.0.2 (diff)
downloadlibredirect-f167e6ee7d3a2385d3d9a1c354e89509056d2d4c.zip
Switch to remove button for selected instances
Diffstat (limited to 'src')
-rw-r--r--src/pages/options_src/Services/Instances.svelte36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/pages/options_src/Services/Instances.svelte b/src/pages/options_src/Services/Instances.svelte
index 7a04b04e..b37c3904 100644
--- a/src/pages/options_src/Services/Instances.svelte
+++ b/src/pages/options_src/Services/Instances.svelte
@@ -207,20 +207,34 @@
                     <span style="color:{pingCache[instance].color}">{pingCache[instance].value}</span>
                   {/if}
                 </span>
-                <button
-                  class="add"
-                  aria-label="Add instance"
-                  on:click={() => {
-                    if (_options[selectedFrontend]) {
-                      if (!_options[selectedFrontend].includes(instance)) {
+                {#if !_options[selectedFrontend].includes(instance)}
+                  <button
+                    class="add"
+                    aria-label="Add instance"
+                    on:click={() => {
+                      if (_options[selectedFrontend]) {
                         _options[selectedFrontend].push(instance)
                         options.set(_options)
                       }
-                    }
-                  }}
-                >
-                  <AddIcon />
-                </button>
+                    }}
+                  >
+                    <AddIcon />
+                  </button>
+                {:else}
+                  <button
+                    class="add"
+                    aria-label="Remove Instance"
+                    on:click={() => {
+                      const index = _options[selectedFrontend].indexOf(instance)
+                      if (index > -1) {
+                        _options[selectedFrontend].splice(index, 1)
+                        options.set(_options)
+                      }
+                    }}
+                  >
+                    <CloseIcon />
+                  </button>
+                {/if}
               </Row>
               <hr />
             {/each}