Could somebody please help me with my Aura code? It works fine and does exactly what I need it to do but the only issue I'm having is, once the aura component loads, the lightning:spinner keeps randomly showing about 3 times and then finally goes away. Am I perhaps implementing the spinner in the wrong fashion? or is my recordUpdated() maybe not correctly implemented? Thanks for any help you can provide!
ErroHandler.cmp
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId">
<aura:attribute name="record" type="Object"/>
<aura:attribute name="RecordSimp" type="Object"/>
<aura:attribute name="recordError" type="String"/>
<aura:attribute name="recordSuccess" type="String"/>
<aura:attribute name="showSpinner" type="boolean" default="false"/>
<aura:handler event="aura:waiting" action="{!c.handleShowSpinner}"/>
<aura:handler event="aura:doneWaiting" action="{!c.handleHideSpinner}"/>
<force:recordData aura:id="RDLoader"
fields="ErrorMessage__c,ErrorMessagePersistent__c"
recordId="{!v.recordId}"
targetRecord="{!v.record}"
targetFields ="{!v.RecordSimp}"
targetError="{!v.recordError}"
recordUpdated="{!c.recordUpdated}"
mode="EDIT"/>
<div class="Error Detail">
<lightning:card iconName="utility:error" variant="error" title="Error!">
<aura:if isTrue="{!v.showSpinner}">
<lightning:spinner variant="brand" size ="medium"/>
</aura:if>
<div class="slds-p-around_medium">
<p class="slds-text-heading--small">
<lightning:formattedText value="{!v.RecordSimp.CaseErrorMessage__c}"/>
<br></br><br></br>
<lightning:formattedText value="{!v.RecordSimp.ErrorMessagePersistent__c}"/>
</p>
<br></br>
<lightning:button aura:id="submitbuttonid" variant="brand" label="Clear Message? Click here" onclick="{!c.handleClick}" disabled = "false"/>
</div>
</lightning:card>
</div>
</aura:component>
ErrorHandlerController.js
({
recordUpdated: function(component, event, helper){
var eventParams = event.getParams();
if(eventParams.changeType === "LOADED"){
var record = component.get('v.RecordSimp');
record.ErrorMessage__c = '';
record.ErrorMessagePersistent__c = '0 errors';
}
},
//event="aura:waiting"
handleShowSpinner: function(component, event, helper) {
component.set("v.showSpinner", true);
},
//event="aura:doneWaiting"
handleHideSpinner : function(component,event,helper){
component.set("v.showSpinner", false);
},
handleClick: function(component, event, helper)
{
let button = component.find('submitbuttonid');
button.set('v.disabled',true);
component.find("RDLoader").saveRecord($A.getCallback(function(saveResult){
if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Success",
"message": "Thank you!",
"type": "success"
});
}else {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Error",
"message": "Please try again.",
"type": "error"
});
}
toastEvent.fire();
}));
}
})