mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-07 16:22:18 +02:00
[ts-migrate][client] Init tsconfig.json file
Co-authored-by: ts-migrate <>
This commit is contained in:
parent
a799677c2a
commit
a0c05b93d6
|
@ -3,6 +3,23 @@
|
|||
import socket from "../socket";
|
||||
import eventbus from "../eventbus";
|
||||
|
||||
type ContextMenuItem =
|
||||
| ({
|
||||
label: string;
|
||||
type: string;
|
||||
class: string;
|
||||
} & (
|
||||
| {
|
||||
link?: string;
|
||||
}
|
||||
| {
|
||||
action?: () => void;
|
||||
}
|
||||
))
|
||||
| {
|
||||
type: "divider";
|
||||
};
|
||||
|
||||
export function generateChannelContextMenu($root, channel, network) {
|
||||
const typeMap = {
|
||||
lobby: "network",
|
||||
|
@ -18,7 +35,7 @@ export function generateChannelContextMenu($root, channel, network) {
|
|||
special: "Close",
|
||||
};
|
||||
|
||||
let items = [
|
||||
let items: ContextMenuItem[] = [
|
||||
{
|
||||
label: channel.name,
|
||||
type: "item",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const sizes = ["Bytes", "KiB", "MiB", "GiB", "TiB", "PiB"];
|
||||
|
||||
export default (size) => {
|
||||
export default (size: number) => {
|
||||
// Loosely inspired from https://stackoverflow.com/a/18650828/1935861
|
||||
const i = size > 0 ? Math.floor(Math.log(size) / Math.log(1024)) : 0;
|
||||
const fixedSize = parseFloat((size / Math.pow(1024, i)).toFixed(1));
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
"use strict";
|
||||
|
||||
export default (event) => {
|
||||
if (event.target.tagName !== "TEXTAREA" && event.target.tagName !== "INPUT") {
|
||||
export default (event: MouseEvent) => {
|
||||
if (
|
||||
(event.target as HTMLElement).tagName !== "TEXTAREA" &&
|
||||
(event.target as HTMLElement).tagName !== "INPUT"
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If focus is in a textarea, do not handle keybinds if user has typed anything
|
||||
// This is done to prevent keyboard layout binds conflicting with ours
|
||||
// For example alt+shift+left on macos selects a word
|
||||
return !!event.target.value;
|
||||
return !!(event.target as any).value;
|
||||
};
|
||||
|
|
|
@ -5,7 +5,10 @@ import distance from "./distance";
|
|||
// onTwoFingerSwipe will be called with a cardinal direction ("n", "e", "s" or
|
||||
// "w") as its only argument.
|
||||
function listenForTwoFingerSwipes(onTwoFingerSwipe) {
|
||||
let history = [];
|
||||
let history: {
|
||||
center: number[];
|
||||
timestamp: number;
|
||||
}[] = [];
|
||||
|
||||
document.body.addEventListener(
|
||||
"touchmove",
|
||||
|
@ -17,6 +20,10 @@ function listenForTwoFingerSwipes(onTwoFingerSwipe) {
|
|||
const a = event.touches.item(0);
|
||||
const b = event.touches.item(1);
|
||||
|
||||
if (!a || !b) {
|
||||
return;
|
||||
}
|
||||
|
||||
const timestamp = window.performance.now();
|
||||
const center = [(a.screenX + b.screenX) / 2, (a.screenY + b.screenY) / 2];
|
||||
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export default (time) => dayjs(time).format("D MMMM YYYY, HH:mm:ss");
|
||||
export default (time: Date | number) => dayjs(time).format("D MMMM YYYY, HH:mm:ss");
|
||||
|
|
Loading…
Reference in a new issue