mirror of
https://github.com/hyperspacedev/hyperspace
synced 2025-02-09 16:28:43 +01:00
Add check-prettier to GitHub actions
Signed-off-by: Marquis Kurt <software@marquiskurt.net>
This commit is contained in:
parent
cbb12c4455
commit
298b7606cb
22
.github/workflows/review-style.yml
vendored
Normal file
22
.github/workflows/review-style.yml
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
name: Prettier
|
||||||
|
|
||||||
|
on: [pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Clone source code
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
- name: Install Node
|
||||||
|
uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 10.x
|
||||||
|
- name: Install dependencies and run Prettier
|
||||||
|
run: |
|
||||||
|
npm install
|
||||||
|
npm run check-prettier
|
||||||
|
env:
|
||||||
|
CI: true
|
@ -56,6 +56,7 @@
|
|||||||
"build-desktop-darwin-nosign": "npm run create-mac-icon; electron-builder -p 'never' -m dmg -c.mac.identity=null -c.afterSign=\"desktop/donothing.js\"",
|
"build-desktop-darwin-nosign": "npm run create-mac-icon; electron-builder -p 'never' -m dmg -c.mac.identity=null -c.afterSign=\"desktop/donothing.js\"",
|
||||||
"build-desktop-linux": "electron-builder -p 'never' -l deb AppImage snap",
|
"build-desktop-linux": "electron-builder -p 'never' -l deb AppImage snap",
|
||||||
"build-desktop-linux-select": "electron-builder -p 'never' -l ",
|
"build-desktop-linux-select": "electron-builder -p 'never' -l ",
|
||||||
|
"check-prettier": "prettier --check src/**/**.tsx",
|
||||||
"test": "react-scripts test",
|
"test": "react-scripts test",
|
||||||
"eject": "react-scripts eject"
|
"eject": "react-scripts eject"
|
||||||
},
|
},
|
||||||
|
@ -2,16 +2,16 @@
|
|||||||
* Basic type for Cards, usually in Statuses
|
* Basic type for Cards, usually in Statuses
|
||||||
*/
|
*/
|
||||||
export type Card = {
|
export type Card = {
|
||||||
url: string;
|
url: string;
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
image: string | null;
|
image: string | null;
|
||||||
type: "link" | "photo" | "video" | "rich";
|
type: "link" | "photo" | "video" | "rich";
|
||||||
author_name: string | null;
|
author_name: string | null;
|
||||||
author_url: string | null;
|
author_url: string | null;
|
||||||
provider_name: string | null;
|
provider_name: string | null;
|
||||||
provider_url: string | null;
|
provider_url: string | null;
|
||||||
html: string | null;
|
html: string | null;
|
||||||
width: number | null;
|
width: number | null;
|
||||||
height: number | null;
|
height: number | null;
|
||||||
};
|
};
|
||||||
|
@ -7,5 +7,5 @@ import { isDarwinApp } from "./desktop";
|
|||||||
* @returns Boolean dictating if the title bar is visible
|
* @returns Boolean dictating if the title bar is visible
|
||||||
*/
|
*/
|
||||||
export function isAppbarExpanded(): boolean {
|
export function isAppbarExpanded(): boolean {
|
||||||
return isDarwinApp() || process.env.NODE_ENV === "development";
|
return isDarwinApp() || process.env.NODE_ENV === "development";
|
||||||
}
|
}
|
||||||
|
@ -4,22 +4,22 @@ import { getUserDefaultBool, setUserDefaultBool } from "./settings";
|
|||||||
* Get the person's permission to send notification requests.
|
* Get the person's permission to send notification requests.
|
||||||
*/
|
*/
|
||||||
export function getNotificationRequestPermission() {
|
export function getNotificationRequestPermission() {
|
||||||
if ("Notification" in window) {
|
if ("Notification" in window) {
|
||||||
Notification.requestPermission();
|
Notification.requestPermission();
|
||||||
let request = Notification.permission;
|
let request = Notification.permission;
|
||||||
if (request === "granted") {
|
if (request === "granted") {
|
||||||
setUserDefaultBool("enablePushNotifications", true);
|
setUserDefaultBool("enablePushNotifications", true);
|
||||||
setUserDefaultBool("userDeniedNotification", false);
|
setUserDefaultBool("userDeniedNotification", false);
|
||||||
|
} else {
|
||||||
|
setUserDefaultBool("enablePushNotifications", false);
|
||||||
|
setUserDefaultBool("userDeniedNotification", true);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setUserDefaultBool("enablePushNotifications", false);
|
console.warn(
|
||||||
setUserDefaultBool("userDeniedNotification", true);
|
"Notifications aren't supported in this browser. The setting will be disabled."
|
||||||
|
);
|
||||||
|
setUserDefaultBool("enablePushNotifications", false);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.warn(
|
|
||||||
"Notifications aren't supported in this browser. The setting will be disabled."
|
|
||||||
);
|
|
||||||
setUserDefaultBool("enablePushNotifications", false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,7 +27,7 @@ export function getNotificationRequestPermission() {
|
|||||||
* @returns Boolean value that determines whether the browser supports the Notification API
|
* @returns Boolean value that determines whether the browser supports the Notification API
|
||||||
*/
|
*/
|
||||||
export function browserSupportsNotificationRequests(): boolean {
|
export function browserSupportsNotificationRequests(): boolean {
|
||||||
return "Notification" in window;
|
return "Notification" in window;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,7 +35,7 @@ export function browserSupportsNotificationRequests(): boolean {
|
|||||||
* @returns Boolean value of `enablePushNotifications`
|
* @returns Boolean value of `enablePushNotifications`
|
||||||
*/
|
*/
|
||||||
export function canSendNotifications() {
|
export function canSendNotifications() {
|
||||||
return getUserDefaultBool("enablePushNotifications");
|
return getUserDefaultBool("enablePushNotifications");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,15 +44,15 @@ export function canSendNotifications() {
|
|||||||
* @param body The contents of the push notification
|
* @param body The contents of the push notification
|
||||||
*/
|
*/
|
||||||
export function sendNotificationRequest(title: string, body: string) {
|
export function sendNotificationRequest(title: string, body: string) {
|
||||||
if (canSendNotifications()) {
|
if (canSendNotifications()) {
|
||||||
let notif = new Notification(title, {
|
let notif = new Notification(title, {
|
||||||
body: body
|
body: body
|
||||||
});
|
});
|
||||||
|
|
||||||
notif.onclick = () => {
|
notif.onclick = () => {
|
||||||
window.focus();
|
window.focus();
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.warn("The person has opted to not receive push notifications.");
|
console.warn("The person has opted to not receive push notifications.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,13 @@ import { Config } from "../types/Config";
|
|||||||
import { Visibility } from "../types/Visibility";
|
import { Visibility } from "../types/Visibility";
|
||||||
|
|
||||||
type SettingsTemplate = {
|
type SettingsTemplate = {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
darkModeEnabled: boolean;
|
darkModeEnabled: boolean;
|
||||||
systemDecidesDarkMode: boolean;
|
systemDecidesDarkMode: boolean;
|
||||||
enablePushNotifications: boolean;
|
enablePushNotifications: boolean;
|
||||||
clearNotificationsOnRead: boolean;
|
clearNotificationsOnRead: boolean;
|
||||||
displayAllOnNotificationBadge: boolean;
|
displayAllOnNotificationBadge: boolean;
|
||||||
defaultVisibility: string;
|
defaultVisibility: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,14 +20,14 @@ type SettingsTemplate = {
|
|||||||
* @returns The boolean value associated with the key
|
* @returns The boolean value associated with the key
|
||||||
*/
|
*/
|
||||||
export function getUserDefaultBool(key: string): boolean {
|
export function getUserDefaultBool(key: string): boolean {
|
||||||
if (localStorage.getItem(key) === null) {
|
if (localStorage.getItem(key) === null) {
|
||||||
console.warn(
|
console.warn(
|
||||||
"This key has not been set before, so the default value is FALSE for now."
|
"This key has not been set before, so the default value is FALSE for now."
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return localStorage.getItem(key) === "true";
|
return localStorage.getItem(key) === "true";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,10 +36,10 @@ export function getUserDefaultBool(key: string): boolean {
|
|||||||
* @param value The boolean value for the key
|
* @param value The boolean value for the key
|
||||||
*/
|
*/
|
||||||
export function setUserDefaultBool(key: string, value: boolean) {
|
export function setUserDefaultBool(key: string, value: boolean) {
|
||||||
if (localStorage.getItem(key) === null) {
|
if (localStorage.getItem(key) === null) {
|
||||||
console.warn("This key has not been set before.");
|
console.warn("This key has not been set before.");
|
||||||
}
|
}
|
||||||
localStorage.setItem(key, value.toString());
|
localStorage.setItem(key, value.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,14 +47,14 @@ export function setUserDefaultBool(key: string, value: boolean) {
|
|||||||
* @returns The Visibility value associated with the key
|
* @returns The Visibility value associated with the key
|
||||||
*/
|
*/
|
||||||
export function getUserDefaultVisibility(): Visibility {
|
export function getUserDefaultVisibility(): Visibility {
|
||||||
if (localStorage.getItem("defaultVisibility") === null) {
|
if (localStorage.getItem("defaultVisibility") === null) {
|
||||||
console.warn(
|
console.warn(
|
||||||
"This key has not been set before, so the default value is PUBLIC for now."
|
"This key has not been set before, so the default value is PUBLIC for now."
|
||||||
);
|
);
|
||||||
return "public";
|
return "public";
|
||||||
} else {
|
} else {
|
||||||
return localStorage.getItem("defaultVisibility") as Visibility;
|
return localStorage.getItem("defaultVisibility") as Visibility;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,23 +62,23 @@ export function getUserDefaultVisibility(): Visibility {
|
|||||||
* @param key The settings key in localStorage to change
|
* @param key The settings key in localStorage to change
|
||||||
*/
|
*/
|
||||||
export function setUserDefaultVisibility(key: string) {
|
export function setUserDefaultVisibility(key: string) {
|
||||||
if (localStorage.getItem("defaultVisibility") === null) {
|
if (localStorage.getItem("defaultVisibility") === null) {
|
||||||
console.warn("This key has not been set before.");
|
console.warn("This key has not been set before.");
|
||||||
}
|
}
|
||||||
localStorage.setItem("defaultVisibility", key.toString());
|
localStorage.setItem("defaultVisibility", key.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the user's default theme or the default theme
|
* Gets the user's default theme or the default theme
|
||||||
*/
|
*/
|
||||||
export function getUserDefaultTheme() {
|
export function getUserDefaultTheme() {
|
||||||
let returnTheme = defaultTheme;
|
let returnTheme = defaultTheme;
|
||||||
themes.forEach(theme => {
|
themes.forEach(theme => {
|
||||||
if (theme.key === localStorage.getItem("theme")) {
|
if (theme.key === localStorage.getItem("theme")) {
|
||||||
returnTheme = theme;
|
returnTheme = theme;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return returnTheme;
|
return returnTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,42 +86,42 @@ export function getUserDefaultTheme() {
|
|||||||
* @param themeName The name of the theme
|
* @param themeName The name of the theme
|
||||||
*/
|
*/
|
||||||
export function setUserDefaultTheme(themeName: string) {
|
export function setUserDefaultTheme(themeName: string) {
|
||||||
localStorage.setItem("theme", themeName);
|
localStorage.setItem("theme", themeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the user defaults if they do not exist already.
|
* Creates the user defaults if they do not exist already.
|
||||||
*/
|
*/
|
||||||
export function createUserDefaults() {
|
export function createUserDefaults() {
|
||||||
let defaults: SettingsTemplate = {
|
let defaults: SettingsTemplate = {
|
||||||
darkModeEnabled: false,
|
darkModeEnabled: false,
|
||||||
systemDecidesDarkMode: true,
|
systemDecidesDarkMode: true,
|
||||||
enablePushNotifications: true,
|
enablePushNotifications: true,
|
||||||
clearNotificationsOnRead: false,
|
clearNotificationsOnRead: false,
|
||||||
displayAllOnNotificationBadge: false,
|
displayAllOnNotificationBadge: false,
|
||||||
defaultVisibility: "public"
|
defaultVisibility: "public"
|
||||||
};
|
};
|
||||||
|
|
||||||
let settings = [
|
let settings = [
|
||||||
"darkModeEnabled",
|
"darkModeEnabled",
|
||||||
"systemDecidesDarkMode",
|
"systemDecidesDarkMode",
|
||||||
"clearNotificationsOnRead",
|
"clearNotificationsOnRead",
|
||||||
"displayAllOnNotificationBadge",
|
"displayAllOnNotificationBadge",
|
||||||
"defaultVisibility"
|
"defaultVisibility"
|
||||||
];
|
];
|
||||||
|
|
||||||
migrateExistingSettings();
|
migrateExistingSettings();
|
||||||
|
|
||||||
settings.forEach((setting: string) => {
|
settings.forEach((setting: string) => {
|
||||||
if (localStorage.getItem(setting) === null) {
|
if (localStorage.getItem(setting) === null) {
|
||||||
if (typeof defaults[setting] === "boolean") {
|
if (typeof defaults[setting] === "boolean") {
|
||||||
setUserDefaultBool(setting, defaults[setting]);
|
setUserDefaultBool(setting, defaults[setting]);
|
||||||
} else {
|
} else {
|
||||||
localStorage.setItem(setting, defaults[setting].toString());
|
localStorage.setItem(setting, defaults[setting].toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
getNotificationRequestPermission();
|
getNotificationRequestPermission();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,22 +129,22 @@ export function createUserDefaults() {
|
|||||||
* @returns The Promise data from getting the config.
|
* @returns The Promise data from getting the config.
|
||||||
*/
|
*/
|
||||||
export async function getConfig(): Promise<Config | undefined> {
|
export async function getConfig(): Promise<Config | undefined> {
|
||||||
try {
|
try {
|
||||||
const resp = await axios.get("config.json");
|
const resp = await axios.get("config.json");
|
||||||
let config: Config = resp.data;
|
return resp.data as Config;
|
||||||
return config;
|
} catch (err) {
|
||||||
} catch (err) {
|
console.error(
|
||||||
console.error(
|
"Couldn't configure Hyperspace with the config file. Reason: " +
|
||||||
"Couldn't configure Hyperspace with the config file. Reason: " + err.name
|
err.name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function migrateExistingSettings() {
|
export function migrateExistingSettings() {
|
||||||
if (localStorage.getItem("prefers-dark-mode")) {
|
if (localStorage.getItem("prefers-dark-mode")) {
|
||||||
setUserDefaultBool(
|
setUserDefaultBool(
|
||||||
"darkModeEnabled",
|
"darkModeEnabled",
|
||||||
localStorage.getItem("prefers-dark-mode") === "true"
|
localStorage.getItem("prefers-dark-mode") === "true"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user