Implemented strict linting standards and prettier formatting config. (#248)

* Implemented strict linting standards and prettier formatting config.

* More linter fixes and type updates.

* More linter updates and type fixes

* Remove noisy comments

* Linter and type updates

* Linter, formatting and type updates.

* Linter updates

* Type updates

* Type updates

* fixed all linter errors

* Fixed all linting, formatting and type issues.

* Resolve merge conflicts.
This commit is contained in:
Jas Singh
2024-09-14 16:20:05 -07:00
committed by GitHub
parent ff13e3dd3c
commit 2c72cc66d8
222 changed files with 13141 additions and 8433 deletions

View File

@@ -1,35 +1,36 @@
import { Notification, Notifications } from "types/service/notifications";
const Actions = (notif: Notification, notifs: Notifications) => {
import { BoxWidget } from 'lib/types/widget';
import { Notification, Notifications } from 'types/service/notifications';
const Actions = (notif: Notification, notifs: Notifications): BoxWidget => {
if (notif.actions !== undefined && notif.actions.length > 0) {
return Widget.Box({
class_name: "notification-card-actions menu",
class_name: 'notification-card-actions menu',
hexpand: true,
vpack: "end",
vpack: 'end',
children: notif.actions.map((action) => {
return Widget.Button({
hexpand: true,
class_name: "notification-action-buttons menu",
class_name: 'notification-action-buttons menu',
on_primary_click: () => {
if (action.id.includes("scriptAction:-")) {
App.closeWindow("notificationsmenu");
Utils.execAsync(
`${action.id.replace("scriptAction:-", "")}`,
).catch((err) => console.error(err));
if (action.id.includes('scriptAction:-')) {
App.closeWindow('notificationsmenu');
Utils.execAsync(`${action.id.replace('scriptAction:-', '')}`).catch((err) =>
console.error(err),
);
notifs.CloseNotification(notif.id);
} else {
App.closeWindow("notificationsmenu");
App.closeWindow('notificationsmenu');
notif.invoke(action.id);
}
},
child: Widget.Box({
hpack: "center",
hpack: 'center',
hexpand: true,
children: [
Widget.Label({
class_name: "notification-action-buttons-label menu",
class_name: 'notification-action-buttons-label menu',
hexpand: true,
max_width_chars: 15,
truncate: "end",
truncate: 'end',
wrap: true,
label: action.label,
}),
@@ -41,7 +42,7 @@ const Actions = (notif: Notification, notifs: Notifications) => {
}
return Widget.Box({
class_name: "spacer",
class_name: 'spacer',
});
};

View File

@@ -1,23 +1,24 @@
import { notifHasImg } from "../../utils.js";
import { Notification } from "types/service/notifications";
import { BoxWidget } from 'lib/types/widget.js';
import { notifHasImg } from '../../utils.js';
import { Notification } from 'types/service/notifications';
export const Body = (notif: Notification) => {
export const Body = (notif: Notification): BoxWidget => {
return Widget.Box({
vpack: "start",
vpack: 'start',
hexpand: true,
class_name: "notification-card-body menu",
class_name: 'notification-card-body menu',
children: [
Widget.Label({
hexpand: true,
use_markup: true,
xalign: 0,
justification: "left",
truncate: "end",
justification: 'left',
truncate: 'end',
lines: 2,
max_width_chars: !notifHasImg(notif) ? 35 : 28,
wrap: true,
class_name: "notification-card-body-label menu",
label: notif["body"],
class_name: 'notification-card-body-label menu',
label: notif['body'],
}),
],
});

View File

@@ -1,14 +1,17 @@
import { Notification, Notifications } from "types/service/notifications";
export const CloseButton = (notif: Notification, notifs: Notifications) => {
import { Attribute } from 'lib/types/widget';
import { Notification, Notifications } from 'types/service/notifications';
import Button from 'types/widgets/button';
import Label from 'types/widgets/label';
export const CloseButton = (notif: Notification, notifs: Notifications): Button<Label<Attribute>, Attribute> => {
return Widget.Button({
class_name: "close-notification-button menu",
class_name: 'close-notification-button menu',
on_primary_click: () => {
notifs.CloseNotification(notif.id);
},
child: Widget.Label({
class_name: "txt-icon notif-close",
label: "󰅜",
hpack: "center",
class_name: 'txt-icon notif-close',
label: '󰅜',
hpack: 'center',
}),
});
};

View File

@@ -1,15 +1,16 @@
import { Notification } from "types/service/notifications.js";
import { NotificationIcon } from "lib/types/notification.js";
import { getNotificationIcon } from "globals/notification";
import { Notification } from 'types/service/notifications.js';
import { NotificationIcon } from 'lib/types/notification.js';
import { getNotificationIcon } from 'globals/notification';
import { BoxWidget } from 'lib/types/widget';
const NotificationIcon = ({ app_entry = "", app_icon = "", app_name = "" }: Partial<Notification>) => {
const NotificationIcon = ({ app_entry = '', app_icon = '', app_name = '' }: Partial<Notification>): BoxWidget => {
return Widget.Box({
css: `
min-width: 2rem;
min-height: 2rem;
`,
child: Widget.Icon({
class_name: "notification-icon menu",
class_name: 'notification-icon menu',
icon: getNotificationIcon(app_name, app_icon, app_entry),
}),
});

View File

@@ -1,50 +1,51 @@
import GLib from "gi://GLib";
import { Notification } from "types/service/notifications";
import { NotificationIcon } from "./icon.js";
import { notifHasImg } from "../../utils.js";
import options from "options.js";
import GLib from 'gi://GLib';
import { Notification } from 'types/service/notifications';
import { NotificationIcon } from './icon.js';
import { notifHasImg } from '../../utils.js';
import options from 'options.js';
import { BoxWidget } from 'lib/types/widget.js';
const { military } = options.menus.clock.time;
export const Header = (notif: Notification) => {
const time = (time: number, format = "%I:%M %p") => {
return GLib.DateTime.new_from_unix_local(time).format(military.value ? "%H:%M" : format);
}
export const Header = (notif: Notification): BoxWidget => {
const time = (time: number, format = '%I:%M %p'): string => {
return GLib.DateTime.new_from_unix_local(time).format(military.value ? '%H:%M' : format) || '--:--';
};
return Widget.Box({
vertical: false,
hexpand: true,
children: [
Widget.Box({
class_name: "notification-card-header menu",
hpack: "start",
class_name: 'notification-card-header menu',
hpack: 'start',
children: [NotificationIcon(notif)],
}),
Widget.Box({
class_name: "notification-card-header menu",
class_name: 'notification-card-header menu',
hexpand: true,
vpack: "start",
vpack: 'start',
children: [
Widget.Label({
class_name: "notification-card-header-label menu",
hpack: "start",
class_name: 'notification-card-header-label menu',
hpack: 'start',
hexpand: true,
vexpand: true,
max_width_chars: !notifHasImg(notif) ? 34 : 22,
truncate: "end",
truncate: 'end',
wrap: true,
label: notif["summary"],
label: notif['summary'],
}),
],
}),
Widget.Box({
class_name: "notification-card-header menu",
hpack: "end",
vpack: "start",
class_name: 'notification-card-header menu',
hpack: 'end',
vpack: 'start',
hexpand: true,
child: Widget.Label({
vexpand: true,
class_name: "notification-time",
class_name: 'notification-time',
label: time(notif.time),
}),
}),

View File

@@ -1,17 +1,18 @@
import { Notification } from "types/service/notifications";
import { notifHasImg } from "../../utils.js";
import { Notification } from 'types/service/notifications';
import { notifHasImg } from '../../utils.js';
import { BoxWidget } from 'lib/types/widget.js';
const Image = (notif: Notification) => {
const Image = (notif: Notification): BoxWidget => {
if (notifHasImg(notif)) {
return Widget.Box({
class_name: "notification-card-image-container menu",
hpack: "center",
vpack: "center",
class_name: 'notification-card-image-container menu',
hpack: 'center',
vpack: 'center',
vexpand: false,
child: Widget.Box({
hpack: "center",
hpack: 'center',
vexpand: false,
class_name: "notification-card-image menu",
class_name: 'notification-card-image menu',
css: `background-image: url("${notif.image}")`,
}),
});

View File

@@ -1,45 +1,40 @@
import { Notifications, Notification } from "types/service/notifications";
import { notifHasImg } from "../utils.js";
import { Header } from "./header/index.js";
import { Actions } from "./actions/index.js";
import { Image } from "./image/index.js";
import { Placeholder } from "./placeholder/index.js";
import { Body } from "./body/index.js";
import { CloseButton } from "./close/index.js";
import options from "options.js";
import { Variable } from "types/variable.js";
import { filterNotifications } from "lib/shared/notifications.js";
import { Notifications, Notification } from 'types/service/notifications';
import { notifHasImg } from '../utils.js';
import { Header } from './header/index.js';
import { Actions } from './actions/index.js';
import { Image } from './image/index.js';
import { Placeholder } from './placeholder/index.js';
import { Body } from './body/index.js';
import { CloseButton } from './close/index.js';
import options from 'options.js';
import { Variable } from 'types/variable.js';
import { filterNotifications } from 'lib/shared/notifications.js';
import Scrollable from 'types/widgets/scrollable.js';
import { Attribute, Child } from 'lib/types/widget.js';
const { displayedTotal, ignore } = options.notifications;
const NotificationCard = (notifs: Notifications, curPage: Variable<number>) => {
const NotificationCard = (notifs: Notifications, curPage: Variable<number>): Scrollable<Child, Attribute> => {
return Widget.Scrollable({
vscroll: "automatic",
vscroll: 'automatic',
child: Widget.Box({
class_name: "menu-content-container notifications",
hpack: "center",
class_name: 'menu-content-container notifications',
hpack: 'center',
vexpand: true,
spacing: 0,
vertical: true,
setup: (self) => {
Utils.merge(
[
notifs.bind("notifications"),
curPage.bind("value"),
displayedTotal.bind("value"),
ignore.bind("value")
notifs.bind('notifications'),
curPage.bind('value'),
displayedTotal.bind('value'),
ignore.bind('value'),
],
(
notifications,
currentPage,
dispTotal,
ignoredNotifs
) => {
(notifications, currentPage, dispTotal, ignoredNotifs) => {
const filteredNotifications = filterNotifications(notifications, ignoredNotifs);
const sortedNotifications = filteredNotifications.sort(
(a, b) => b.time - a.time,
);
const sortedNotifications = filteredNotifications.sort((a, b) => b.time - a.time);
if (filteredNotifications.length <= 0) {
return (self.children = [Placeholder(notifs)]);
@@ -47,37 +42,36 @@ const NotificationCard = (notifs: Notifications, curPage: Variable<number>) => {
const pageStart = (currentPage - 1) * dispTotal;
const pageEnd = currentPage * dispTotal;
return (self.children = sortedNotifications.slice(pageStart, pageEnd).map((notif: Notification) => {
return Widget.Box({
class_name: "notification-card-content-container",
children: [
Widget.Box({
class_name: "notification-card menu",
vpack: "start",
hexpand: true,
vexpand: false,
children: [
Image(notif),
Widget.Box({
vpack: "center",
vertical: true,
hexpand: true,
class_name: `notification-card-content ${!notifHasImg(notif) ? "noimg" : " menu"}`,
children: [
Header(notif),
Body(notif),
Actions(notif, notifs),
],
}),
],
}),
CloseButton(notif, notifs),
],
});
}));
});
return (self.children = sortedNotifications
.slice(pageStart, pageEnd)
.map((notif: Notification) => {
return Widget.Box({
class_name: 'notification-card-content-container',
children: [
Widget.Box({
class_name: 'notification-card menu',
vpack: 'start',
hexpand: true,
vexpand: false,
children: [
Image(notif),
Widget.Box({
vpack: 'center',
vertical: true,
hexpand: true,
class_name: `notification-card-content ${!notifHasImg(notif) ? 'noimg' : ' menu'}`,
children: [Header(notif), Body(notif), Actions(notif, notifs)],
}),
],
}),
CloseButton(notif, notifs),
],
});
}));
},
);
},
})
}),
});
};

View File

@@ -1,24 +1,25 @@
import { Notifications } from "types/service/notifications";
import { BoxWidget } from 'lib/types/widget';
import { Notifications } from 'types/service/notifications';
const Placeholder = (notifs: Notifications) => {
const Placeholder = (notifs: Notifications): BoxWidget => {
return Widget.Box({
class_name: "notification-label-container",
vpack: "fill",
hpack: "center",
class_name: 'notification-label-container',
vpack: 'fill',
hpack: 'center',
expand: true,
child: Widget.Box({
vpack: "center",
vpack: 'center',
vertical: true,
expand: true,
children: [
Widget.Label({
vpack: "center",
class_name: "placeholder-label dim bell",
label: notifs.bind("dnd").as((dnd) => (dnd ? "󰂛" : "󰂚")),
vpack: 'center',
class_name: 'placeholder-label dim bell',
label: notifs.bind('dnd').as((dnd) => (dnd ? '󰂛' : '󰂚')),
}),
Widget.Label({
vpack: "start",
class_name: "placehold-label dim message",
vpack: 'start',
class_name: 'placehold-label dim message',
label: "You're all caught up :)",
}),
],