mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-09-29 18:28:06 +03:00
add idm/access client-side handling
This commit is contained in:
@@ -32,7 +32,8 @@ import {ICCard} from "../components/ICCard";
|
||||
import RealmContext from "../models/RealmContext";
|
||||
import {AMServer} from "../models/AMServer";
|
||||
import {AMCard} from "../models/AMCard";
|
||||
import ObjectId = BSON.ObjectId;
|
||||
|
||||
import {icCard0008Number} from "../lib/iccard";
|
||||
import {
|
||||
AMServerConnectionInfo,
|
||||
AMServerInstanceMetrics,
|
||||
@@ -41,6 +42,8 @@ import {
|
||||
performCardIn
|
||||
} from "amnet-shared";
|
||||
|
||||
import ObjectId = BSON.ObjectId;
|
||||
|
||||
const {useRealm, useQuery, useObject} = RealmContext;
|
||||
|
||||
export default function ServerCardIn({route, navigation}) {
|
||||
@@ -147,8 +150,10 @@ export default function ServerCardIn({route, navigation}) {
|
||||
const cardInCallback = useCallback(() => {
|
||||
setCardInCompleted(false);
|
||||
|
||||
const cardId = selectedCard.physicalCardData && server.preferredCardIdFormat === "idm" ? icCard0008Number(selectedCard.physicalCardData.cardIDm) : selectedCard.code;
|
||||
const abortController = new AbortController();
|
||||
performCardIn(server, {cardId: selectedCard.code}, abortController.signal).then(async r => {
|
||||
|
||||
performCardIn(server, {cardId}, abortController.signal).then(async r => {
|
||||
const now = new Date();
|
||||
realm.write(() => {
|
||||
server.lastUsed = now;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {Realm} from 'realm';
|
||||
import {AMServerConnectionInfo, AMServerMetadata} from "amnet-shared";
|
||||
import {AMServerConnectionInfo, AMServerMetadata, AMServerPhysicalCardPreferences} from "amnet-shared";
|
||||
|
||||
export class AMServer extends Realm.Object<AMServer> implements AMServerConnectionInfo, AMServerMetadata {
|
||||
export class AMServer extends Realm.Object<AMServer> implements AMServerConnectionInfo, AMServerMetadata, AMServerPhysicalCardPreferences {
|
||||
_id!: Realm.BSON.ObjectId;
|
||||
|
||||
apiVersion: number;
|
||||
@@ -12,7 +12,9 @@ export class AMServer extends Realm.Object<AMServer> implements AMServerConnecti
|
||||
|
||||
lastUsed: Date;
|
||||
createdAt: Date;
|
||||
|
||||
|
||||
preferredCardIdFormat?: "idm" | "access" | null;
|
||||
|
||||
get shareUrl() {
|
||||
return `http://card.ppc.moe/#/servers/add?address=${encodeURIComponent(this.serverAddress)}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user