mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Chore: Remove recently-added .gitignored files (#10898)
This commit is contained in:
parent
c19d0773b3
commit
ea420967c4
@ -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 = `
|
|
||||||
<div class="update-notification" style="color: ${theme.color2};">
|
|
||||||
${updateAvailableHtml} <a href="#" onclick="openChangelogLink()" style="color: ${theme.color2};">${seeChangelogHtml}</a>
|
|
||||||
<div style="display: flex; gap: 10px; margin-top: 8px;">
|
|
||||||
<button onclick="document.dispatchEvent(new CustomEvent('${UpdateNotificationEvents.ApplyUpdate}'))" class="notyf__button notyf__button--confirm" style="color: ${theme.color2};">${restartNowHtml}</button>
|
|
||||||
<button onclick="document.dispatchEvent(new CustomEvent('${UpdateNotificationEvents.Dismiss}'))" class="notyf__button notyf__button--dismiss" style="color: ${theme.color2};">${updateLaterHtml}</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
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
|
|
@ -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
|
|
@ -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
|
|
Loading…
Reference in New Issue
Block a user