Skip to content

Commit

Permalink
Bugfix/correct websocket origin (#18)
Browse files Browse the repository at this point in the history
Bugfix/correct websocket origin
  • Loading branch information
Yukaii authored Oct 31, 2019
2 parents be1939e + 5165baf commit a70986f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 160 deletions.
90 changes: 19 additions & 71 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@
"vscode": "^1.1.33"
},
"dependencies": {
"find-free-port": "^2.0.0",
"http-proxy": "^1.17.0",
"ptt-client": "^0.8.0",
"ws": "^6.2.1"
"ptt-client": "^0.8.1"
}
}
19 changes: 3 additions & 16 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ import key from 'ptt-client/dist/utils/keymap';

(global as any).WebSocket = require('ws');

import initProxy from './proxy';
import { PttTreeDataProvider, Board } from './pttDataProvider';
import ContentProvider from './provider';
import store, { ArticleListItem } from './store';

let proxyServer;
let proxyAddress;
let ptt;
let ctx: vscode.ExtensionContext;
let pttProvider: PttTreeDataProvider;
Expand All @@ -27,15 +24,9 @@ export interface FavoriteBoardItem{
divider: boolean;
}

async function intializeProxy () {
const { server, address } = await initProxy();
proxyServer = server;
proxyAddress = address;
}

function intializePttClient (url: string) {
function intializePttClient () {
return new Promise(resolve => {
const ptt = new PTT({ url });
const ptt = new PTT({ origin: 'app://vscode-ptt' });
ptt.once('connect', () => resolve(ptt));
});
}
Expand Down Expand Up @@ -130,12 +121,8 @@ function setSearchCondition(type: string, criteria: string): void
export async function activate(context: vscode.ExtensionContext) {
ctx = context;

if (!proxyServer) {
await intializeProxy();
}

if (!ptt) {
ptt = await intializePttClient(proxyAddress);
ptt = await intializePttClient();
}

pttProvider = new PttTreeDataProvider(ptt, ctx);
Expand Down
69 changes: 0 additions & 69 deletions src/proxy.ts

This file was deleted.

0 comments on commit a70986f

Please sign in to comment.