mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-17 18:37:04 -04:00
parent
c91b0df607
commit
faa90eccd3
8 changed files with 182 additions and 27 deletions
|
@ -117,6 +117,7 @@ const ModalAPI = mapMangledModuleLazy("onCloseRequest:null!=", {
|
|||
openModal: filters.byCode("onCloseRequest:null!="),
|
||||
closeModal: filters.byCode("onCloseCallback&&"),
|
||||
openModalLazy: m => m?.length === 1 && filters.byCode(".apply(this,arguments)")(m),
|
||||
closeAllModals: filters.byCode(".value.key,")
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -142,3 +143,10 @@ export function openModal(render: RenderFunction, options?: ModalOptions, contex
|
|||
export function closeModal(modalKey: string, contextKey?: string): void {
|
||||
return ModalAPI.closeModal(modalKey, contextKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close all open modals
|
||||
*/
|
||||
export function closeAllModals(): void {
|
||||
return ModalAPI.closeAllModals();
|
||||
}
|
||||
|
|
|
@ -75,6 +75,10 @@ export interface PluginDef {
|
|||
* Whether this plugin is required and forcefully enabled
|
||||
*/
|
||||
required?: boolean;
|
||||
/**
|
||||
* Whether this plugin should be enabled by default, but can be disabled
|
||||
*/
|
||||
enabledByDefault?: boolean;
|
||||
/**
|
||||
* Set this if your plugin only works on Browser or Desktop, not both
|
||||
*/
|
||||
|
|
|
@ -77,3 +77,25 @@ export async function rebuild() {
|
|||
return oldHashes["patcher.js"] !== newHashes["patcher.js"] ||
|
||||
oldHashes["preload.js"] !== newHashes["preload.js"];
|
||||
}
|
||||
|
||||
export async function maybePromptToUpdate(confirmMessage: string, checkForDev = false) {
|
||||
if (IS_WEB) return;
|
||||
if (checkForDev && IS_DEV) return;
|
||||
|
||||
try {
|
||||
const isOutdated = await checkForUpdates();
|
||||
if (isOutdated) {
|
||||
const wantsUpdate = confirm(confirmMessage);
|
||||
if (wantsUpdate && isNewer) return alert("Your local copy has more recent commits. Please stash or reset them.");
|
||||
if (wantsUpdate) {
|
||||
await update();
|
||||
const needFullRestart = await rebuild();
|
||||
if (needFullRestart) DiscordNative.app.relaunch();
|
||||
else location.reload();
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
UpdateLogger.error(err);
|
||||
alert("That also failed :( Try updating or re-installing with the installer!");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue