Compare commits
4 Commits
a53.2
...
new_follow
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29f83814ee | ||
|
|
744be24410 | ||
|
|
633e39ce5d | ||
|
|
2e6eb25e68 |
@@ -1,4 +1,4 @@
|
|||||||
const DB_VERSION = 8;
|
const DB_VERSION = 9;
|
||||||
|
|
||||||
const USER_ID = localStorage.getItem('auth_user');
|
const USER_ID = localStorage.getItem('auth_user');
|
||||||
const USER_NAME = localStorage.getItem('auth_username');
|
const USER_NAME = localStorage.getItem('auth_username');
|
||||||
@@ -619,7 +619,7 @@ function sync() {
|
|||||||
localTimes[entry['table']] = entry['time'];
|
localTimes[entry['table']] = entry['time'];
|
||||||
});
|
});
|
||||||
|
|
||||||
syncInProgress = 13;
|
syncInProgress = 14;
|
||||||
var syncOkay = true;
|
var syncOkay = true;
|
||||||
log("[db] Sync Start");
|
log("[db] Sync Start");
|
||||||
$('#i-sync').addClass('fa-spin');
|
$('#i-sync').addClass('fa-spin');
|
||||||
@@ -1008,8 +1008,35 @@ function sync() {
|
|||||||
syncInProgress --;
|
syncInProgress --;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FOLLOWS
|
||||||
|
getJSON(QUERY_URL + 'get_follows', function (code, data) {
|
||||||
|
if (code == 200) {
|
||||||
|
var os = db.transaction('follows', 'readwrite').objectStore('follows');
|
||||||
|
data.data.forEach(function (entry) {
|
||||||
|
os.put(entry);
|
||||||
|
});
|
||||||
|
os.openCursor().onsuccess = function (event) {
|
||||||
|
var cursor = event.target.result;
|
||||||
|
if (cursor) {
|
||||||
|
if (!data.keys.includes(parseInt(cursor.key))) {
|
||||||
|
os.delete(cursor.key);
|
||||||
|
}
|
||||||
|
cursor.continue();
|
||||||
} else {
|
} else {
|
||||||
syncInProgress -= 3;
|
syncInProgress --;
|
||||||
|
log('[db] follows synced, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
log("[db] follows: Something went wrong (HTTP " + code + ")");
|
||||||
|
syncOkay = false;
|
||||||
|
syncInProgress --;
|
||||||
|
log('[db] follows failed, remaining:', syncInProgress);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
syncInProgress -= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NEWS
|
// NEWS
|
||||||
@@ -1236,6 +1263,11 @@ function initDatabase() {
|
|||||||
var osRankings = db.createObjectStore('rankings', { keyPath: 'id' });
|
var osRankings = db.createObjectStore('rankings', { keyPath: 'id' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((oldVersion < 9) && (newVersion >= 9)) {
|
||||||
|
log('[db] to version 9');
|
||||||
|
var osFollows = db.createObjectStore('follows', { keyPath: 'id' });
|
||||||
|
}
|
||||||
|
|
||||||
// Force resync after db update
|
// Force resync after db update
|
||||||
if (oldVersion >= 1) {
|
if (oldVersion >= 1) {
|
||||||
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
var osUpdateTimes = upgradeTransaction.objectStore('update_times');
|
||||||
|
|||||||
@@ -85,12 +85,10 @@ var siteScript = async function() {
|
|||||||
var user = await dbGetData('users', localStorage.getItem('auth_user'));
|
var user = await dbGetData('users', localStorage.getItem('auth_user'));
|
||||||
|
|
||||||
// Favorites
|
// Favorites
|
||||||
|
var follows = await dbGetData('follows');
|
||||||
var watched = [];
|
var watched = [];
|
||||||
for (var i = 1; i <= 5; i ++) {
|
for (var i in follows) {
|
||||||
sailor_id = user['sailor' + i];
|
watched.push(await dbGetData('sailors', follows[i].sailor));
|
||||||
if (sailor_id != null) {
|
|
||||||
watched.push(await dbGetData('sailors', sailor_id));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (watched.length > 0) {
|
if (watched.length > 0) {
|
||||||
var year = (new Date()).getFullYear();
|
var year = (new Date()).getFullYear();
|
||||||
|
|||||||
@@ -194,12 +194,10 @@ var siteScript = async function() {
|
|||||||
|
|
||||||
if (isLoggedIn()) {
|
if (isLoggedIn()) {
|
||||||
var user = await dbGetData('users', USER_ID);
|
var user = await dbGetData('users', USER_ID);
|
||||||
|
var follows = await dbGetData('follows');
|
||||||
followedSailors = [];
|
followedSailors = [];
|
||||||
for (var i = 1; i <= 5; i ++) {
|
for (var i in follows) {
|
||||||
sailor_id = user['sailor' + i];
|
followedSailors.push(await dbGetData('sailors', follows[i].sailor));
|
||||||
if (sailor_id != null) {
|
|
||||||
followedSailors.push(await dbGetData('sailors', sailor_id));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
define('PWA_VERSION', '1.12.1h7');
|
define('PWA_VERSION', '1.12.1h8');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user