chore: enable strict mode (#1569)

* chore: enable strict mode

* refactor: remove sync data access from PatchDbService

* launchable even when no LAN url

Co-authored-by: Matt Hill <matthewonthemoon@gmail.com>
This commit is contained in:
Alex Inkin
2022-07-22 18:51:08 +03:00
committed by GitHub
parent 9a01a0df8e
commit 7b8a0eadf3
130 changed files with 1130 additions and 1045 deletions

View File

@@ -0,0 +1,9 @@
import { first } from 'rxjs/operators'
import { PatchDbService } from 'src/app/services/patch-db/patch-db.service'
import { UIMarketplaceData } from 'src/app/services/patch-db/data-model'
export function getMarketplace(
patch: PatchDbService,
): Promise<UIMarketplaceData> {
return patch.watch$('ui', 'marketplace').pipe(first()).toPromise()
}

View File

@@ -0,0 +1,16 @@
import { first } from 'rxjs/operators'
import { PatchDbService } from 'src/app/services/patch-db/patch-db.service'
import { PackageDataEntry } from 'src/app/services/patch-db/data-model'
export function getPackage(
patch: PatchDbService,
id: string,
): Promise<PackageDataEntry> {
return patch.watch$('package-data', id).pipe(first()).toPromise()
}
export function getAllPackages(
patch: PatchDbService,
): Promise<Record<string, PackageDataEntry>> {
return patch.watch$('package-data').pipe(first()).toPromise()
}

View File

@@ -0,0 +1,7 @@
import { first } from 'rxjs/operators'
import { PatchDbService } from 'src/app/services/patch-db/patch-db.service'
import { ServerInfo } from 'src/app/services/patch-db/data-model'
export function getServerInfo(patch: PatchDbService): Promise<ServerInfo> {
return patch.watch$('server-info').pipe(first()).toPromise()
}

View File

@@ -2,24 +2,20 @@ export async function copyToClipboard(str: string): Promise<boolean> {
if (window.isSecureContext) {
return navigator.clipboard
.writeText(str)
.then(() => {
return true
})
.catch(err => {
return false
})
} else {
const el = document.createElement('textarea')
el.value = str
el.setAttribute('readonly', '')
el.style.position = 'absolute'
el.style.left = '-9999px'
document.body.appendChild(el)
el.select()
const copy = document.execCommand('copy')
document.body.removeChild(el)
return copy
.then(() => true)
.catch(() => false)
}
const el = document.createElement('textarea')
el.value = str
el.setAttribute('readonly', '')
el.style.position = 'absolute'
el.style.left = '-9999px'
document.body.appendChild(el)
el.select()
const copy = document.execCommand('copy')
document.body.removeChild(el)
return copy
}
export function strip(html: string) {