Skip to content

Commit

Permalink
[desktop]: Remove nuid dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagohm committed Oct 27, 2024
1 parent b88516f commit 76a476c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
10 changes: 0 additions & 10 deletions desktop/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"hotkeys-js": "3.13.7",
"leaflet": "1.9.4",
"ngx-moveable": "0.50.0",
"nuid": "2.0.1-2",
"panzoom": "9.4.3",
"primeflex": "3.3.1",
"primeicons": "7.0.0",
Expand Down
4 changes: 2 additions & 2 deletions desktop/src/app/image/image.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { AfterViewInit, Component, ElementRef, HostListener, NgZone, OnDestroy,
import { ActivatedRoute } from '@angular/router'
import hotkeys from 'hotkeys-js'
import { NgxLegacyMoveableComponent, OnDrag, OnResize, OnRotate } from 'ngx-moveable'
import { nuid } from 'nuid'
import createPanZoom from 'panzoom'
import { ContextMenu } from 'primeng/contextmenu'
import { DeviceListMenuComponent } from '../../shared/components/device-list-menu/device-list-menu.component'
Expand Down Expand Up @@ -52,6 +51,7 @@ import { Mount } from '../../shared/types/mount.types'
import { PlateSolverRequest } from '../../shared/types/platesolver.types'
import { StarDetectionRequest } from '../../shared/types/stardetector.types'
import { CoordinateInterpolator } from '../../shared/utils/coordinate-interpolation'
import { uid } from '../../shared/utils/random'
import { AppComponent } from '../app.component'

@Component({
Expand Down Expand Up @@ -530,7 +530,7 @@ export class ImageComponent implements AfterViewInit, OnDestroy {

this.loadPreference()

this.solver.key = nuid.next()
this.solver.key = uid()
}

async ngAfterViewInit() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { nuid } from 'nuid'
import { Observable } from 'rxjs'
import { uid } from '../utils/random'

@Injectable({ providedIn: 'root' })
export class IdempotencyKeyInterceptor implements HttpInterceptor {
static readonly HEADER_KEY = 'X-Idempotency-Key'

intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
const idempotencyKey = nuid.next()
const idempotencyKey = uid()

req = req.clone({
headers: req.headers.set(IdempotencyKeyInterceptor.HEADER_KEY, idempotencyKey),
Expand Down
11 changes: 11 additions & 0 deletions desktop/src/shared/utils/random.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789'

export function uid(length: number = 12) {
const value = new Array<number>(length)

for (let i = 0; i < length; i++) {
value[i] = chars[Math.floor(Math.random() * 36)].codePointAt(0)!
}

return String.fromCharCode.apply(null, value)
}

0 comments on commit 76a476c

Please sign in to comment.