Skip to content

Commit

Permalink
Merge branch 'n-air_unstable' into merge-upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
berlysia committed Sep 10, 2019
2 parents 372c6ad + 28db7c1 commit 4504bae
Show file tree
Hide file tree
Showing 37 changed files with 1,558 additions and 706 deletions.
14 changes: 13 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,24 @@
"arrow-parens": "off",
"comma-dangle": "off",
"prefer-rest-params": "off",
"no-await-in-loop": "off",
"no-restricted-syntax": "off",
"no-continue": "off",
"max-len": ["error", { "code": 120 }],
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true
}
],
"spaced-comment": "off"
}
},
"overrides": [
{
"files": ["bin/**/*.js"],
"rules": {
"global-require": "off"
}
}
]
}
16 changes: 15 additions & 1 deletion app/components/TitleBar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="titlebar">
<div class="titlebar" :class="{isUnstable}">
<div class="titlebar-title">
{{ title }}
</div>
Expand All @@ -25,6 +25,20 @@
vertical-align: top;
z-index: 1;
background-color: @bg-primary;
// 実験版用
&.isUnstable {
background-color: #e2c84d;
.titlebar-title {
color: @black;
font-weight: bold;
}
.link {
color: @black;
}
}
}
.titlebar-icon {
Expand Down
4 changes: 4 additions & 0 deletions app/components/TitleBar.vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export default class TitleBar extends Vue {
return electron.remote.getCurrentWindow().isMinimizable();
}

get isUnstable() {
return Utils.isMainWindow() && Utils.isUnstable();
}

minimize() {
electron.remote.getCurrentWindow().minimize();
}
Expand Down
25 changes: 24 additions & 1 deletion app/components/nicolive-area/ProgramInfo.vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { Inject } from 'util/injector';
import { NicoliveProgramService, NicoliveProgramServiceFailure } from 'services/nicolive-program/nicolive-program';
import { remote } from 'electron';
import { $t } from 'services/i18n';
import { StreamingService } from 'services/streaming';

@Component({})
export default class ProgramInfo extends Vue {
@Inject()
nicoliveProgramService: NicoliveProgramService;
@Inject() streamingService: StreamingService;

// TODO: 後でまとめる
programIsMemberOnlyTooltip = 'コミュニティ限定放送';
Expand Down Expand Up @@ -52,7 +54,28 @@ export default class ProgramInfo extends Vue {
if (this.isStarting) throw new Error('startProgram is running');
try {
this.isStarting = true;
return await this.nicoliveProgramService.startProgram();
await this.nicoliveProgramService.startProgram();

// もし配信開始してなかったら確認する
if (!this.streamingService.isStreaming) {
const startStreaming = await new Promise(resolve => {
// TODO: 翻訳
remote.dialog.showMessageBox(
remote.getCurrentWindow(),
{
type: 'warning',
message: $t('program-info.start-streaming-confirmation'),
buttons: [$t('streaming.goLive'), $t('program-info.later')],
noLink: true,
},
idx => resolve(idx === 0)
);
});
if (startStreaming) {
// 開始
await this.streamingService.toggleStreamingAsync();
}
}
} catch (caught) {
if (caught instanceof NicoliveProgramServiceFailure) {
await NicoliveProgramService.openErrorDialogFromFailure(caught);
Expand Down
12 changes: 8 additions & 4 deletions app/i18n/en-US/nicolive-program.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@
"message": "You could not extend the program time because of a network error.\nCheck the health of your Internet connection."
},
"400": {
"title": "Invalid request",
"message": "You could not extend the program time because the request you sent was invalid.\nTry again later."
"title": "Failed to extend the program",
"message": "You could not extend the program.\n%{additionalMessage}"
},
"401": {
"title": "You do not have the authority to extend the program",
"message": "You can not extend the program because the account you are logged into does not have authority to extend the program. \nMake sure you are logged in with the correct account."
},
"403": {
"title": "The upper limit of extension",
"message": "You can not extend the program time any more because it has reached the extension limit or the program itself has already ended.\nIf the displaced time on N Air has not reached the upper limit, update the program information and get the latest program information."
"title": "Failed to extend the program",
"message": "Failed to extend the program.\n%{additionalMessage}"
},
"404": {
"title": "There is no program",
Expand All @@ -119,6 +119,10 @@
"404": {
"title": "There is no program",
"message": "You can not post a comment because there is no program.\nIf you want to create a new program, update the program information and then press the \"Create A Program\" button."
},
"500": {
"title": "Failed to post a comment",
"message": "Failed to post a comment.\n%{additionalMessage}"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions app/i18n/en-US/program-info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"start-streaming-confirmation": "The program has started. But you do not show the movie and the sound to the viewers because you have not started streaming yet. \nGo live and start streaming?",
"later": "later"
}
14 changes: 9 additions & 5 deletions app/i18n/ja-JP/nicolive-program.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@
"message": "ネットワークエラーが発生したため、番組時間を延長できませんでした。\nネットワーク接続が正常かどうかをご確認ください。"
},
"400": {
"title": "不正なリクエストです",
"message": "不正なリクエストが送られたため、番組時間を延長できませんでした。\n少し時間をおいてから再度お試し下さい。"
"title": "番組を延長できませんでした",
"message": "番組時間を延長できませんでした。\n%{additionalMessage}"
},
"401": {
"title": "番組を延長する権限がありません",
"message": "ログインしているアカウントに番組を延長する権限がないため、番組を延長できませんでした。\n正しいアカウントでログインしているかを確認してください。"
},
"403": {
"title": "延長の上限に達しています",
"message": "番組が延長上限に達している、もしくはすでに終了しているため、番組時間を延長できませんでした。\n番組時間の表記が上限に達していない場合、番組情報を更新して、最新の番組情報を取得してください。"
"title": "番組時間を延長できませんでした",
"message": "番組時間を延長できませんでした。\n%{additionalMessage}"
},
"404": {
"title": "番組が見つかりません",
Expand All @@ -118,7 +118,11 @@
},
"404": {
"title": "番組が見つかりません",
"message": "番組が見つからないため、番組時間を延長できませんでした。\n新規に番組を作成する場合、番組情報を更新した後、[番組作成]を押してください。"
"message": "番組が見つからないため、放送者コメントを投稿できませんでした。\n新規に番組を作成する場合、番組情報を更新した後、[番組作成]を押してください。"
},
"500": {
"title": "放送者コメントを投稿できませんでした",
"message": "放送者コメントを投稿できませんでした。\n%{additionalMessage}"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions app/i18n/ja-JP/program-info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"start-streaming-confirmation": "番組を開始しましたが、配信を開始していないため、視聴者に映像・音声が流れていません。\n配信も開始しますか?",
"later": "後で"
}
13 changes: 11 additions & 2 deletions app/services/nicolive-program/NicoliveClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,20 @@ function setupMock() {
}
}

const openExternal = jest.fn();
let wrapper: {
browserWindow: BrowserWindow;
openExternal: jest.Mock;
} = {
browserWindow: null,
openExternal,
};
jest.doMock('electron', () => ({
remote: {
BrowserWindow,
shell: {
openExternal
}
},
ipcRenderer: {
send() {},
Expand Down Expand Up @@ -260,7 +266,8 @@ describe('webviews', () => {
expect(mock.browserWindow.close).toHaveBeenCalled();
});

test('createProgramでニコ生外に出ると画面を閉じる', async () => {
test('createProgramでニコ生外に出ると既定のブラウザで開いてwebviewは閉じる', async () => {
const openExternal = jest.fn();
const mock = setupMock();

const { NicoliveClient } = require('./NicoliveClient');
Expand All @@ -272,6 +279,7 @@ describe('webviews', () => {

await result;
expect(mock.browserWindow.close).toHaveBeenCalled();
expect(mock.openExternal).toHaveBeenCalledWith('https://example.com');
});

test('createProgramで何もせず画面を閉じても結果が返る', async () => {
Expand Down Expand Up @@ -316,7 +324,7 @@ describe('webviews', () => {
expect(mock.browserWindow.close).toHaveBeenCalled();
});

test('editProgramでニコ生外に出ると画面を閉じる', async () => {
test('editProgramでニコ生外に出ると既定のブラウザで開いてwebviewは閉じる', async () => {
const mock = setupMock();

const { NicoliveClient } = require('./NicoliveClient');
Expand All @@ -328,6 +336,7 @@ describe('webviews', () => {

await result;
expect(mock.browserWindow.close).toHaveBeenCalled();
expect(mock.openExternal).toHaveBeenCalledWith('https://example.com');
});

test('editProgramで何もせず画面を閉じても結果が返る', async () => {
Expand Down
6 changes: 3 additions & 3 deletions app/services/nicolive-program/NicoliveClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@ export class NicoliveClient {
}

static isAllowedURL(url: string): boolean {
// メンテ中は作成画面に http://blog.nicovideo.jp/niconews/category/nicolivemainte/ へのリンクが表示されるので表示を許す
return (
/^https?:\/\/live2?.nicovideo.jp\//.test(url) ||
/^https?:\/\/blog\.nicovideo\.jp\/niconews\//.test(url)
/^https?:\/\/live2?.nicovideo.jp\//.test(url)
);
}

Expand Down Expand Up @@ -342,6 +340,7 @@ export class NicoliveClient {
win.close();
} else if (!NicoliveClient.isAllowedURL(url)) {
resolve(CreateResult.OTHER);
remote.shell.openExternal(url);
win.close();
}
});
Expand Down Expand Up @@ -370,6 +369,7 @@ export class NicoliveClient {
win.close();
} else if (!NicoliveClient.isAllowedURL(url)) {
resolve(EditResult.OTHER);
remote.shell.openExternal(url);
win.close();
}
});
Expand Down
10 changes: 4 additions & 6 deletions app/services/patch-notes/notes.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { IPatchNotes } from '.';

export const notes: IPatchNotes = {
version: '1.0.20190627-1',
title: '1.0.20190627-1',
version: '1.0.20190905-1',
title: '1.0.20190905-1',
notes: [
'追加: 最適化ダイアログにハードウェアエンコーダーを使うかどうかのオプションを追加 (#315)',
'追加: 番組URLをクリップボードへコピーする機能を番組情報パネルに追加 (#301)',
'変更: アップデーターのボタン文言を簡潔にする (#312)',
'修正: ニコ生などの操作パネルを開閉するボタンが目立つように修正 (#318)'
'修正: エラーメッセージが想定通りに親切になっていなかった (#337)',
'改善: 番組開始時に配信ボタンを押していないときに確認を出す(真っ黒配信抑止) (#339)'
]
};
4 changes: 4 additions & 0 deletions app/services/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export default class Utils {
return process.env.NODE_ENV !== 'production';
}

static isUnstable(): boolean {
return !!electron.remote.process.env.NAIR_UNSTABLE;
}

static isPreview(): boolean {
return electron.remote.process.env.NAIR_PREVIEW;
}
Expand Down
4 changes: 4 additions & 0 deletions app/util/autoLink.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ test('myvideo/1', () => {
expect(apply('myvideo/1')).toMatchInlineSnapshot(`"<a href=\\"https://www.nicovideo.jp/myvideo/1\\">myvideo/1</a>"`);
});

test('series/1', () => {
expect(apply('series/1')).toMatchInlineSnapshot(`"<a href=\\"https://www.nicovideo.jp/series/1\\">series/1</a>"`);
});

test('lv1', () => {
expect(apply('lv1')).toMatchInlineSnapshot(`"<a href=\\"https://live2.nicovideo.jp/watch/lv1\\">lv1</a>"`);
});
Expand Down
1 change: 1 addition & 0 deletions app/util/autoLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const autoLinkPatterns = [
},
{ matcher: /\bwatch\/\d+\b/, replace: '<a href="https://www.nicovideo.jp/$&">$&</a>' },
{ matcher: /\bmyvideo\/\d+\b/, replace: '<a href="https://www.nicovideo.jp/$&">$&</a>' },
{ matcher: /\bseries\/\d+\b/, replace: '<a href="https://www.nicovideo.jp/$&">$&</a>' },
// negative lookbehindが使えないので user/\d+ より先にニコニコモンズユーザーページを判定させる
{ matcher: /\bniconicommons\.jp\/user\/\d+\b/, replace: '<a href="https://www.$&">$&</a>' },
{ matcher: /\buser\/\d+\b/, replace: '<a href="https://www.nicovideo.jp/$&">$&</a>' },
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
build: off

install:
- ps: Install-Product node 8
- ps: Install-Product node 10
- yarn install --frozen-lockfile --check-files
- yarn compile:ci

Expand Down
Loading

0 comments on commit 4504bae

Please sign in to comment.