Skip to content

Commit

Permalink
fixed Accuweather | Met norway
Browse files Browse the repository at this point in the history
  • Loading branch information
PranshulGG committed Nov 19, 2024
1 parent 174f0ee commit 961e972
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ android {
applicationId "com.example.weathermaster"
minSdk 22
targetSdk 33
versionCode 73
versionName "1.8.1 (W)"
versionCode 74
versionName "1.8.2 (W)"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}


buildTypes {
release {
minifyEnabled false
Expand Down
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 73,
"versionName": "1.8.1 (W)",
"versionCode": 74,
"versionName": "1.8.2 (W)",
"outputFile": "app-release.apk"
}
],
Expand Down
36 changes: 30 additions & 6 deletions app/src/main/assets/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,20 @@ function loadSavedLocations() {


} else if(localStorage.getItem('selectedMainWeatherProvider') === 'Met norway' && !JSON.parse(localStorage.getItem(`WeatherDataMetNorway_${location.locationName}`))){

const lastCallTimeKey = `DecodeWeatherLastCallMet_${location.locationName}`;
const currentTime = Date.now();
const lastCallTime = localStorage.getItem(lastCallTimeKey);

const timeLimit = 5 * 60 * 1000;

if (!lastCallTime || currentTime - lastCallTime > timeLimit) {
DecodeWeather(savedLocationItemLat, savedLocationItemLon, location.locationName);
savedLocationsHolder.innerHTML = ''
setTimeout(() => {
loadSavedLocations()
}, 1000)
localStorage.setItem(lastCallTimeKey, currentTime);
}
}
else if (localStorage.getItem('ApiForAccu') && localStorage.getItem('selectedMainWeatherProvider') === 'Accuweather' && JSON.parse(localStorage.getItem(`WeatherDataAccuCurrent_${location.locationName}`))) {
const data = JSON.parse(localStorage.getItem(`WeatherDataAccuCurrent_${location.locationName}`));
Expand All @@ -429,9 +442,10 @@ function loadSavedLocations() {

if (!lastCallTime || currentTime - lastCallTime > timeLimit) {
DecodeWeather(savedLocationItemLat, savedLocationItemLon, location.locationName);
savedLocationsHolder.innerHTML = ''
setTimeout(() => {
loadSavedLocations()
}, 200)
}, 1000)
localStorage.setItem(lastCallTimeKey, currentTime);
}

Expand Down Expand Up @@ -538,7 +552,7 @@ function loadSavedLocations() {
const MoreDetailsData = JSON.parse(localStorage.getItem(`MoreDetailsData_${location.locationName}`));
const AstronomyData = JSON.parse(localStorage.getItem(`AstronomyData_${location.locationName}`))
const renderFromSavedDataMetTimstamp = localStorage.getItem(`WeatherDataMetNorwayTimeStamp_${location.locationName}`)
const SavedalertData = JSON.parse(localStorage.getItem(`AlertData_${location.locationName}`))
const SavedalertData = JSON.parse(localStorage.getItem(`AlertData_${location.locationName}`))

if(SavedalertData){
FetchAlertRender(SavedalertData)
Expand All @@ -553,8 +567,14 @@ function loadSavedLocations() {
const currentData = renderFromSavedDataMet.properties.timeseries[0];
const hourlyData = renderFromSavedDataMet.properties.timeseries.slice(0, 24);

renderCurrentDataMetNorway(currentData, savedLocationItemLat, savedLocationItemLon);
renderHourlyDataMetNorway(hourlyData);

if(renderFromSavedDataMet){
renderCurrentDataMetNorway(currentData, savedLocationItemLat, savedLocationItemLon);
renderHourlyDataMetNorway(hourlyData);
} else{
DecodeWeather(savedLocationItemLat, savedLocationItemLon, location.locationName);
}

createHourlyDataCount(renderFromSavedData)

CurrentWeather(renderFromSavedData.current, renderFromSavedData.daily.sunrise[0], renderFromSavedData.daily.sunset[0])
Expand Down Expand Up @@ -619,8 +639,12 @@ function loadSavedLocations() {

astronomyDataRender(AstronomyData)
MoreDetailsRender(MoreDetailsData)
if(data){
DisplayCurrentAccuweatherData(data, savedLocationItemLat, savedLocationItemLon)
DisplayHourlyAccuweatherData(dataHourly)
} else{
DecodeWeather(savedLocationItemLat, savedLocationItemLon, location.locationName);
}

const AirQuailityData = JSON.parse(localStorage.getItem(`AirQuality_${location.locationName}`));

Expand Down Expand Up @@ -985,7 +1009,7 @@ checkNoInternet();

document.addEventListener('DOMContentLoaded', async function() {

const currentVersion = 'v1.8.1';
const currentVersion = 'v1.8.2';
const githubRepo = 'PranshulGG/WeatherMaster';
const releasesUrl = `https://api.github.com/repos/${githubRepo}/releases/latest`;

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/assets/pages/AboutPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
<div class="app_label_about">
<p>Weather <br>Master</p>

<span>1.8.1 (W)</span>
<span>1.8.2 (W)</span>
</div>

<div class="app_icon_holder_about">
Expand Down Expand Up @@ -355,7 +355,7 @@


document.getElementById('checkUpdatesBtn').addEventListener('click', async function () {
const currentVersion = 'v1.8.1';
const currentVersion = 'v1.8.2';
const githubRepo = 'PranshulGG/WeatherMaster';
const releasesUrl = `https://api.github.com/repos/${githubRepo}/releases/latest`;

Expand Down

0 comments on commit 961e972

Please sign in to comment.