From ea420967c4eff64d7ebef36c03448d8865177821 Mon Sep 17 00:00:00 2001 From: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Date: Thu, 22 Aug 2024 13:52:17 -0700 Subject: [PATCH] Chore: Remove recently-added .gitignored files (#10898) --- .../UpdateNotification/UpdateNotification.js | 85 ---------------- .../autoUpdater/AutoUpdaterService.js | 99 ------------------- packages/lib/models/utils/getCollator.js | 14 --- 3 files changed, 198 deletions(-) delete mode 100644 packages/app-desktop/gui/UpdateNotification/UpdateNotification.js delete mode 100644 packages/app-desktop/services/autoUpdater/AutoUpdaterService.js delete mode 100644 packages/lib/models/utils/getCollator.js diff --git a/packages/app-desktop/gui/UpdateNotification/UpdateNotification.js b/packages/app-desktop/gui/UpdateNotification/UpdateNotification.js deleted file mode 100644 index 0c0d187f3..000000000 --- a/packages/app-desktop/gui/UpdateNotification/UpdateNotification.js +++ /dev/null @@ -1,85 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.UpdateNotificationEvents = void 0; -const React = require("react"); -const react_1 = require("react"); -const theme_1 = require("@joplin/lib/theme"); -const NotyfContext_1 = require("../NotyfContext"); -const electron_1 = require("electron"); -const AutoUpdaterService_1 = require("../../services/autoUpdater/AutoUpdaterService"); -const locale_1 = require("@joplin/lib/locale"); -const html_1 = require("@joplin/utils/html"); -var UpdateNotificationEvents; -(function (UpdateNotificationEvents) { - UpdateNotificationEvents["ApplyUpdate"] = "apply-update"; - UpdateNotificationEvents["Dismiss"] = "dismiss-update-notification"; -})(UpdateNotificationEvents || (exports.UpdateNotificationEvents = UpdateNotificationEvents = {})); -const changelogLink = 'https://github.com/laurent22/joplin/releases'; -window.openChangelogLink = () => { - electron_1.ipcRenderer.send('open-link', changelogLink); -}; -const UpdateNotification = ({ themeId }) => { - const notyfContext = (0, react_1.useContext)(NotyfContext_1.default); - const notificationRef = (0, react_1.useRef)(null); // Use ref to hold the current notification - const theme = (0, react_1.useMemo)(() => (0, theme_1.themeStyle)(themeId), [themeId]); - const notyf = (0, react_1.useMemo)(() => { - const output = notyfContext; - output.options.types = notyfContext.options.types.map(type => { - if (type.type === 'success') { - type.background = theme.backgroundColor5; - // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied - type.icon.color = theme.backgroundColor5; - } - return type; - }); - return output; - }, [notyfContext, theme]); - const handleDismissNotification = (0, react_1.useCallback)(() => { - notyf.dismiss(notificationRef.current); - notificationRef.current = null; - }, [notyf]); - const handleApplyUpdate = (0, react_1.useCallback)(() => { - electron_1.ipcRenderer.send('apply-update-now'); - handleDismissNotification(); - }, [handleDismissNotification]); - const handleUpdateDownloaded = (0, react_1.useCallback)((_event, info) => { - if (notificationRef.current) - return; - const updateAvailableHtml = (0, html_1.htmlentities)((0, locale_1._)('A new update (%s) is available', info.version)); - const seeChangelogHtml = (0, html_1.htmlentities)((0, locale_1._)('See changelog')); - const restartNowHtml = (0, html_1.htmlentities)((0, locale_1._)('Restart now')); - const updateLaterHtml = (0, html_1.htmlentities)((0, locale_1._)('Update later')); - const messageHtml = ` -
- ${updateAvailableHtml} ${seeChangelogHtml} -
- - -
-
- `; - const notification = notyf.open({ - type: 'success', - message: messageHtml, - position: { - x: 'right', - y: 'bottom', - }, - duration: 0, - }); - notificationRef.current = notification; - }, [notyf, theme]); - (0, react_1.useEffect)(() => { - electron_1.ipcRenderer.on(AutoUpdaterService_1.AutoUpdaterEvents.UpdateDownloaded, handleUpdateDownloaded); - document.addEventListener(UpdateNotificationEvents.ApplyUpdate, handleApplyUpdate); - document.addEventListener(UpdateNotificationEvents.Dismiss, handleDismissNotification); - return () => { - electron_1.ipcRenderer.removeListener(AutoUpdaterService_1.AutoUpdaterEvents.UpdateDownloaded, handleUpdateDownloaded); - document.removeEventListener(UpdateNotificationEvents.ApplyUpdate, handleApplyUpdate); - document.removeEventListener(UpdateNotificationEvents.Dismiss, handleDismissNotification); - }; - }, [handleApplyUpdate, handleDismissNotification, handleUpdateDownloaded]); - return (React.createElement("div", { style: { display: 'none' } })); -}; -exports.default = UpdateNotification; -//# sourceMappingURL=UpdateNotification.js.map \ No newline at end of file diff --git a/packages/app-desktop/services/autoUpdater/AutoUpdaterService.js b/packages/app-desktop/services/autoUpdater/AutoUpdaterService.js deleted file mode 100644 index a7d09cc95..000000000 --- a/packages/app-desktop/services/autoUpdater/AutoUpdaterService.js +++ /dev/null @@ -1,99 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.AutoUpdaterEvents = void 0; -const electron_1 = require("electron"); -const electron_updater_1 = require("electron-updater"); -const electron_log_1 = require("electron-log"); -const path = require("path"); -const timers_1 = require("timers"); -var AutoUpdaterEvents; -(function (AutoUpdaterEvents) { - AutoUpdaterEvents["CheckingForUpdate"] = "checking-for-update"; - AutoUpdaterEvents["UpdateAvailable"] = "update-available"; - AutoUpdaterEvents["UpdateNotAvailable"] = "update-not-available"; - AutoUpdaterEvents["Error"] = "error"; - AutoUpdaterEvents["DownloadProgress"] = "download-progress"; - AutoUpdaterEvents["UpdateDownloaded"] = "update-downloaded"; -})(AutoUpdaterEvents || (exports.AutoUpdaterEvents = AutoUpdaterEvents = {})); -const defaultUpdateInterval = 12 * 60 * 60 * 1000; -const initialUpdateStartup = 5 * 1000; -class AutoUpdaterService { - constructor() { - this.updatePollInterval_ = null; - this.startPeriodicUpdateCheck = (interval = defaultUpdateInterval) => { - this.stopPeriodicUpdateCheck(); - this.updatePollInterval_ = (0, timers_1.setInterval)(() => { - void this.checkForUpdates(); - }, interval); - setTimeout(this.checkForUpdates, initialUpdateStartup); - }; - this.stopPeriodicUpdateCheck = () => { - if (this.updatePollInterval_) { - clearInterval(this.updatePollInterval_); - this.updatePollInterval_ = null; - } - }; - this.checkForUpdates = () => __awaiter(this, void 0, void 0, function* () { - try { - yield electron_updater_1.autoUpdater.checkForUpdates(); // Use async/await - } - catch (error) { - electron_log_1.default.error('Failed to check for updates:', error); - if (error.message.includes('ERR_CONNECTION_REFUSED')) { - electron_log_1.default.info('Server is not reachable. Will try again later.'); - } - } - }); - this.configureAutoUpdater = () => { - electron_updater_1.autoUpdater.logger = electron_log_1.default; - electron_log_1.default.transports.file.level = 'info'; - if (this.electronIsDev()) { - electron_log_1.default.info('Development mode: using dev-app-update.yml'); - electron_updater_1.autoUpdater.updateConfigPath = path.join(__dirname, 'dev-app-update.yml'); - electron_updater_1.autoUpdater.forceDevUpdateConfig = true; - } - electron_updater_1.autoUpdater.autoDownload = false; - electron_updater_1.autoUpdater.on(AutoUpdaterEvents.CheckingForUpdate, this.onCheckingForUpdate); - electron_updater_1.autoUpdater.on(AutoUpdaterEvents.UpdateNotAvailable, this.onUpdateNotAvailable); - electron_updater_1.autoUpdater.on(AutoUpdaterEvents.UpdateAvailable, this.onUpdateAvailable); - electron_updater_1.autoUpdater.on(AutoUpdaterEvents.DownloadProgress, this.onDownloadProgress); - electron_updater_1.autoUpdater.on(AutoUpdaterEvents.UpdateDownloaded, this.onUpdateDownloaded); - electron_updater_1.autoUpdater.on(AutoUpdaterEvents.Error, this.onError); - }; - this.electronIsDev = () => !electron_1.app.isPackaged; - this.onCheckingForUpdate = () => { - electron_log_1.default.info('Checking for update...'); - }; - this.onUpdateNotAvailable = (_info) => { - electron_log_1.default.info('Update not available.'); - }; - this.onUpdateAvailable = (info) => { - electron_log_1.default.info(`Update available: ${info.version}.`); - }; - this.onDownloadProgress = (progressObj) => { - electron_log_1.default.info(`Download progress... ${progressObj.percent}% completed`); - }; - this.onUpdateDownloaded = (info) => { - electron_log_1.default.info('Update downloaded. It will be installed on restart.'); - void this.promptUserToUpdate(info); - }; - this.onError = (error) => { - electron_log_1.default.error('Error in auto-updater.', error); - }; - this.promptUserToUpdate = (info) => __awaiter(this, void 0, void 0, function* () { - electron_log_1.default.info(`Update is available: ${info.version}.`); - }); - this.configureAutoUpdater(); - } -} -exports.default = AutoUpdaterService; -//# sourceMappingURL=AutoUpdaterService.js.map \ No newline at end of file diff --git a/packages/lib/models/utils/getCollator.js b/packages/lib/models/utils/getCollator.js deleted file mode 100644 index b8557612d..000000000 --- a/packages/lib/models/utils/getCollator.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.getCollatorLocale = exports.getCollator = void 0; -const locale_1 = require("../../locale"); -function getCollator(locale = getCollatorLocale()) { - return new Intl.Collator(locale, { numeric: true, sensitivity: 'accent' }); -} -exports.getCollator = getCollator; -function getCollatorLocale() { - const collatorLocale = (0, locale_1.languageCodeOnly)((0, locale_1.currentLocale)()); - return collatorLocale; -} -exports.getCollatorLocale = getCollatorLocale; -//# sourceMappingURL=getCollator.js.map \ No newline at end of file