Compare commits

...

3 Commits

Author SHA1 Message Date
Evan Simkowitz 35cf4b6a3b Merge branch 'main' into evan/inshellisense 2024-04-22 13:54:42 -07:00
Sylvie Crowe 8fdcf10cae fix: ignore computer sleep for telemetry clock (#577)
* fix: ignore computer sleep for telemetry clock

This uses unix time with regular integer comparisons to prevent the
telemetry clock from needing to wait for 8 hours of the program running.
Now, it only needs to wait 8 real-time hours instead.

* drop telemetry time to 4 hours, tick every 10 minutes
2024-04-19 18:26:31 -07:00
Mike Sawka 6336f87cf2 tab context menu (w/ close tab option) (#583)
* create tab context menu (for close tab)

* small update to ctx menu, also make all tab deletes (including keybinding) not popup confirm modal if less than 10 blocks
2024-04-19 18:25:26 -07:00
4 changed files with 68 additions and 9 deletions
+55 -1
View File
@@ -12,6 +12,7 @@ import * as constants from "@/app/appconst";
import { Reorder } from "framer-motion";
import { MagicLayout } from "@/app/magiclayout";
import { TabIcon } from "@/elements/tabicon";
import * as appconst from "@/app/appconst";
@mobxReact.observer
class ScreenTab extends React.Component<
@@ -62,6 +63,59 @@ class ScreenTab extends React.Component<
})();
}
@boundMethod
onContextMenu(e: React.MouseEvent) {
e.preventDefault();
e.stopPropagation();
let { screen, activeScreenId } = this.props;
if (activeScreenId != screen.screenId) {
// only show context menu for active tab
GlobalCommandRunner.switchScreen(screen.screenId);
return;
}
let colorSubMenu: ContextMenuItem[] = [];
for (let color of appconst.TabColors) {
colorSubMenu.push({
label: color,
click: () => {
GlobalCommandRunner.screenSetSettings(screen.screenId, { tabcolor: color }, false);
},
});
}
let menu: ContextMenuItem[] = [
{
label: "New Tab",
click: () => {
GlobalCommandRunner.createNewScreen();
},
},
{
type: "separator",
},
{
label: "Set Tab Color",
submenu: colorSubMenu,
},
{
label: "All Tab Settings",
click: () => {
GlobalModel.tabSettingsOpen.set(true);
},
},
{
type: "separator",
},
{
label: "Close Tab",
click: () => {
GlobalModel.onCloseCurrentTab();
},
},
];
GlobalModel.contextMenuModel.showContextMenu(menu, { x: e.clientX, y: e.clientY });
return;
}
render() {
let { screen, activeScreenId, index, onSwitchScreen } = this.props;
let archived = screen.archived.get() ? (
@@ -83,7 +137,7 @@ class ScreenTab extends React.Component<
"color-" + screen.getTabColor()
)}
onPointerDown={() => onSwitchScreen(screen.screenId)}
onContextMenu={(event) => this.openScreenSettings(event, screen)}
onContextMenu={this.onContextMenu}
onDragEnd={this.handleDragEnd}
>
<div className="background"></div>
+2 -1
View File
@@ -121,7 +121,8 @@ class TabSettings extends React.Component<{ screen: Screen }, {}> {
if (screen == null) {
return;
}
if (screen.getScreenLines().lines.length == 0) {
let numLines = screen.getScreenLines().lines.length;
if (numLines < 10) {
GlobalCommandRunner.screenDelete(screen.screenId, false);
GlobalModel.modalsModel.popModal();
return;
+6 -1
View File
@@ -609,6 +609,11 @@ class Model {
if (activeScreen == null) {
return;
}
let numLines = activeScreen.getScreenLines().lines.length;
if (numLines < 10) {
GlobalCommandRunner.screenDelete(activeScreen.screenId, false);
return;
}
const rtnp = this.showAlert({
message: "Are you sure you want to delete this tab?",
confirm: true,
@@ -617,7 +622,7 @@ class Model {
if (!result) {
return;
}
GlobalCommandRunner.screenDelete(activeScreen.screenId, true);
GlobalCommandRunner.screenDelete(activeScreen.screenId, false);
});
}
+5 -6
View File
@@ -67,8 +67,8 @@ const WSStateReconnectTime = 30 * time.Second
const WSStatePacketChSize = 20
const InitialTelemetryWait = 30 * time.Second
const TelemetryTick = 30 * time.Minute
const TelemetryInterval = 8 * time.Hour
const TelemetryTick = 10 * time.Minute
const TelemetryInterval = 4 * time.Hour
const MaxWriteFileMemSize = 20 * (1024 * 1024) // 20M
@@ -930,12 +930,11 @@ func checkNewReleaseWrapper() {
}
func telemetryLoop() {
var lastSent time.Time
var nextSend int64
time.Sleep(InitialTelemetryWait)
for {
dur := time.Since(lastSent)
if lastSent.IsZero() || dur >= TelemetryInterval {
lastSent = time.Now()
if time.Now().Unix() > nextSend {
nextSend = time.Now().Add(TelemetryInterval).Unix()
sendTelemetryWrapper()
checkNewReleaseWrapper()
}