mirror of
https://github.com/ivabus/gui
synced 2025-06-07 07:40:27 +03:00
cleanup and lint
This commit is contained in:
parent
3a00459b15
commit
721c278fd4
7 changed files with 13 additions and 33 deletions
|
@ -1,5 +0,0 @@
|
|||
#[tauri::command]
|
||||
pub fn auth(package: String) {
|
||||
println!("installing: {}", package);
|
||||
|
||||
}
|
|
@ -1,2 +1 @@
|
|||
pub mod packages;
|
||||
pub mod auth;
|
||||
pub mod packages;
|
|
@ -1,9 +1,9 @@
|
|||
<script lang="ts">
|
||||
import { open } from '@tauri-apps/api/shell';
|
||||
import { authStore } from '$libs/stores';
|
||||
import type { User } from '@tea/ui/types';
|
||||
import type { Developer } from '@tea/ui/types';
|
||||
|
||||
let user: User | null = null;
|
||||
let user: Developer | null = null;
|
||||
const deviceId = authStore.deviceIdStore;
|
||||
|
||||
const openGithub = () => {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<script lang="ts">
|
||||
import '$appcss';
|
||||
import { authStore } from '$libs/stores';
|
||||
import type { User } from '@tea/ui/types';
|
||||
import type { Developer } from '@tea/ui/types';
|
||||
|
||||
let user: User | null = null;
|
||||
let user: Developer | null = null;
|
||||
const authPage = `http://localhost:3000/v1/auth/user?device_id=${authStore.deviceId}`; // https://api.tea.xyz/v1/auth/user?device_id=device_id
|
||||
|
||||
authStore.subscribe((u) => (user = u));
|
||||
|
|
|
@ -15,7 +15,7 @@ import { getClient } from '@tauri-apps/api/http';
|
|||
import { Command } from '@tauri-apps/api/shell';
|
||||
import { readDir, BaseDirectory } from '@tauri-apps/api/fs';
|
||||
|
||||
import type { Package, Review, AirtablePost, User, Bottle } from '@tea/ui/types';
|
||||
import type { Package, Review, AirtablePost, Developer, Bottle } from '@tea/ui/types';
|
||||
import type { GUIPackage, Course, Category, AuthStatus } from '../types';
|
||||
|
||||
import * as mock from './mock';
|
||||
|
@ -171,7 +171,7 @@ export async function getCategorizedPackages(): Promise<Category[]> {
|
|||
|
||||
type DeviceAuth = {
|
||||
status: AuthStatus;
|
||||
user: User;
|
||||
user: Developer;
|
||||
key: string;
|
||||
};
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@ import { writable } from 'svelte/store';
|
|||
import { BaseDirectory, createDir, readTextFile, writeTextFile } from '@tauri-apps/api/fs';
|
||||
import { join } from '@tauri-apps/api/path';
|
||||
import { getDeviceAuth, registerDevice } from '@api';
|
||||
import type { User } from '@tea/ui/types';
|
||||
import type { Developer } from '@tea/ui/types';
|
||||
|
||||
const basePath = '.tea/tea.xyz/gui';
|
||||
interface Session {
|
||||
device_id?: string;
|
||||
key?: string;
|
||||
user?: any;
|
||||
user?: Developer;
|
||||
}
|
||||
|
||||
export default function initAuthStore() {
|
||||
|
@ -69,8 +69,8 @@ export default function initAuthStore() {
|
|||
return {
|
||||
deviceId,
|
||||
deviceIdStore,
|
||||
subscribe: (cb: (u: User) => void) => {
|
||||
return session.subscribe((v) => v && cb(v.user));
|
||||
subscribe: (cb: (u: Developer) => void) => {
|
||||
return session.subscribe((v) => v?.user && cb(v.user));
|
||||
},
|
||||
pollSession
|
||||
};
|
||||
|
@ -96,7 +96,7 @@ const getLocalSessionData = async (): Promise<Session | void> => {
|
|||
data = JSON.parse(encryptedData || '{}');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
const deviceId = await getDeviceId();
|
||||
const deviceId = await registerDevice();
|
||||
data = {
|
||||
device_id: deviceId
|
||||
};
|
||||
|
@ -113,17 +113,3 @@ const saveLocallySessionData = async (data: Session) => {
|
|||
dir: BaseDirectory.Home
|
||||
});
|
||||
};
|
||||
|
||||
const getDeviceId = async (): Promise<string> => {
|
||||
const hasLocal = false;
|
||||
// get from local data
|
||||
// else get from server
|
||||
// GET /v1/auth/registerDevice
|
||||
let deviceId = '';
|
||||
if (hasLocal) {
|
||||
} else {
|
||||
deviceId = await registerDevice();
|
||||
}
|
||||
console.log('deviceId:', deviceId);
|
||||
return deviceId;
|
||||
};
|
||||
|
|
|
@ -35,7 +35,7 @@ export type AirtablePost = {
|
|||
tags: string[];
|
||||
};
|
||||
|
||||
export type User = {
|
||||
export type Developer = {
|
||||
developer_id: string;
|
||||
avatar_url?: string;
|
||||
name: string;
|
||||
|
|
Loading…
Reference in a new issue