mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-23 18:01:08 +01:00
Better tauri listeners and stuff
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
import type { KeyValue } from './models';
|
||||
|
||||
const DEFAULT_NAMESPACE = 'app';
|
||||
export const NAMESPACE_GLOBAL = 'global';
|
||||
export const NAMESPACE_NO_SYNC = 'no_sync';
|
||||
|
||||
export async function setKeyValue<T>({
|
||||
namespace = DEFAULT_NAMESPACE,
|
||||
namespace = NAMESPACE_GLOBAL,
|
||||
key,
|
||||
value,
|
||||
}: {
|
||||
@@ -20,7 +21,7 @@ export async function setKeyValue<T>({
|
||||
}
|
||||
|
||||
export async function getKeyValue<T>({
|
||||
namespace = DEFAULT_NAMESPACE,
|
||||
namespace = NAMESPACE_GLOBAL,
|
||||
key,
|
||||
fallback,
|
||||
}: {
|
||||
|
||||
@@ -2,7 +2,6 @@ export interface BaseModel {
|
||||
readonly id: string;
|
||||
readonly createdAt: string;
|
||||
readonly updatedAt: string;
|
||||
updatedBy: string;
|
||||
}
|
||||
|
||||
export interface Workspace extends BaseModel {
|
||||
@@ -26,6 +25,18 @@ export const AUTH_TYPE_NONE = null;
|
||||
export const AUTH_TYPE_BASIC = 'basic';
|
||||
export const AUTH_TYPE_BEARER = 'bearer';
|
||||
|
||||
export type Model = Workspace | HttpRequest | HttpResponse | KeyValue;
|
||||
|
||||
export function modelsEq(a: Model, b: Model) {
|
||||
if (a.model === 'key_value' && b.model === 'key_value') {
|
||||
return a.key === b.key && a.namespace === b.namespace;
|
||||
}
|
||||
if ('id' in a && 'id' in b) {
|
||||
return a.id === b.id;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export interface HttpRequest extends BaseModel {
|
||||
readonly workspaceId: string;
|
||||
readonly model: 'http_request';
|
||||
|
||||
Reference in New Issue
Block a user