mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-10 09:39:58 +00:00
Switch to eslint and fix issues
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* tslint:disable:max-line-length */
|
||||
/* eslint-disable max-len */
|
||||
"use strict";
|
||||
|
||||
import React, { Component } from "react";
|
||||
@@ -79,7 +79,7 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
||||
private updateData: any;
|
||||
private updateStatusTimeout?: number;
|
||||
|
||||
constructor (props: BridgeProps) {
|
||||
constructor(props: BridgeProps) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
@@ -95,7 +95,7 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
||||
this.onUpdate = this.onUpdate.bind(this);
|
||||
}
|
||||
|
||||
public render () {
|
||||
public render() {
|
||||
const [ backupMessageStart, backupMessageEnd ]
|
||||
= _("optionsBridgeBackupEnabled", "\0").split("\0");
|
||||
|
||||
@@ -177,7 +177,7 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
||||
);
|
||||
}
|
||||
|
||||
private renderStatus () {
|
||||
private renderStatus() {
|
||||
const infoClasses = `bridge__info ${!this.props.info
|
||||
? this.props.loadingTimedOut
|
||||
? "bridge__info--timed-out"
|
||||
@@ -228,7 +228,7 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
||||
);
|
||||
}
|
||||
|
||||
private onCheckUpdates () {
|
||||
private onCheckUpdates() {
|
||||
this.setState({
|
||||
isCheckingUpdates: true
|
||||
});
|
||||
@@ -249,7 +249,7 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
||||
.catch(this.onCheckUpdatesError);
|
||||
}
|
||||
|
||||
private async onCheckUpdatesResponse (res: any) {
|
||||
private async onCheckUpdatesResponse(res: any) {
|
||||
let latestBridgeRelease;
|
||||
for (const release of res) {
|
||||
if (release.assets.find((asset: any) =>
|
||||
@@ -290,7 +290,7 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
||||
this.showUpdateStatus();
|
||||
}
|
||||
|
||||
private onCheckUpdatesError () {
|
||||
private onCheckUpdatesError() {
|
||||
this.setState({
|
||||
isCheckingUpdates: false
|
||||
, wasErrorCheckingUpdates: true
|
||||
@@ -300,7 +300,7 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
||||
this.showUpdateStatus();
|
||||
}
|
||||
|
||||
private showUpdateStatus () {
|
||||
private showUpdateStatus() {
|
||||
if (this.updateStatusTimeout) {
|
||||
window.clearTimeout(this.updateStatusTimeout);
|
||||
}
|
||||
@@ -311,7 +311,7 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
private async onUpdate () {
|
||||
private async onUpdate() {
|
||||
// Open downloads page
|
||||
if (this.updateData.html_url) {
|
||||
browser.tabs.create({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* tslint:disable:max-line-length */
|
||||
/* eslint-disable max-len */
|
||||
"use strict";
|
||||
|
||||
import React, { Component } from "react";
|
||||
@@ -24,7 +24,7 @@ export default class EditableList extends Component<
|
||||
|
||||
private rawViewTextArea: (HTMLTextAreaElement | null) = null;
|
||||
|
||||
constructor (props: EditableListProps) {
|
||||
constructor(props: EditableListProps) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
@@ -43,7 +43,7 @@ export default class EditableList extends Component<
|
||||
this.handleNewItemEdit = this.handleNewItemEdit.bind(this);
|
||||
}
|
||||
|
||||
public render () {
|
||||
public render() {
|
||||
return (
|
||||
<div className="editable-list">
|
||||
{ this.state.rawView
|
||||
@@ -102,21 +102,21 @@ export default class EditableList extends Component<
|
||||
);
|
||||
}
|
||||
|
||||
private handleItemRemove (item: string) {
|
||||
private handleItemRemove(item: string) {
|
||||
const newItems = new Set(this.props.data);
|
||||
newItems.delete(item);
|
||||
|
||||
this.props.onChange([...newItems]);
|
||||
}
|
||||
|
||||
private handleItemEdit (item: string, newValue: string) {
|
||||
private handleItemEdit(item: string, newValue: string) {
|
||||
this.props.onChange(this.props.data.map(
|
||||
currentItem => currentItem === item
|
||||
? newValue
|
||||
: currentItem));
|
||||
}
|
||||
|
||||
private handleSwitchView () {
|
||||
private handleSwitchView() {
|
||||
this.setState(currentState => {
|
||||
if (currentState.rawView) {
|
||||
return {
|
||||
@@ -132,7 +132,7 @@ export default class EditableList extends Component<
|
||||
});
|
||||
}
|
||||
|
||||
private handleSaveRaw () {
|
||||
private handleSaveRaw() {
|
||||
this.setState(currentState => {
|
||||
const newItems = currentState.rawViewValue.split("\n")
|
||||
.filter(item => item !== "");
|
||||
@@ -153,7 +153,7 @@ export default class EditableList extends Component<
|
||||
});
|
||||
}
|
||||
|
||||
private handleRawViewTextAreaChange (ev: React.ChangeEvent<HTMLTextAreaElement>) {
|
||||
private handleRawViewTextAreaChange(ev: React.ChangeEvent<HTMLTextAreaElement>) {
|
||||
if (!this.rawViewTextArea) {
|
||||
return;
|
||||
}
|
||||
@@ -167,19 +167,19 @@ export default class EditableList extends Component<
|
||||
});
|
||||
}
|
||||
|
||||
private handleAddItem () {
|
||||
private handleAddItem() {
|
||||
this.setState({
|
||||
addingNewItem: true
|
||||
});
|
||||
}
|
||||
|
||||
private handleNewItemRemove () {
|
||||
private handleNewItemRemove() {
|
||||
this.setState({
|
||||
addingNewItem: false
|
||||
});
|
||||
}
|
||||
|
||||
private handleNewItemEdit (_item: string, newItem: string) {
|
||||
private handleNewItemEdit(_item: string, newItem: string) {
|
||||
this.setState({
|
||||
addingNewItem: false
|
||||
}, () => {
|
||||
@@ -208,7 +208,7 @@ class EditableListItem extends Component<
|
||||
|
||||
private input: (HTMLInputElement | null) = null;
|
||||
|
||||
constructor (props: EditableListItemProps) {
|
||||
constructor(props: EditableListItemProps) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
@@ -223,7 +223,7 @@ class EditableListItem extends Component<
|
||||
this.handleInputKeyPress = this.handleInputKeyPress.bind(this);
|
||||
}
|
||||
|
||||
public render () {
|
||||
public render() {
|
||||
const selected = this.state.editing
|
||||
? "editable-list__item--selected" : "";
|
||||
|
||||
@@ -260,7 +260,7 @@ class EditableListItem extends Component<
|
||||
);
|
||||
}
|
||||
|
||||
private stopEditing (input: HTMLInputElement) {
|
||||
private stopEditing(input: HTMLInputElement) {
|
||||
if (this.props.editing
|
||||
&& !this.props.itemPattern.test(this.state.editValue)) {
|
||||
input.setCustomValidity(this.props.itemPatternError());
|
||||
@@ -277,11 +277,11 @@ class EditableListItem extends Component<
|
||||
});
|
||||
}
|
||||
|
||||
private handleRemove () {
|
||||
private handleRemove() {
|
||||
this.props.onRemove(this.props.text);
|
||||
}
|
||||
|
||||
private handleEditBegin () {
|
||||
private handleEditBegin() {
|
||||
if (!this.state.editing) {
|
||||
this.setState({
|
||||
editing: true
|
||||
@@ -293,11 +293,11 @@ class EditableListItem extends Component<
|
||||
}
|
||||
}
|
||||
|
||||
private handleEditEnd (ev: React.FocusEvent<HTMLInputElement>) {
|
||||
private handleEditEnd(ev: React.FocusEvent<HTMLInputElement>) {
|
||||
this.stopEditing(ev.target);
|
||||
}
|
||||
|
||||
private handleInputChange (ev: React.ChangeEvent<HTMLInputElement>) {
|
||||
private handleInputChange(ev: React.ChangeEvent<HTMLInputElement>) {
|
||||
this.setState({
|
||||
editValue: ev.target.value
|
||||
});
|
||||
@@ -308,7 +308,7 @@ class EditableListItem extends Component<
|
||||
: "");
|
||||
}
|
||||
|
||||
private handleInputKeyPress (ev: React.KeyboardEvent<HTMLInputElement>) {
|
||||
private handleInputKeyPress(ev: React.KeyboardEvent<HTMLInputElement>) {
|
||||
if (ev.key === "Enter") {
|
||||
this.stopEditing(ev.target as HTMLInputElement);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* tslint:disable:max-line-length */
|
||||
/* eslint-disable max-len */
|
||||
"use strict";
|
||||
|
||||
import React, { Component } from "react";
|
||||
@@ -40,7 +40,7 @@ browser.runtime.getPlatformInfo()
|
||||
});
|
||||
|
||||
|
||||
function getInputValue (input: HTMLInputElement) {
|
||||
function getInputValue(input: HTMLInputElement) {
|
||||
switch (input.type) {
|
||||
case "checkbox":
|
||||
return input.checked;
|
||||
@@ -78,7 +78,7 @@ class OptionsApp extends Component<
|
||||
, hasSaved: false
|
||||
};
|
||||
|
||||
constructor (props: OptionsAppProps) {
|
||||
constructor(props: OptionsAppProps) {
|
||||
super(props);
|
||||
|
||||
this.handleReset = this.handleReset.bind(this);
|
||||
@@ -94,7 +94,7 @@ class OptionsApp extends Component<
|
||||
this.getWhitelistItemPatternError.bind(this);
|
||||
}
|
||||
|
||||
public async componentDidMount () {
|
||||
public async componentDidMount() {
|
||||
this.setState({
|
||||
hasLoaded: true
|
||||
, options: await options.getAll()
|
||||
@@ -131,7 +131,7 @@ class OptionsApp extends Component<
|
||||
}
|
||||
}
|
||||
|
||||
public render () {
|
||||
public render() {
|
||||
if (!this.state.hasLoaded) {
|
||||
return;
|
||||
}
|
||||
@@ -402,6 +402,7 @@ class OptionsApp extends Component<
|
||||
{ _("optionsReset") }
|
||||
</button>
|
||||
<button type="submit"
|
||||
// @ts-ignore
|
||||
default
|
||||
disabled={ !this.state.isFormValid }>
|
||||
{ _("optionsSave") }
|
||||
@@ -413,13 +414,13 @@ class OptionsApp extends Component<
|
||||
}
|
||||
|
||||
|
||||
private handleReset () {
|
||||
private handleReset() {
|
||||
this.setState({
|
||||
options: { ...defaultOptions }
|
||||
});
|
||||
}
|
||||
|
||||
private async handleFormSubmit (ev: React.FormEvent<HTMLFormElement>) {
|
||||
private async handleFormSubmit(ev: React.FormEvent<HTMLFormElement>) {
|
||||
ev.preventDefault();
|
||||
|
||||
this.form?.reportValidity();
|
||||
@@ -443,7 +444,7 @@ class OptionsApp extends Component<
|
||||
}
|
||||
}
|
||||
|
||||
private handleFormChange (ev: React.FormEvent<HTMLFormElement>) {
|
||||
private handleFormChange(ev: React.FormEvent<HTMLFormElement>) {
|
||||
ev.preventDefault();
|
||||
|
||||
const isFormValid = this.form?.checkValidity();
|
||||
@@ -454,7 +455,7 @@ class OptionsApp extends Component<
|
||||
}
|
||||
}
|
||||
|
||||
private handleInputChange (ev: React.ChangeEvent<HTMLInputElement>) {
|
||||
private handleInputChange(ev: React.ChangeEvent<HTMLInputElement>) {
|
||||
this.setState(currentState => {
|
||||
if (currentState.options) {
|
||||
currentState.options[ev.target.name] = getInputValue(ev.target);
|
||||
@@ -464,19 +465,20 @@ class OptionsApp extends Component<
|
||||
});
|
||||
}
|
||||
|
||||
private handleReceiverSelectorTypeChange (
|
||||
private handleReceiverSelectorTypeChange(
|
||||
ev: React.ChangeEvent<HTMLSelectElement>) {
|
||||
|
||||
this.setState(currentState => {
|
||||
if (currentState.options) {
|
||||
currentState.options[ev.target.name] = parseInt(ev.target.value);
|
||||
currentState.options[ev.target.name] =
|
||||
parseInt(ev.target.value);
|
||||
}
|
||||
|
||||
return currentState;
|
||||
});
|
||||
}
|
||||
|
||||
private handleWhitelistChange (whitelist: string[]) {
|
||||
private handleWhitelistChange(whitelist: string[]) {
|
||||
this.setState(currentState => {
|
||||
if (currentState.options) {
|
||||
currentState.options.userAgentWhitelist = whitelist;
|
||||
@@ -486,7 +488,7 @@ class OptionsApp extends Component<
|
||||
});
|
||||
}
|
||||
|
||||
private getWhitelistItemPatternError (info: string): string {
|
||||
private getWhitelistItemPatternError(info: string): string {
|
||||
return _("optionsUserAgentWhitelistInvalidMatchPattern", info);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* tslint:disable:max-line-length */
|
||||
/* eslint-disable max-len */
|
||||
"use strict";
|
||||
|
||||
import React, { Component } from "react";
|
||||
@@ -29,6 +29,7 @@ browser.runtime.getPlatformInfo()
|
||||
});
|
||||
|
||||
|
||||
interface PopupAppProps {}
|
||||
interface PopupAppState {
|
||||
receivers: Receiver[];
|
||||
mediaType: ReceiverSelectorMediaType;
|
||||
@@ -41,12 +42,12 @@ interface PopupAppState {
|
||||
mirroringEnabled: boolean;
|
||||
}
|
||||
|
||||
class PopupApp extends Component<{}, PopupAppState> {
|
||||
class PopupApp extends Component<PopupAppProps, PopupAppState> {
|
||||
private port?: Port;
|
||||
private win?: browser.windows.Window;
|
||||
private defaultMediaType?: ReceiverSelectorMediaType;
|
||||
|
||||
constructor (props: {}) {
|
||||
constructor(props: PopupAppProps) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
@@ -67,7 +68,7 @@ class PopupApp extends Component<{}, PopupAppState> {
|
||||
this.onStop = this.onStop.bind(this);
|
||||
}
|
||||
|
||||
public async componentDidMount () {
|
||||
public async componentDidMount() {
|
||||
this.port = messaging.connect({ name: "popup" });
|
||||
|
||||
this.port.onMessage.addListener((message: Message) => {
|
||||
@@ -111,7 +112,7 @@ class PopupApp extends Component<{}, PopupAppState> {
|
||||
});
|
||||
}
|
||||
|
||||
public componentDidUpdate () {
|
||||
public componentDidUpdate() {
|
||||
setTimeout(() => {
|
||||
if (this.win?.id === undefined) {
|
||||
return;
|
||||
@@ -127,7 +128,11 @@ class PopupApp extends Component<{}, PopupAppState> {
|
||||
}, 1);
|
||||
}
|
||||
|
||||
public render () {
|
||||
public render() {
|
||||
/*
|
||||
|
||||
// TODO: Add file support back to popup
|
||||
|
||||
let truncatedFileName: string;
|
||||
|
||||
if (this.state.filePath) {
|
||||
@@ -138,6 +143,7 @@ class PopupApp extends Component<{}, PopupAppState> {
|
||||
? `${fileName.substring(0, 12)}...`
|
||||
: fileName;
|
||||
}
|
||||
*/
|
||||
|
||||
const isAppMediaTypeSelected =
|
||||
this.state.mediaType === ReceiverSelectorMediaType.App;
|
||||
@@ -147,7 +153,7 @@ class PopupApp extends Component<{}, PopupAppState> {
|
||||
this.state.mediaType === ReceiverSelectorMediaType.Screen;
|
||||
|
||||
const isSelectedMediaTypeAvailable =
|
||||
!!(this.state.availableMediaTypes & this.state.mediaType)
|
||||
!!(this.state.availableMediaTypes & this.state.mediaType);
|
||||
const isAppMediaTypeAvailable = !!(this.state.availableMediaTypes
|
||||
& ReceiverSelectorMediaType.App);
|
||||
|
||||
@@ -208,7 +214,7 @@ class PopupApp extends Component<{}, PopupAppState> {
|
||||
</>;
|
||||
}
|
||||
|
||||
private onCast (receiver: Receiver) {
|
||||
private onCast(receiver: Receiver) {
|
||||
this.setState({
|
||||
isLoading: true
|
||||
});
|
||||
@@ -224,7 +230,7 @@ class PopupApp extends Component<{}, PopupAppState> {
|
||||
});
|
||||
}
|
||||
|
||||
private onStop (receiver: Receiver) {
|
||||
private onStop(receiver: Receiver) {
|
||||
this.port?.postMessage({
|
||||
subject: "receiverSelector:stop"
|
||||
, data: {
|
||||
@@ -234,7 +240,7 @@ class PopupApp extends Component<{}, PopupAppState> {
|
||||
});
|
||||
}
|
||||
|
||||
private onSelectChange (ev: React.ChangeEvent<HTMLSelectElement>) {
|
||||
private onSelectChange(ev: React.ChangeEvent<HTMLSelectElement>) {
|
||||
const mediaType = parseInt(ev.target.value);
|
||||
|
||||
if (mediaType === ReceiverSelectorMediaType.File) {
|
||||
@@ -282,7 +288,7 @@ interface ReceiverEntryState {
|
||||
}
|
||||
|
||||
class ReceiverEntry extends Component<ReceiverEntryProps, ReceiverEntryState> {
|
||||
constructor (props: ReceiverEntryProps) {
|
||||
constructor(props: ReceiverEntryProps) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
@@ -313,7 +319,7 @@ class ReceiverEntry extends Component<ReceiverEntryProps, ReceiverEntryState> {
|
||||
this.handleCast = this.handleCast.bind(this);
|
||||
}
|
||||
|
||||
public render () {
|
||||
public render() {
|
||||
if (!this.props.receiver.status) {
|
||||
return;
|
||||
}
|
||||
@@ -349,7 +355,7 @@ class ReceiverEntry extends Component<ReceiverEntryProps, ReceiverEntryState> {
|
||||
);
|
||||
}
|
||||
|
||||
private handleCast () {
|
||||
private handleCast() {
|
||||
if (!this.props.receiver.status) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user