Skip to content

Commit

Permalink
Adding a finer menu for support including copy to clipboard and sendi…
Browse files Browse the repository at this point in the history
…ng a mail
  • Loading branch information
shech2 committed Dec 25, 2023
1 parent 15e91fd commit abc0d84
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -993,12 +993,27 @@ async function supportCMD(shell: Shell) {
email = await shell.askValue("Enter your email address")
}

// Menu to ask user if they want to send the log or Post it to mail
const fields = [
{prompt: "Copy log to clipboard"},
{prompt: "Send log to support"}
]

// Saving the log to the clipboard
terminal7.dumpLog()
// Ask user for choice
let choice = await shell.runForm(fields,"menu" , "Choose an option")

Check failure on line 1003 in src/commands.ts

View workflow job for this annotation

GitHub Actions / test

'choice' is never reassigned. Use 'const' instead

Check failure on line 1003 in src/commands.ts

View workflow job for this annotation

GitHub Actions / test

'choice' is never reassigned. Use 'const' instead

// send the log to the server
const res = await fetch(`${schema}://${terminal7.conf.net.peerbook}/support`, {
// Check the choice and perform the action
if (choice == "Copy log to clipboard") {
// Saving the log to the clipboard
let log = terminal7.dumpLog()

Check failure on line 1008 in src/commands.ts

View workflow job for this annotation

GitHub Actions / test

'log' is never reassigned. Use 'const' instead

Check failure on line 1008 in src/commands.ts

View workflow job for this annotation

GitHub Actions / test

'log' is never reassigned. Use 'const' instead
await Clipboard.write({string: (await log).toString()})
shell.t.writeln("Log copied to clipboard.")
shell.t.writeln("Please paste into discord support channel.")
}
// Send log to support
else if (choice == "Send log to support") {
shell.t.writeln("Sending log to support...")
const res = await fetch(`${schema}://${terminal7.conf.net.peerbook}/support`, {
method: "POST",
body: JSON.stringify({
email,
Expand All @@ -1007,13 +1022,14 @@ async function supportCMD(shell: Shell) {
})

// check the response
if (res.ok) {
if (res.ok) {
shell.t.writeln("Thank you for your feedback.")
}
else {
else {
shell.t.writeln("Error sending feedback.")
shell.t.writeln("Please send us a message in discord.")
shell.t.writeln("Please send us a message in discord support channel.")
}
}
}
async function loginCMD(shell: Shell) {
if (terminal7.pb.isOpen()) {
Expand Down

0 comments on commit abc0d84

Please sign in to comment.