From 6f770a04cf10a7cee92ee21f41749d77c2456c29 Mon Sep 17 00:00:00 2001 From: kPherox Date: Tue, 30 Apr 2019 14:39:46 +0900 Subject: [PATCH] Fix set authorize client --- src/main/Client.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/Client.ts b/src/main/Client.ts index 57d0c7b3..0a463af2 100644 --- a/src/main/Client.ts +++ b/src/main/Client.ts @@ -2,6 +2,7 @@ import { app } from "electron" import Mastodon from 'megalodon' import Datastore from "nedb" import { join } from "path" + type Protocol = 'http' | 'websocket' export default class Clients { @@ -11,7 +12,7 @@ export default class Clients { // Non-authorized Accounts. keyには`domain`を設定します private static nonAuthorizedHTTP: Map = new Map() - private static nonAuthorizedWebsocket: Map = new Map() + private static nonAuthorizedWebSocket: Map = new Map() public static getAuthClient(username: string, protocol: Protocol = 'http'): Mastodon { let clients = protocol === 'http' ? this.authorizedHTTP : this.authorizedWebSocket @@ -28,14 +29,14 @@ export default class Clients { } else { Clients.setAuthClient(protocol, username, Clients.createAuthClient(protocol, docs.domain, docs.accessToken)) } - }); + }) } return clients.get(username)! } public static setAuthClient(protocol: Protocol, username: string, client: Mastodon) { - let clients = protocol === 'http' ? this.nonAuthorizedHTTP : this.nonAuthorizedWebsocket + let clients = protocol === 'http' ? this.authorizedHTTP : this.authorizedWebSocket clients.set(username, client) } @@ -48,7 +49,7 @@ export default class Clients { } public static getNoAuthClient(domain: string, protocol: Protocol = 'http'): Mastodon { - let clients = protocol === 'http' ? this.nonAuthorizedHTTP : this.nonAuthorizedWebsocket + let clients = protocol === 'http' ? this.nonAuthorizedHTTP : this.nonAuthorizedWebSocket if (!clients.has(domain)) { this.setNoAuthClient(protocol, domain, this.createNoAuthClient(protocol, domain)) @@ -58,7 +59,7 @@ export default class Clients { } public static setNoAuthClient(protocol: Protocol, domain: string, client: Mastodon) { - let clients = protocol === 'http' ? this.nonAuthorizedHTTP : this.nonAuthorizedWebsocket + let clients = protocol === 'http' ? this.nonAuthorizedHTTP : this.nonAuthorizedWebSocket clients.set(domain, client) }