Skip to content

Commit

Permalink
- Modularized global keys
Browse files Browse the repository at this point in the history
  • Loading branch information
vinicioslc committed Dec 12, 2019
1 parent 4a7d530 commit f9a7ec1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
7 changes: 3 additions & 4 deletions src/adb-actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { execSync } from 'child_process'
import { NetHelpers } from '../ip-helpers'
import { log } from 'util'

export class ADBInterface {
static ConnectToDevice(deviceIP: string): ADBResult {
Expand Down Expand Up @@ -75,7 +74,7 @@ export class ADBInterface {
return result
}

static disableFirebaseEventsDebug({ package_name }): string {
static disableFirebaseEventsDebug(): string {
const result = execSync(
`adb shell setprop debug.firebase.analytics.app .none.`
).toString()
Expand Down Expand Up @@ -116,8 +115,8 @@ export class ADBInterface {
const output = result.toLocaleString()
if (output.startsWith('List of devices attached')) {
let ips = output.split(/[\r]|[\n]/gim)
ips = ips.filter((ip, index, array) => this.testIP(ip))
ips = ips.map((ipAddress, index, array) => {
ips = ips.filter(ip => this.testIP(ip))
ips = ips.map(ipAddress => {
let nameOfDevice = this.getDeviceName(
this.extractIPAddress(ipAddress)
)
Expand Down
7 changes: 7 additions & 0 deletions src/extension/global-state-keys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Store all keys for extension state management
*/
export default {
allPackages: 'last_app_package_name',
lastIPUsed: 'lastIPAddress'
}
10 changes: 4 additions & 6 deletions src/extension/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ADBResultState, ADBInterface } from '../adb-actions'
import * as FirebaseExtension from '../firebase-actions'
import * as vscode from 'vscode'
import stateKeys from './global-state-keys'

export async function ResetDevicesPort() {
vscode.window.withProgress(
Expand Down Expand Up @@ -29,10 +30,8 @@ export async function ResetDevicesPort() {
// Display a message box to the user
}

const LastIPAddressKey = 'lastIPAddress'

export async function ConnectToDevice(context: vscode.ExtensionContext) {
let lastvalue = context.globalState.get(LastIPAddressKey, '')
let lastvalue = context.globalState.get(stateKeys.lastIPUsed, '')
// The code you place here will be executed every time your command is executed
vscode.window
.showInputBox({
Expand All @@ -49,7 +48,7 @@ export async function ConnectToDevice(context: vscode.ExtensionContext) {
}

function connectToAdbDevice(context: vscode.ExtensionContext, value: string) {
context.globalState.update(LastIPAddressKey, value)
context.globalState.update(stateKeys.lastIPUsed, value)
try {
vscode.window.withProgress(
{
Expand Down Expand Up @@ -132,12 +131,11 @@ export async function KillADBServer() {
}
}

const allPackages = 'last_app_package_name'
export async function EnableFirebaseDebugView(
context: vscode.ExtensionContext
) {
try {
let lastvalue = context.globalState.get(allPackages, [])
let lastvalue = context.globalState.get(stateKeys.allPackages, [])

let packageName = await vscode.window.showInputBox({
placeHolder: 'com.yourapp.domain',
Expand Down

0 comments on commit f9a7ec1

Please sign in to comment.