I'd like to take an action the first time a user loads a new version of my VS Code extension. This is different from merely detecting first run as described by the How to run vscode extension command just right after installation? because I don't want to detect "just right after installation" I want to detect first run of each new version which is a totally different problem.
Mike Lischke's answer to that question doesn't actually answer that question, it answers this question, but that doesn't mean this is a duplicate question, it means the response to the other question doesn't actually answer the asked question, and since unlike many people I actually read the question, I didn't bother to read the answers, because answers to that question are not what I seek. Frankly I'm tempted to delete the question myself just to spite Stack Overflow because I'm fed up with this crap. Do whatever you like.
Searching the net turned up sample code
export function activate(context: vscode.ExtensionContext) {
if (context.firstTimeUse) {
//do the one-time-per-version-update thing
}
}
but ExtensionContext doesn't seem to have this property, at least not any more.
So how do you do it now?
I could record the version in a file and compare to the file before updating it, but if there's baked in support I'd rather do it the supported way.
There is no supported mechanism.
Since each update gets a new folder, you don't need to log a timestamp, just probe for the file. If it exists, not first run. If it doesn't exist, first run so create the file and do other first run things.
This is so simple and straightforward there probably won't ever be a supported mechanism. Thanks to Lex Li in the comments for confirming that this is the standard solution.
If you need to differentiate major, minor and maintenance releases, the simplest solution is to store the version string in context.globalState. You begin by trying to fetch from context.globalState. Absence means first run ever. If it's present, an exact match for current version means no change. For a non-match you can parse out major and minor version numbers context.globalState.
const currentVersion = context.extension.packageJSON.version as string;
const lastVersion = context.globalState.get("version") as string ?? "0.0.0"
if (lastVersion !== currentVersion) {
logger.warn(`Updated to ${currentVersion}`);
const lastVersionPart = lastVersion.split(".");
const currVersionPart = currentVersion.split(".");
if (lastVersionPart[0] !== currVersionPart[0]) {
// major version change
advertiseWalkthrough();
if (lastVersionPart[1] !== currVersionPart[1]) {
// minor version change
launchWhatsNew();
} else {
// it's a maintenance version change so don't pester the user
}
}
context.globalState.update("version", currentVersion);
}
Related
Link 1.
What is the equivalent for
const user = await Auth.currentAuthenticatedUser();
const result = await Auth.updateUserAttributes(user, {
'custom:favorite_flavor': 'Strawberry'
});
in Flutter
amplify_core: '<1.0.0'
amplify_auth_cognito: '<1.0.0'
Took a look and found the simple answer that the exact copy over does not exists as i'm sure you have realized at this point.
The link:
https://docs.amplify.aws/lib/auth/manageusers/q/platform/js/ will fail to give you any comparable Flutter etc... pages & if you try it will return "Flutter is not supported on this page. Please select one of the following: Javascript."
Unfortunately, Javascript is not supported in android/IOS though there was some stuff out there to partially work with it https://medium.com/flutter-community/using-javascript-code-in-flutter-web-903de54a2000.
Hopefully this answer will become obsolete over time as more work is put into the needed functionality.
Basically, I've been developing a bot for several weeks now using the discord.js library and recently encountered a small but crucial issue. Essentially when I declare my argument, I also made it so that the message content (message.content) would be capitalized using .toUpperCase(). Essentially in doing so regardless of the type of prefix you would enter (symbol wise) it would all be read by the program as valid.
For example only: !help - should work, however if I would enter .help, it would also be read as valid.
In any case, here's the code. I appreciate all the help!
bot.on('message', message =>{
let args = message.content.toUpperCase().substring(PREFIX.length).split(" ");
const sender = message.member;
switch(args[0])
{
case 'HELP':
message.reply("I've sent you some documentation on all the commands that you can use...").then(d_msg => {d_msg.delete(3000); });
message.delete(3000);
const attachment = new Attachment('./UtilityBot_Documentation.txt')
message.author.send('[Education] Bot - Documentation');
message.author.send(attachment);
break;
}
})
The discord.js tutorial covers an extremely similar problem to what you're trying to do. I recommend you check it out. The page I linked in specific is doing a very similar thing to you, but it's worth giving the whole thing a read through if you haven't done so already. In general, I would include the following line just above where you established args.
if (!message.content.startsWith(PREFIX)) return;
What I'm doing here is saying if the message does not start with the prefix, stop running until a new message is sent. I might be missing something, but certainly check out the tutorial. It's really well written.
https://discordjs.guide/creating-your-bot/commands-with-user-input.html#basic-arguments
I need to check if the user's device can input from a camera on my site. To do this I am attempting to use modernizr. I have followed the steps/example code provided on their site but when I test the capture attribute, I always get undefined, regardless of if I am on a device that supports capture.
Steps I followed:
I browsed for the input[capture] attribute and added it to the build
I copied the demo code to check this feature and added it to my project
I downloaded the build, added the js file to my project, and included the appropriate reference in my page
However after all of this, when inspecting Modernizr.capture in the chrome inspector, it always shows up as undefined.
My basic check function is as follows:
$scope.hasCamera = function() {
if (Modernizr.capture) {
// supported
return true;
} else {
// not-supported
return false;
}
}
This is my first time using Modernizr. Am I missing a step or doing something incorrectly? I also installed modernizr using npm install and tried adding the reference to a json config file from the command line.
Alternatively, how might I check if my device has a camera?
Thank you very much for your time. Please let me know if I am being unclear or if you need any additional information from me.
A few things
while photos are helpful, actual code hosted in a public website (either your own project, or on something like jsbin.com) is 10x as useful. As a result, I am not sure why it is coming back as undefined.
The actual capture detect is quite simple. It all comes down to this
var capture = 'capture' in document.createElement('input')`
Your code is a lot more complicated than it needs to be. Lets break it down. You trying to set $scope.hasCamera to equal the result of Modernizr.capture, and you are using a function to check the value of Modernizr.capture, and if it is true, return true. If it is false, return false. There is a fair bit of duplicated logic, so we can break it down from the inside out.
Firstly, your testing for a true/false value, and then returning the same value. That means you could simplify the code by just returning the value of Modernizr.capture
$scope.hasCamera = function() {
return Modernizr.capture
}
While Modernizr will always be giving you a boolean value (when it is functioning - without seeing your actual code I can't say why it is coming back as undefined), if you are unsure of the value you can add !! before it to coerce it into a boolean. In your case, it would make undefined into false
$scope.hasCamera = function() {
return !!Modernizr.capture
}
At this point, you can see that we are setting up a function just to return a static value. That means we can just set assign that static value directly to the variable rather than setting up a function to do that
$scope.hasCamera = !!Modernizr.capture
Now, the final thing you may be able to do something better is if you are only using Modernizr for this one feature. Since it is such a simple feature detection, it is overkill to be using all of Modernizr.
$scope.hasCamera = 'capture' in document.createElement('input')`
I am encountering this issue in CE1.9.1.
When a User registers (doesn't matter if its during checkout or from the Create an Account link) the user keeps getting the password mismatch error even though the password is re-entered correctly.
The form validation does not indicate a miss-match, but once a user clicks on Register it returns the mismatch error.
There is no errors in the chrome console...
I found this: https://magento.stackexchange.com/questions/37381/please-make-sure-your-passwords-match-password-error-in-checkout-with-new-re
But I don't believe it is the same error.
I need to fix it soon, any help is greatly appreciated!
We also had this issue with 1 of our webshops. However we used a checkout extension. So im not sure if this applies for the regular standard checkout. Anyway.
The question should be, are u using a checkout extension?
If so, the value inside the model's file of that extension is set at:
$customer->setConfirmation($password);
but should be:
$customer->setPasswordConfirmation($password);
For me this worked, without changing anything in the core. It's just that the extensions should get a small update, or you can do it manually like i did. Just find that line in the files of the model map of your extension.
as workaround you can use folloing code:
$confirmation = $this->getConfirmation();
$passwordconfirmation = $this->getPasswordConfirmation();
//if ($password != $confirmation) {
if (!(($password == $confirmation) ||
($password == $passwordconfirmation))) {
$errors[] = Mage::helper('customer')->__('Please make sure your passwords match.');
}
Changing app/code/core/Mage/Customer/Model/Customer.php as proposed by #Pedro breaks the functionality of "forgot password" and "edit customer account" pages. Instead, make the following changes to
app/code/core/Mage/Checkout/Model/Type/Onepage.php
by editing lines starting from 369
if ($quote->getCheckoutMethod() == self::METHOD_REGISTER) {
// set customer password
$customer->setPassword($customerRequest->getParam('customer_password'));
$customer->setConfirmation($customerRequest->getParam('confirm_password'));
} else {
// emulate customer password for quest
$password = $customer->generatePassword();
$customer->setPassword($password);
$customer->setConfirmation($password);
}
and set the PasswordConfirmation -Property and not the Confirmation-Property of the Customer-Object:
if ($quote->getCheckoutMethod() == self::METHOD_REGISTER) {
// set customer password
$customer->setPassword($customerRequest->getParam('customer_password'));
$customer->setPasswordConfirmation($customerRequest->getParam('confirm_password'));
} else {
// emulate customer password for quest
$password = $customer->generatePassword();
$customer->setPassword($password);
$customer->setPasswordConfirmation($password);
}
Encountered the same problem and fixed it. Snel's answer is closer to right answer. The problem could lay in the external/local modules, so you should check not the
app/code/core/Mage/Checkout/Model/Type/Onepage.php
And of course do NOT modify it in any case!
But you should find _validateCustomerData() method which is used in your case. Use Mage::log() or debug_backtrace() for it. It may look something like (but not exactly, because this part could be modified for some reason):
if ($quote->getCheckoutMethod() == self::METHOD_REGISTER) {
// set customer password
$customer->setPassword($customerRequest->getParam('customer_password'));
$customer->setConfirmation($customerRequest->getParam('confirm_password'));
} else {
// emulate customer password for quest
$password = $customer->generatePassword();
$customer->setPassword($password);
$customer->setConfirmation($password);
}
Those modules extend the old version of core file so if you module wasn't updated, you should change them yourself and change
setConfirmation()
to its current usable analog:
setPasswordConfirmation()
I also had this same problem. I'm not comfortable with code so I wanted to avoid all the above fiddling. To fix it all I did was update my extensions, and I also disable one page checkout, cleared cache, then re-enabled one-page checkout.
This has now fixed the problem without needing to modify code.
hope it helps for you.
If anybody still can't figure out, why this is happening:
The Conlabz Useroptin extension (http://www.magentocommerce.com/magento-connect/newsletter-double-opt-in-for-customers.html) can cause this behavior aswell.
Unless this truly is a core bug, I wouldn't recommend changing core files.But i sloved this way Open app\code\core\Mage\Customer\Model\Customer.php and edit your code like below
$confirmation = $this->getConfirmation();
$passwordconfirmation = $this->getPasswordConfirmation();
//if ($password != $confirmation) {
if (!(($password == $confirmation) ||
($password == $passwordconfirmation))) {
$errors[] = Mage::helper('customer')->__('Please make sure your passwords match.');
}
I had the same issue after updating to 1.9.2.1 and was unable to resolve using some of the suggested code changes here and elsewhere - also very reluctant to change core code for obvious reasons.
My solution - a configuration update. It was:
Enable OnePage Checkout = Yes
Allow Guest Checkout = Yes
Require Customer to be Logged in = No
I updated to Yes/No/Yes as per the above and cleared the cache. This resolved the issue by inserting the standard customer registration form (rather than appending the registration to end of the billing info) and passing that info to the billing form on successful registration.
It seems there is a code issue here along the lines of the other responses but this was an excellent workaround for me. Hope it helps.
Change this code
app\code\core\Mage\Customer\Model\Customer.php
$confirmation = $this->getPasswordConfirmation();
to this code
$confirmation = $this->getConfirmation();
How can I specify that I ALWAYS want the local file to replace the server copy even if the TFS copy is newer?
if (pendingChanges.GetUpperBound(0)>-1)
ChangeSetNumber = workspace.CheckIn(pendingChanges, filename);
I can see from the intelisense that I can specify checkinoptions as a parameter of the CheckIn method, I just cannot find what I need to put in to have it always check in and ignore any conflict I might come up with.
Thanks in advance.
EDIT: I found a command TF RESOLVE "item" /auto:AcceptYours /recursive So I guess my revised question would be is there a programming equivalent to the /auto:AcceptYours switch?
NecroEDIT: process the conflicts before doing the checkin
Conflict[] conflicts = workspace.QueryConflicts(new string[] { TFSProject }, true);
foreach (Conflict conflict in conflicts)
{
conflict.Resolution = Resolution.AcceptTheirs;
workspace.ResolveConflict(conflict);
}
Checkins are atomic - either they all succeed or they all fail. If there are any conflicts that need to be resolved before the check in, the check in operation will throw an exception. (Documentation)
You have to evaluate checkin for conflicts and then resolve the CheckinConflicts by Workspace.ResolveConflict Method.
ResolveConflict expects CheckinConflict, and result of the EvaluateCheckin (which is CheckinEvaluationResult) includes CheckinConflicts.
This page may help.
Note: checkinoptions is not related with what you are asking.
Hope this helps.