Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement silent update functionality #2131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Extensions/xkit_patches.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//* TITLE XKit Patches **//
//* VERSION 7.4.19 **//
//* VERSION 7.4.20 **//
//* DESCRIPTION Patches framework **//
//* DEVELOPER new-xkit **//

Expand Down Expand Up @@ -1326,6 +1326,7 @@ XKit.extensions.xkit_patches = new Object({
version.major = parseInt(versionSplit[0]);
version.minor = parseInt(versionSplit[1]);
version.patch = parseInt(versionSplit[2]);
version.silent_patch = versionSplit[3] ? parseInt(versionSplit[3]) : 0;
}
return version;
};
Expand Down
22 changes: 17 additions & 5 deletions Extensions/xkit_updates.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//* TITLE XKit Updates **//
//* VERSION 2.1.2 **//
//* VERSION 2.1.3 **//
//* DESCRIPTION Provides automatic updating of extensions **//
//* DEVELOPER new-xkit **//
XKit.extensions.xkit_updates = new Object({
Expand Down Expand Up @@ -55,6 +55,7 @@ XKit.extensions.xkit_updates = new Object({

to_update: "",
to_update_index: 0,
to_update_silent: [],
updated_list: "",
updated_list_versions: "",

Expand All @@ -74,6 +75,7 @@ XKit.extensions.xkit_updates = new Object({

XKit.extensions.xkit_updates.to_update_index = 0;
XKit.extensions.xkit_updates.to_update = [];
XKit.extensions.xkit_updates.to_update_silent = [];
XKit.extensions.xkit_updates.updated_list = [];
XKit.extensions.xkit_updates.updated_list_versions = [];

Expand All @@ -95,14 +97,18 @@ XKit.extensions.xkit_updates = new Object({

if (check_this) {
XKit.extensions.xkit_updates.to_update.push(mdata.extensions[extension].name);
XKit.extensions.xkit_updates.to_update_silent.push(false);
}
}

} else {

if (XKit.installed.check(mdata.extensions[extension].name)) {
if (XKit.extensions.xkit_updates.shouldUpdate(XKit.tools.parse_version(XKit.installed.get(mdata.extensions[extension].name).version), XKit.tools.parse_version(mdata.extensions[extension].version))) {
const shouldUpdate = XKit.extensions.xkit_updates.shouldUpdate(XKit.tools.parse_version(XKit.installed.get(mdata.extensions[extension].name).version), XKit.tools.parse_version(mdata.extensions[extension].version));

if (shouldUpdate) {
XKit.extensions.xkit_updates.to_update.push(mdata.extensions[extension].name);
XKit.extensions.xkit_updates.to_update_silent.push(shouldUpdate === 'silent');
}
}

Expand Down Expand Up @@ -202,7 +208,7 @@ XKit.extensions.xkit_updates = new Object({

var to_show = XKit.tools.get_setting("xkit_show_update_notifications", "true");

if (to_show === "true") {
if (XKit.extensions.xkit_updates.updated_list.length && to_show === "true") {
var suffix = "";

if (XKit.extensions.xkit_updates.updated_list.length !== 1) {
Expand Down Expand Up @@ -246,8 +252,11 @@ XKit.extensions.xkit_updates = new Object({
}
}

XKit.extensions.xkit_updates.updated_list.push(mdata.title);
XKit.extensions.xkit_updates.updated_list_versions.push(mdata.version);
if (XKit.extensions.xkit_updates.to_update_silent[XKit.extensions.xkit_updates.to_update_index] === false) {
XKit.extensions.xkit_updates.updated_list.push(mdata.title);
XKit.extensions.xkit_updates.updated_list_versions.push(mdata.version);
}

console.log("Updated " + XKit.extensions.xkit_updates.to_update[XKit.extensions.xkit_updates.to_update_index]);
XKit.extensions.xkit_updates.to_update_index++;
XKit.extensions.xkit_updates.update_next(force_mode);
Expand Down Expand Up @@ -317,6 +326,9 @@ XKit.extensions.xkit_updates = new Object({
if ((versionRemote.patch > versionCurrent.patch) && (versionRemote.major >= versionCurrent.major) && (versionRemote.minor >= versionCurrent.minor)) {
return true;
}
if ((versionRemote.silent_patch > versionCurrent.silent_patch) && (versionRemote.patch === versionCurrent.patch) && (versionRemote.major === versionCurrent.major) && (versionRemote.minor === versionCurrent.minor)) {
return 'silent';
}
return false;
},

Expand Down
Loading