Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: presets styling for web #3585

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/js/browserMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ import "../css/tabs/led_strip.less";
import "../css/tabs/sensors.less";
import "../css/tabs/cli.less";
import "../tabs/presets/presets.less";
// TODO: for some reason can't resolve these less files
// import "../tabs/presets/TitlePanel/PresetTitlePanel.less";
import "../tabs/presets/TitlePanel/PresetTitlePanel.css";
import "../tabs/presets/DetailedDialog/PresetsDetailedDialog.less";
// TODO: for some reason can't resolve these less files
// import "../tabs/presets/SourcesDialog/SourcesDialog.less";
// import "../tabs/presets/SourcesDialog/SourcePanel.less";
import "../tabs/presets/SourcesDialog/SourcesDialog.css";
import "../tabs/presets/SourcesDialog/SourcePanel.css";
import "../css/tabs/logging.less";
import "../css/tabs/onboard_logging.less";
import "../css/tabs/firmware_flasher.less";
Expand Down
7 changes: 4 additions & 3 deletions src/js/msp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import GUI from "./gui.js";
import CONFIGURATOR from "./data_storage.js";
import serialNWJS from "./serial.js";
import serialWeb from "./webSerial.js";
import { isWeb } from "./utils/isWeb.js";

const serial = import.meta.env ? serialWeb : serialNWJS;
const serial = isWeb() ? serialWeb : serialNWJS;

const MSP = {
symbols: {
Expand Down Expand Up @@ -307,7 +308,7 @@ const MSP = {
return bufferOut;
},
send_message(code, data, callback_sent, callback_msp, doCallbackOnError) {
const connected = import.meta.env ? serial.connected : serial.connectionId;
const connected = isWeb ? serial.connected : serial.connectionId;
if (code === undefined || !connected || CONFIGURATOR.virtualMode) {
if (callback_msp) {
callback_msp();
Expand All @@ -324,7 +325,7 @@ const MSP = {
}
}

if (import.meta.env && (code === undefined || !serial.connectionInfo)) {
if (isWeb() && (code === undefined || !serial.connectionInfo)) {
console.log('ERROR: code undefined or no connectionId');
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion src/js/port_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { get as getConfig } from "./ConfigStorage";
import serial from "./serial";
import MdnsDiscovery from "./mdns_discovery";
import $ from 'jquery';
import { isWeb } from "./utils/isWeb";

const TIMEOUT_CHECK = 500 ; // With 250 it seems that it produces a memory leak and slowdown in some versions, reason unknown

Expand All @@ -32,7 +33,7 @@ PortHandler.initialize = function () {

// currently web build doesn't need port handler,
// so just bail out.
if (import.meta.env) {
if (isWeb()) {
return 'not implemented';
}

Expand Down
7 changes: 4 additions & 3 deletions src/js/serial_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ import BuildApi from "./BuildApi";

import serialNWJS from "./serial.js";
import serialWeb from "./webSerial.js";
import { isWeb } from "./utils/isWeb";

const serial = import.meta.env ? serialWeb : serialNWJS;
const serial = isWeb() ? serialWeb : serialNWJS;

let mspHelper;
let connectionTimestamp;
Expand Down Expand Up @@ -118,7 +119,7 @@ export function initializeSerialBackend() {
CONFIGURATOR.virtualApiVersion = $('#firmware-version-dropdown :selected').val();

serial.connect('virtual', {}, onOpenVirtual);
} else if (import.meta.env) {
} else if (isWeb()) {
// Explicitly disconnect the event listeners before attaching the new ones.
serial.removeEventListener('connect', connectHandler);
serial.addEventListener('connect', connectHandler);
Expand Down Expand Up @@ -327,7 +328,7 @@ function onOpen(openInfo) {
result = getConfig('expertMode')?.expertMode ?? false;
$('input[name="expertModeCheckbox"]').prop('checked', result).trigger('change');

if(import.meta.env) {
if(isWeb()) {
serial.removeEventListener('receive', read_serial_adapter);
serial.addEventListener('receive', read_serial_adapter);
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/js/utils/isWeb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function isWeb() {
return !!import.meta.env;
}