Skip to content

Commit f1b2350

Browse files
committed
fix: pressing the toolbar button twice should do nothing if already active
#2
1 parent 06d64bd commit f1b2350

3 files changed

Lines changed: 10 additions & 12 deletions

File tree

‎doc/design.md‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ This is how user actions are handled:
1818
* ~~When the text is changed in the compose window, `compose` sends the update to `background`, which relays it to the server, which updates the text editor.~~ (Not until v2.0.0)
1919
1. The WebSocket connection remains open until one of the following happens:
2020
* a) When the server closes the WebSocket connection, which `background` detects and notifies `compose`.
21-
* b) When the compose window is closed, `compose` closes the `Port`, which `background` detects and closes the WebSocket connection.
21+
* b) When the shortcut key assigned to the close function is pressed, `compose` closes the `Port`, which `background` detects and closes the WebSocket connection.
22+
* c) When the compose window is closed, `compose` closes the `Port`, handled as the same as (b).
2223
1. The compose window returns to its normal state and the button is toggled off.
2324

2425
### The options page
@@ -81,11 +82,8 @@ loop
8182
B->>C: Close the port
8283
end
8384
else
84-
break When the Ghostbird button has been clicked again
85-
B->>B: User clicks the Ghostbird button
86-
B->>C: Request a graceful close
87-
C->>B: Send Last update
88-
B->>S: Send Last update
85+
break When the close shortcut key is pressed
86+
B->>B: User types the shortcut key
8987
B->>C: Close the port
9088
B->>S: Close the WebSocket
9189
end

‎src/app-background/background_event_router.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class BackgroundEventRouter {
4848
return Promise.reject(Error("Event dropped"))
4949
}
5050

51-
return this.composeActionNotifier.toggle(composeTab)
51+
return this.composeActionNotifier.start(composeTab)
5252
}
5353

5454
/** handles one-off messages from content scripts */

‎src/app-background/compose_action_notifier.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class ComposeActionNotifier {
1010

1111
async start(tab: IComposeWindow): Promise<void> {
1212
if (this.findOpenPort(tab)) {
13-
console.log("Port is open; skipping")
13+
console.info("Port is already open; skipping")
1414
return
1515
}
1616
await tab.prepareContentScript()
@@ -19,11 +19,11 @@ export class ComposeActionNotifier {
1919
this.runners.set(tab.tabId, port)
2020

2121
try {
22-
console.log("starting session")
22+
console.info("starting session")
2323
let editor = new EmailEditor(tab, port)
2424
await this.ghostTextRunner.run(editor, editor)
2525
} finally {
26-
console.log("session closed")
26+
console.info("session closed")
2727
this.close(tab, port)
2828
}
2929
}
@@ -35,10 +35,10 @@ export class ComposeActionNotifier {
3535
async toggle(tab: IComposeWindow): Promise<void> {
3636
let port = this.findOpenPort(tab)
3737
if (port) {
38-
console.log("toggle: closing")
38+
console.info("toggle: closing")
3939
this.close(tab, port)
4040
} else {
41-
console.log("toggle: starting")
41+
console.info("toggle: starting")
4242
await this.start(tab)
4343
}
4444
}

0 commit comments

Comments
 (0)