Skip to content

Commit

Permalink
Implement minor improvements (no behavior change)
Browse files Browse the repository at this point in the history
  • Loading branch information
D13ce committed Oct 25, 2023
1 parent 3a2a93c commit 2f214cd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app/pages/dev/dev.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class DevPage extends Tab3Page implements OnInit {
})
} else {
Toast.show({
text: 'Token refreshed failed :(',
text: 'Token refresh failed :(',
})
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/app/utils/CacheModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import { StorageService, replacer } from '../services/storage.service'
import { Validator } from './ValidatorUtils'

const LOGTAG = '[CacheModule]'

interface CachedData {
maxStaleTime: number
time: number
Expand Down Expand Up @@ -67,7 +69,7 @@ export class CacheModule {
// dont load hardStorage if last time it was written too is more than 6 hours ago
const lastWrite = (await this.hardStorage.getObject('cachemodule2_' + this.keyPrefix + '_lastWrite')) as number
if (lastWrite && lastWrite + 6 * 60 * 60 * 1000 < this.getTimestamp()) {
console.log('[CacheModule] hardStorage too old, ignoring')
console.log(LOGTAG + ' hardStorage too old, ignoring')
} else {
const result = (await this.hardStorage.getObject('cachemodule2_' + this.keyPrefix)) as Map<string, CachedData>
if (result) {
Expand All @@ -84,9 +86,9 @@ export class CacheModule {
const size = new TextEncoder().encode(JSON.stringify(this.cache, replacer)).length
kiloBytes = Math.round((size * 100) / 1024) / 100
}
console.log('[CacheModule] initialized with ', kiloBytes == null ? '(unknown size)' : '(' + kiloBytes + ' KiB)', this.cache)
console.log(LOGTAG + ' initialized with ', kiloBytes == null ? '(unknown size)' : '(' + kiloBytes + ' KiB)', this.cache)
if (kiloBytes && kiloBytes > this.hardStorageSizeLimit) {
console.warn('[CacheModule] storage cap exceeded (1 MB), clearing cache')
console.warn(LOGTAG + ' storage cap exceeded (1 MB), clearing cache')
await this.clearHardCache()
}
} catch (e) {
Expand Down Expand Up @@ -187,7 +189,7 @@ export class CacheModule {

protected cacheMultiple(prefix: string, data: Validator[]) {
if (!data || data.length <= 0) {
console.log('[CacheModule] ignore cache attempt of empty data set', data)
console.log(LOGTAG + ' ignore cache attempt of empty data set', data)
return
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/utils/ClientUpdateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export default class ClientUpdateUtils {
for (let i = 0; i < results.length; i++) {
if (results[i] && !this.contains(results[i])) {
changeFound = true
break
}
}

Expand All @@ -164,7 +165,7 @@ export default class ClientUpdateUtils {
}
}
} catch (error) {
console.error('An error occurred:', error)
console.error('An error occurred while checking for all updates:', error)
}
this.locked = false
}
Expand Down

0 comments on commit 2f214cd

Please sign in to comment.