File tree 1 file changed +3
-23
lines changed
1 file changed +3
-23
lines changed Original file line number Diff line number Diff line change 1
1
<script lang =' ts' >
2
- import { get } from ' svelte/store'
3
-
4
2
import discordBlueIcon from ' @/assets/discord_blue.svg'
5
3
import reloadIcon from ' @/assets/reload.svg'
6
4
9
7
import { DiscordState } from ' @/models/DiscordState.ts'
10
8
11
9
12
- let state = $conn ?.discordState
13
- let mutable = true
14
-
15
-
16
- const reconnectDiscord = () => {
17
- mutable = false
18
- state = DiscordState .Connecting
19
-
10
+ const reconnectDiscord = () =>
20
11
browser .runtime .sendMessage ({ type: ' reconnect discord' })
21
-
22
- setTimeout (() => {
23
- mutable = true
24
- state = get (conn )?.discordState ?? DiscordState .Disconnected
25
- }, 2000 )
26
- }
27
-
28
-
29
- conn .subscribe (conn => {
30
- if (conn && mutable ) state = conn .discordState
31
- })
32
12
</script >
33
13
34
- <div id ='discord-connection' class:invalid ={state === DiscordState .Disconnected }>
14
+ <div id ='discord-connection' class:invalid ={$conn ?. discordState === DiscordState .Disconnected }>
35
15
<img src ={discordBlueIcon } alt =' Discord icon' />
36
16
37
17
<div >
45
25
{/if }
46
26
</div >
47
27
48
- {#if state === DiscordState .Disconnected }
28
+ {#if $conn ?. discordState === DiscordState .Disconnected }
49
29
<button on:click ={reconnectDiscord } aria-label =' Reconnect' >
50
30
<img src ={reloadIcon } alt =' Reconnect icon' />
51
31
</button >
You can’t perform that action at this time.
0 commit comments