From 01afdc410ec651058572ae638f35ddb593fcc7d6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 13 Nov 2021 19:10:08 +0900 Subject: [PATCH 01/29] Update .eslintrc.js --- packages/backend/.eslintrc.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/backend/.eslintrc.js b/packages/backend/.eslintrc.js index 5ce38b9cc..0978f8ab4 100644 --- a/packages/backend/.eslintrc.js +++ b/packages/backend/.eslintrc.js @@ -31,6 +31,10 @@ module.exports = { 'before': true, 'after': true, }], + 'key-spacing': ['error', { + 'beforeColon': false, + 'afterColon': true, + }], /* TODO: path aliasを使わないとwarnする 'no-restricted-imports': ['warn', { 'patterns': [ @@ -47,10 +51,15 @@ module.exports = { 'no-async-promise-executor': ['off'], 'no-useless-escape': ['off'], 'no-multi-spaces': ['warn'], + 'no-multiple-empty-lines': ['error', { 'max': 1 }], 'no-control-regex': ['warn'], 'no-empty': ['warn'], 'no-inner-declarations': ['off'], 'no-sparse-arrays': ['off'], + 'nonblock-statement-body-position': ['error', 'beside'], + 'object-curly-spacing': ['error', 'always'], + 'space-infix-ops': ['error'], + 'space-before-blocks': ['error', 'always'], '@typescript-eslint/no-var-requires': ['warn'], '@typescript-eslint/no-inferrable-types': ['warn'], '@typescript-eslint/no-empty-function': ['off'], From 8b7f5be878bd86d34dde7790346df1835cdc6756 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 13 Nov 2021 19:10:14 +0900 Subject: [PATCH 02/29] fix for lint --- packages/backend/src/games/reversi/core.ts | 8 +- packages/backend/src/misc/populate-emojis.ts | 8 +- packages/backend/src/misc/reaction-lib.ts | 1 + .../src/remote/activitypub/ap-request.ts | 6 +- .../src/remote/activitypub/misc/contexts.ts | 1008 ++++++++--------- .../src/remote/activitypub/models/person.ts | 37 +- .../remote/activitypub/renderer/question.ts | 2 +- packages/backend/src/server/api/2fa.ts | 60 +- .../src/server/api/endpoints/notes/create.ts | 3 +- .../server/api/endpoints/notes/polls/vote.ts | 3 +- .../backend/src/server/api/service/github.ts | 11 +- packages/backend/src/server/well-known.ts | 8 +- 12 files changed, 581 insertions(+), 574 deletions(-) diff --git a/packages/backend/src/games/reversi/core.ts b/packages/backend/src/games/reversi/core.ts index 9bfce9834..fc7f006ce 100644 --- a/packages/backend/src/games/reversi/core.ts +++ b/packages/backend/src/games/reversi/core.ts @@ -82,8 +82,7 @@ export default class Reversi { //#endregion // ゲームが始まった時点で片方の色の石しかないか、始まった時点で勝敗が決定するようなマップの場合がある - if (!this.canPutSomewhere(BLACK)) - this.turn = this.canPutSomewhere(WHITE) ? WHITE : null; + if (!this.canPutSomewhere(BLACK)) this.turn = this.canPutSomewhere(WHITE) ? WHITE : null; } /** @@ -226,11 +225,12 @@ export default class Reversi { // 座標が指し示す位置がボード外に出たとき if (this.opts.loopedBoard && this.transformXyToPos( (x = ((x % this.mapWidth) + this.mapWidth) % this.mapWidth), - (y = ((y % this.mapHeight) + this.mapHeight) % this.mapHeight)) === initPos) + (y = ((y % this.mapHeight) + this.mapHeight) % this.mapHeight)) === initPos) { // 盤面の境界でループし、自分が石を置く位置に戻ってきたとき、挟めるようにしている (ref: Test4のマップ) return found; - else if (x === -1 || y === -1 || x === this.mapWidth || y === this.mapHeight) + } else if (x === -1 || y === -1 || x === this.mapWidth || y === this.mapHeight) { return []; // 挟めないことが確定 (盤面外に到達) + } const pos = this.transformXyToPos(x, y); if (this.mapDataGet(pos) === 'null') return []; // 挟めないことが確定 (配置不可能なマスに到達) diff --git a/packages/backend/src/misc/populate-emojis.ts b/packages/backend/src/misc/populate-emojis.ts index f0a8bde31..b021ec46e 100644 --- a/packages/backend/src/misc/populate-emojis.ts +++ b/packages/backend/src/misc/populate-emojis.ts @@ -54,7 +54,7 @@ export async function populateEmoji(emojiName: string, noteUserHost: string | nu const queryOrNull = async () => (await Emojis.findOne({ name, - host + host, })) || null; const emoji = await cache.fetch(`${name} ${host}`, queryOrNull); @@ -62,7 +62,7 @@ export async function populateEmoji(emojiName: string, noteUserHost: string | nu if (emoji == null) return null; const isLocal = emoji.host == null; - const url = isLocal ? emoji.url : `${config.url}/proxy/image.png?${query({url: emoji.url})}`; + const url = isLocal ? emoji.url : `${config.url}/proxy/image.png?${query({ url: emoji.url })}`; return { name: emojiName, @@ -111,12 +111,12 @@ export async function prefetchEmojis(emojis: { name: string; host: string | null for (const host of hosts) { emojisQuery.push({ name: In(notCachedEmojis.filter(e => e.host === host).map(e => e.name)), - host: host + host: host, }); } const _emojis = emojisQuery.length > 0 ? await Emojis.find({ where: emojisQuery, - select: ['name', 'host', 'url'] + select: ['name', 'host', 'url'], }) : []; for (const emoji of _emojis) { cache.set(`${emoji.name} ${emoji.host}`, emoji); diff --git a/packages/backend/src/misc/reaction-lib.ts b/packages/backend/src/misc/reaction-lib.ts index 46dedfa24..e24f4a4fc 100644 --- a/packages/backend/src/misc/reaction-lib.ts +++ b/packages/backend/src/misc/reaction-lib.ts @@ -1,3 +1,4 @@ +/* eslint-disable key-spacing */ import { emojiRegex } from './emoji-regex'; import { fetchMeta } from './fetch-meta'; import { Emojis } from '@/models/index'; diff --git a/packages/backend/src/remote/activitypub/ap-request.ts b/packages/backend/src/remote/activitypub/ap-request.ts index 76a385714..c75f44f2e 100644 --- a/packages/backend/src/remote/activitypub/ap-request.ts +++ b/packages/backend/src/remote/activitypub/ap-request.ts @@ -19,7 +19,7 @@ export function createSignedPost(args: { key: PrivateKey, url: string, body: str const request: Request = { url: u.href, method: 'POST', - headers: objectAssignWithLcKey({ + headers: objectAssignWithLcKey({ 'Date': new Date().toUTCString(), 'Host': u.hostname, 'Content-Type': 'application/activity+json', @@ -43,7 +43,7 @@ export function createSignedGet(args: { key: PrivateKey, url: string, additional const request: Request = { url: u.href, method: 'GET', - headers: objectAssignWithLcKey({ + headers: objectAssignWithLcKey({ 'Accept': 'application/activity+json, application/ld+json', 'Date': new Date().toUTCString(), 'Host': new URL(args.url).hostname, @@ -66,7 +66,7 @@ function signToRequest(request: Request, key: PrivateKey, includeHeaders: string const signatureHeader = `keyId="${key.keyId}",algorithm="rsa-sha256",headers="${includeHeaders.join(' ')}",signature="${signature}"`; request.headers = objectAssignWithLcKey(request.headers, { - Signature: signatureHeader + Signature: signatureHeader, }); return { diff --git a/packages/backend/src/remote/activitypub/misc/contexts.ts b/packages/backend/src/remote/activitypub/misc/contexts.ts index 64d9da647..aee0d3629 100644 --- a/packages/backend/src/remote/activitypub/misc/contexts.ts +++ b/packages/backend/src/remote/activitypub/misc/contexts.ts @@ -1,526 +1,526 @@ /* eslint:disable:quotemark indent */ const id_v1 = { - "@context": { - "id": "@id", - "type": "@type", + '@context': { + 'id': '@id', + 'type': '@type', - "cred": "https://w3id.org/credentials#", - "dc": "http://purl.org/dc/terms/", - "identity": "https://w3id.org/identity#", - "perm": "https://w3id.org/permissions#", - "ps": "https://w3id.org/payswarm#", - "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", - "rdfs": "http://www.w3.org/2000/01/rdf-schema#", - "sec": "https://w3id.org/security#", - "schema": "http://schema.org/", - "xsd": "http://www.w3.org/2001/XMLSchema#", + 'cred': 'https://w3id.org/credentials#', + 'dc': 'http://purl.org/dc/terms/', + 'identity': 'https://w3id.org/identity#', + 'perm': 'https://w3id.org/permissions#', + 'ps': 'https://w3id.org/payswarm#', + 'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', + 'rdfs': 'http://www.w3.org/2000/01/rdf-schema#', + 'sec': 'https://w3id.org/security#', + 'schema': 'http://schema.org/', + 'xsd': 'http://www.w3.org/2001/XMLSchema#', - "Group": "https://www.w3.org/ns/activitystreams#Group", + 'Group': 'https://www.w3.org/ns/activitystreams#Group', - "claim": {"@id": "cred:claim", "@type": "@id"}, - "credential": {"@id": "cred:credential", "@type": "@id"}, - "issued": {"@id": "cred:issued", "@type": "xsd:dateTime"}, - "issuer": {"@id": "cred:issuer", "@type": "@id"}, - "recipient": {"@id": "cred:recipient", "@type": "@id"}, - "Credential": "cred:Credential", - "CryptographicKeyCredential": "cred:CryptographicKeyCredential", + 'claim': { '@id': 'cred:claim', '@type': '@id' }, + 'credential': { '@id': 'cred:credential', '@type': '@id' }, + 'issued': { '@id': 'cred:issued', '@type': 'xsd:dateTime' }, + 'issuer': { '@id': 'cred:issuer', '@type': '@id' }, + 'recipient': { '@id': 'cred:recipient', '@type': '@id' }, + 'Credential': 'cred:Credential', + 'CryptographicKeyCredential': 'cred:CryptographicKeyCredential', - "about": {"@id": "schema:about", "@type": "@id"}, - "address": {"@id": "schema:address", "@type": "@id"}, - "addressCountry": "schema:addressCountry", - "addressLocality": "schema:addressLocality", - "addressRegion": "schema:addressRegion", - "comment": "rdfs:comment", - "created": {"@id": "dc:created", "@type": "xsd:dateTime"}, - "creator": {"@id": "dc:creator", "@type": "@id"}, - "description": "schema:description", - "email": "schema:email", - "familyName": "schema:familyName", - "givenName": "schema:givenName", - "image": {"@id": "schema:image", "@type": "@id"}, - "label": "rdfs:label", - "name": "schema:name", - "postalCode": "schema:postalCode", - "streetAddress": "schema:streetAddress", - "title": "dc:title", - "url": {"@id": "schema:url", "@type": "@id"}, - "Person": "schema:Person", - "PostalAddress": "schema:PostalAddress", - "Organization": "schema:Organization", + 'about': { '@id': 'schema:about', '@type': '@id' }, + 'address': { '@id': 'schema:address', '@type': '@id' }, + 'addressCountry': 'schema:addressCountry', + 'addressLocality': 'schema:addressLocality', + 'addressRegion': 'schema:addressRegion', + 'comment': 'rdfs:comment', + 'created': { '@id': 'dc:created', '@type': 'xsd:dateTime' }, + 'creator': { '@id': 'dc:creator', '@type': '@id' }, + 'description': 'schema:description', + 'email': 'schema:email', + 'familyName': 'schema:familyName', + 'givenName': 'schema:givenName', + 'image': { '@id': 'schema:image', '@type': '@id' }, + 'label': 'rdfs:label', + 'name': 'schema:name', + 'postalCode': 'schema:postalCode', + 'streetAddress': 'schema:streetAddress', + 'title': 'dc:title', + 'url': { '@id': 'schema:url', '@type': '@id' }, + 'Person': 'schema:Person', + 'PostalAddress': 'schema:PostalAddress', + 'Organization': 'schema:Organization', - "identityService": {"@id": "identity:identityService", "@type": "@id"}, - "idp": {"@id": "identity:idp", "@type": "@id"}, - "Identity": "identity:Identity", + 'identityService': { '@id': 'identity:identityService', '@type': '@id' }, + 'idp': { '@id': 'identity:idp', '@type': '@id' }, + 'Identity': 'identity:Identity', - "paymentProcessor": "ps:processor", - "preferences": {"@id": "ps:preferences", "@type": "@vocab"}, + 'paymentProcessor': 'ps:processor', + 'preferences': { '@id': 'ps:preferences', '@type': '@vocab' }, - "cipherAlgorithm": "sec:cipherAlgorithm", - "cipherData": "sec:cipherData", - "cipherKey": "sec:cipherKey", - "digestAlgorithm": "sec:digestAlgorithm", - "digestValue": "sec:digestValue", - "domain": "sec:domain", - "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"}, - "initializationVector": "sec:initializationVector", - "member": {"@id": "schema:member", "@type": "@id"}, - "memberOf": {"@id": "schema:memberOf", "@type": "@id"}, - "nonce": "sec:nonce", - "normalizationAlgorithm": "sec:normalizationAlgorithm", - "owner": {"@id": "sec:owner", "@type": "@id"}, - "password": "sec:password", - "privateKey": {"@id": "sec:privateKey", "@type": "@id"}, - "privateKeyPem": "sec:privateKeyPem", - "publicKey": {"@id": "sec:publicKey", "@type": "@id"}, - "publicKeyPem": "sec:publicKeyPem", - "publicKeyService": {"@id": "sec:publicKeyService", "@type": "@id"}, - "revoked": {"@id": "sec:revoked", "@type": "xsd:dateTime"}, - "signature": "sec:signature", - "signatureAlgorithm": "sec:signatureAlgorithm", - "signatureValue": "sec:signatureValue", - "CryptographicKey": "sec:Key", - "EncryptedMessage": "sec:EncryptedMessage", - "GraphSignature2012": "sec:GraphSignature2012", - "LinkedDataSignature2015": "sec:LinkedDataSignature2015", + 'cipherAlgorithm': 'sec:cipherAlgorithm', + 'cipherData': 'sec:cipherData', + 'cipherKey': 'sec:cipherKey', + 'digestAlgorithm': 'sec:digestAlgorithm', + 'digestValue': 'sec:digestValue', + 'domain': 'sec:domain', + 'expires': { '@id': 'sec:expiration', '@type': 'xsd:dateTime' }, + 'initializationVector': 'sec:initializationVector', + 'member': { '@id': 'schema:member', '@type': '@id' }, + 'memberOf': { '@id': 'schema:memberOf', '@type': '@id' }, + 'nonce': 'sec:nonce', + 'normalizationAlgorithm': 'sec:normalizationAlgorithm', + 'owner': { '@id': 'sec:owner', '@type': '@id' }, + 'password': 'sec:password', + 'privateKey': { '@id': 'sec:privateKey', '@type': '@id' }, + 'privateKeyPem': 'sec:privateKeyPem', + 'publicKey': { '@id': 'sec:publicKey', '@type': '@id' }, + 'publicKeyPem': 'sec:publicKeyPem', + 'publicKeyService': { '@id': 'sec:publicKeyService', '@type': '@id' }, + 'revoked': { '@id': 'sec:revoked', '@type': 'xsd:dateTime' }, + 'signature': 'sec:signature', + 'signatureAlgorithm': 'sec:signatureAlgorithm', + 'signatureValue': 'sec:signatureValue', + 'CryptographicKey': 'sec:Key', + 'EncryptedMessage': 'sec:EncryptedMessage', + 'GraphSignature2012': 'sec:GraphSignature2012', + 'LinkedDataSignature2015': 'sec:LinkedDataSignature2015', - "accessControl": {"@id": "perm:accessControl", "@type": "@id"}, - "writePermission": {"@id": "perm:writePermission", "@type": "@id"} - } + 'accessControl': { '@id': 'perm:accessControl', '@type': '@id' }, + 'writePermission': { '@id': 'perm:writePermission', '@type': '@id' }, + }, }; const security_v1 = { - "@context": { - "id": "@id", - "type": "@type", + '@context': { + 'id': '@id', + 'type': '@type', - "dc": "http://purl.org/dc/terms/", - "sec": "https://w3id.org/security#", - "xsd": "http://www.w3.org/2001/XMLSchema#", + 'dc': 'http://purl.org/dc/terms/', + 'sec': 'https://w3id.org/security#', + 'xsd': 'http://www.w3.org/2001/XMLSchema#', - "EcdsaKoblitzSignature2016": "sec:EcdsaKoblitzSignature2016", - "Ed25519Signature2018": "sec:Ed25519Signature2018", - "EncryptedMessage": "sec:EncryptedMessage", - "GraphSignature2012": "sec:GraphSignature2012", - "LinkedDataSignature2015": "sec:LinkedDataSignature2015", - "LinkedDataSignature2016": "sec:LinkedDataSignature2016", - "CryptographicKey": "sec:Key", + 'EcdsaKoblitzSignature2016': 'sec:EcdsaKoblitzSignature2016', + 'Ed25519Signature2018': 'sec:Ed25519Signature2018', + 'EncryptedMessage': 'sec:EncryptedMessage', + 'GraphSignature2012': 'sec:GraphSignature2012', + 'LinkedDataSignature2015': 'sec:LinkedDataSignature2015', + 'LinkedDataSignature2016': 'sec:LinkedDataSignature2016', + 'CryptographicKey': 'sec:Key', - "authenticationTag": "sec:authenticationTag", - "canonicalizationAlgorithm": "sec:canonicalizationAlgorithm", - "cipherAlgorithm": "sec:cipherAlgorithm", - "cipherData": "sec:cipherData", - "cipherKey": "sec:cipherKey", - "created": {"@id": "dc:created", "@type": "xsd:dateTime"}, - "creator": {"@id": "dc:creator", "@type": "@id"}, - "digestAlgorithm": "sec:digestAlgorithm", - "digestValue": "sec:digestValue", - "domain": "sec:domain", - "encryptionKey": "sec:encryptionKey", - "expiration": {"@id": "sec:expiration", "@type": "xsd:dateTime"}, - "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"}, - "initializationVector": "sec:initializationVector", - "iterationCount": "sec:iterationCount", - "nonce": "sec:nonce", - "normalizationAlgorithm": "sec:normalizationAlgorithm", - "owner": {"@id": "sec:owner", "@type": "@id"}, - "password": "sec:password", - "privateKey": {"@id": "sec:privateKey", "@type": "@id"}, - "privateKeyPem": "sec:privateKeyPem", - "publicKey": {"@id": "sec:publicKey", "@type": "@id"}, - "publicKeyBase58": "sec:publicKeyBase58", - "publicKeyPem": "sec:publicKeyPem", - "publicKeyWif": "sec:publicKeyWif", - "publicKeyService": {"@id": "sec:publicKeyService", "@type": "@id"}, - "revoked": {"@id": "sec:revoked", "@type": "xsd:dateTime"}, - "salt": "sec:salt", - "signature": "sec:signature", - "signatureAlgorithm": "sec:signingAlgorithm", - "signatureValue": "sec:signatureValue" - } + 'authenticationTag': 'sec:authenticationTag', + 'canonicalizationAlgorithm': 'sec:canonicalizationAlgorithm', + 'cipherAlgorithm': 'sec:cipherAlgorithm', + 'cipherData': 'sec:cipherData', + 'cipherKey': 'sec:cipherKey', + 'created': { '@id': 'dc:created', '@type': 'xsd:dateTime' }, + 'creator': { '@id': 'dc:creator', '@type': '@id' }, + 'digestAlgorithm': 'sec:digestAlgorithm', + 'digestValue': 'sec:digestValue', + 'domain': 'sec:domain', + 'encryptionKey': 'sec:encryptionKey', + 'expiration': { '@id': 'sec:expiration', '@type': 'xsd:dateTime' }, + 'expires': { '@id': 'sec:expiration', '@type': 'xsd:dateTime' }, + 'initializationVector': 'sec:initializationVector', + 'iterationCount': 'sec:iterationCount', + 'nonce': 'sec:nonce', + 'normalizationAlgorithm': 'sec:normalizationAlgorithm', + 'owner': { '@id': 'sec:owner', '@type': '@id' }, + 'password': 'sec:password', + 'privateKey': { '@id': 'sec:privateKey', '@type': '@id' }, + 'privateKeyPem': 'sec:privateKeyPem', + 'publicKey': { '@id': 'sec:publicKey', '@type': '@id' }, + 'publicKeyBase58': 'sec:publicKeyBase58', + 'publicKeyPem': 'sec:publicKeyPem', + 'publicKeyWif': 'sec:publicKeyWif', + 'publicKeyService': { '@id': 'sec:publicKeyService', '@type': '@id' }, + 'revoked': { '@id': 'sec:revoked', '@type': 'xsd:dateTime' }, + 'salt': 'sec:salt', + 'signature': 'sec:signature', + 'signatureAlgorithm': 'sec:signingAlgorithm', + 'signatureValue': 'sec:signatureValue', + }, }; const activitystreams = { - "@context": { - "@vocab": "_:", - "xsd": "http://www.w3.org/2001/XMLSchema#", - "as": "https://www.w3.org/ns/activitystreams#", - "ldp": "http://www.w3.org/ns/ldp#", - "vcard": "http://www.w3.org/2006/vcard/ns#", - "id": "@id", - "type": "@type", - "Accept": "as:Accept", - "Activity": "as:Activity", - "IntransitiveActivity": "as:IntransitiveActivity", - "Add": "as:Add", - "Announce": "as:Announce", - "Application": "as:Application", - "Arrive": "as:Arrive", - "Article": "as:Article", - "Audio": "as:Audio", - "Block": "as:Block", - "Collection": "as:Collection", - "CollectionPage": "as:CollectionPage", - "Relationship": "as:Relationship", - "Create": "as:Create", - "Delete": "as:Delete", - "Dislike": "as:Dislike", - "Document": "as:Document", - "Event": "as:Event", - "Follow": "as:Follow", - "Flag": "as:Flag", - "Group": "as:Group", - "Ignore": "as:Ignore", - "Image": "as:Image", - "Invite": "as:Invite", - "Join": "as:Join", - "Leave": "as:Leave", - "Like": "as:Like", - "Link": "as:Link", - "Mention": "as:Mention", - "Note": "as:Note", - "Object": "as:Object", - "Offer": "as:Offer", - "OrderedCollection": "as:OrderedCollection", - "OrderedCollectionPage": "as:OrderedCollectionPage", - "Organization": "as:Organization", - "Page": "as:Page", - "Person": "as:Person", - "Place": "as:Place", - "Profile": "as:Profile", - "Question": "as:Question", - "Reject": "as:Reject", - "Remove": "as:Remove", - "Service": "as:Service", - "TentativeAccept": "as:TentativeAccept", - "TentativeReject": "as:TentativeReject", - "Tombstone": "as:Tombstone", - "Undo": "as:Undo", - "Update": "as:Update", - "Video": "as:Video", - "View": "as:View", - "Listen": "as:Listen", - "Read": "as:Read", - "Move": "as:Move", - "Travel": "as:Travel", - "IsFollowing": "as:IsFollowing", - "IsFollowedBy": "as:IsFollowedBy", - "IsContact": "as:IsContact", - "IsMember": "as:IsMember", - "subject": { - "@id": "as:subject", - "@type": "@id" - }, - "relationship": { - "@id": "as:relationship", - "@type": "@id" - }, - "actor": { - "@id": "as:actor", - "@type": "@id" - }, - "attributedTo": { - "@id": "as:attributedTo", - "@type": "@id" - }, - "attachment": { - "@id": "as:attachment", - "@type": "@id" - }, - "bcc": { - "@id": "as:bcc", - "@type": "@id" - }, - "bto": { - "@id": "as:bto", - "@type": "@id" - }, - "cc": { - "@id": "as:cc", - "@type": "@id" - }, - "context": { - "@id": "as:context", - "@type": "@id" - }, - "current": { - "@id": "as:current", - "@type": "@id" - }, - "first": { - "@id": "as:first", - "@type": "@id" - }, - "generator": { - "@id": "as:generator", - "@type": "@id" - }, - "icon": { - "@id": "as:icon", - "@type": "@id" - }, - "image": { - "@id": "as:image", - "@type": "@id" - }, - "inReplyTo": { - "@id": "as:inReplyTo", - "@type": "@id" - }, - "items": { - "@id": "as:items", - "@type": "@id" - }, - "instrument": { - "@id": "as:instrument", - "@type": "@id" - }, - "orderedItems": { - "@id": "as:items", - "@type": "@id", - "@container": "@list" - }, - "last": { - "@id": "as:last", - "@type": "@id" - }, - "location": { - "@id": "as:location", - "@type": "@id" - }, - "next": { - "@id": "as:next", - "@type": "@id" - }, - "object": { - "@id": "as:object", - "@type": "@id" - }, - "oneOf": { - "@id": "as:oneOf", - "@type": "@id" - }, - "anyOf": { - "@id": "as:anyOf", - "@type": "@id" - }, - "closed": { - "@id": "as:closed", - "@type": "xsd:dateTime" - }, - "origin": { - "@id": "as:origin", - "@type": "@id" - }, - "accuracy": { - "@id": "as:accuracy", - "@type": "xsd:float" - }, - "prev": { - "@id": "as:prev", - "@type": "@id" - }, - "preview": { - "@id": "as:preview", - "@type": "@id" - }, - "replies": { - "@id": "as:replies", - "@type": "@id" - }, - "result": { - "@id": "as:result", - "@type": "@id" - }, - "audience": { - "@id": "as:audience", - "@type": "@id" - }, - "partOf": { - "@id": "as:partOf", - "@type": "@id" - }, - "tag": { - "@id": "as:tag", - "@type": "@id" - }, - "target": { - "@id": "as:target", - "@type": "@id" - }, - "to": { - "@id": "as:to", - "@type": "@id" - }, - "url": { - "@id": "as:url", - "@type": "@id" - }, - "altitude": { - "@id": "as:altitude", - "@type": "xsd:float" - }, - "content": "as:content", - "contentMap": { - "@id": "as:content", - "@container": "@language" - }, - "name": "as:name", - "nameMap": { - "@id": "as:name", - "@container": "@language" - }, - "duration": { - "@id": "as:duration", - "@type": "xsd:duration" - }, - "endTime": { - "@id": "as:endTime", - "@type": "xsd:dateTime" - }, - "height": { - "@id": "as:height", - "@type": "xsd:nonNegativeInteger" - }, - "href": { - "@id": "as:href", - "@type": "@id" - }, - "hreflang": "as:hreflang", - "latitude": { - "@id": "as:latitude", - "@type": "xsd:float" - }, - "longitude": { - "@id": "as:longitude", - "@type": "xsd:float" - }, - "mediaType": "as:mediaType", - "published": { - "@id": "as:published", - "@type": "xsd:dateTime" - }, - "radius": { - "@id": "as:radius", - "@type": "xsd:float" - }, - "rel": "as:rel", - "startIndex": { - "@id": "as:startIndex", - "@type": "xsd:nonNegativeInteger" - }, - "startTime": { - "@id": "as:startTime", - "@type": "xsd:dateTime" - }, - "summary": "as:summary", - "summaryMap": { - "@id": "as:summary", - "@container": "@language" - }, - "totalItems": { - "@id": "as:totalItems", - "@type": "xsd:nonNegativeInteger" - }, - "units": "as:units", - "updated": { - "@id": "as:updated", - "@type": "xsd:dateTime" - }, - "width": { - "@id": "as:width", - "@type": "xsd:nonNegativeInteger" - }, - "describes": { - "@id": "as:describes", - "@type": "@id" - }, - "formerType": { - "@id": "as:formerType", - "@type": "@id" - }, - "deleted": { - "@id": "as:deleted", - "@type": "xsd:dateTime" - }, - "inbox": { - "@id": "ldp:inbox", - "@type": "@id" - }, - "outbox": { - "@id": "as:outbox", - "@type": "@id" - }, - "following": { - "@id": "as:following", - "@type": "@id" - }, - "followers": { - "@id": "as:followers", - "@type": "@id" - }, - "streams": { - "@id": "as:streams", - "@type": "@id" - }, - "preferredUsername": "as:preferredUsername", - "endpoints": { - "@id": "as:endpoints", - "@type": "@id" - }, - "uploadMedia": { - "@id": "as:uploadMedia", - "@type": "@id" - }, - "proxyUrl": { - "@id": "as:proxyUrl", - "@type": "@id" - }, - "liked": { - "@id": "as:liked", - "@type": "@id" - }, - "oauthAuthorizationEndpoint": { - "@id": "as:oauthAuthorizationEndpoint", - "@type": "@id" - }, - "oauthTokenEndpoint": { - "@id": "as:oauthTokenEndpoint", - "@type": "@id" - }, - "provideClientKey": { - "@id": "as:provideClientKey", - "@type": "@id" - }, - "signClientKey": { - "@id": "as:signClientKey", - "@type": "@id" - }, - "sharedInbox": { - "@id": "as:sharedInbox", - "@type": "@id" - }, - "Public": { - "@id": "as:Public", - "@type": "@id" - }, - "source": "as:source", - "likes": { - "@id": "as:likes", - "@type": "@id" - }, - "shares": { - "@id": "as:shares", - "@type": "@id" - }, - "alsoKnownAs": { - "@id": "as:alsoKnownAs", - "@type": "@id" - } - } + '@context': { + '@vocab': '_:', + 'xsd': 'http://www.w3.org/2001/XMLSchema#', + 'as': 'https://www.w3.org/ns/activitystreams#', + 'ldp': 'http://www.w3.org/ns/ldp#', + 'vcard': 'http://www.w3.org/2006/vcard/ns#', + 'id': '@id', + 'type': '@type', + 'Accept': 'as:Accept', + 'Activity': 'as:Activity', + 'IntransitiveActivity': 'as:IntransitiveActivity', + 'Add': 'as:Add', + 'Announce': 'as:Announce', + 'Application': 'as:Application', + 'Arrive': 'as:Arrive', + 'Article': 'as:Article', + 'Audio': 'as:Audio', + 'Block': 'as:Block', + 'Collection': 'as:Collection', + 'CollectionPage': 'as:CollectionPage', + 'Relationship': 'as:Relationship', + 'Create': 'as:Create', + 'Delete': 'as:Delete', + 'Dislike': 'as:Dislike', + 'Document': 'as:Document', + 'Event': 'as:Event', + 'Follow': 'as:Follow', + 'Flag': 'as:Flag', + 'Group': 'as:Group', + 'Ignore': 'as:Ignore', + 'Image': 'as:Image', + 'Invite': 'as:Invite', + 'Join': 'as:Join', + 'Leave': 'as:Leave', + 'Like': 'as:Like', + 'Link': 'as:Link', + 'Mention': 'as:Mention', + 'Note': 'as:Note', + 'Object': 'as:Object', + 'Offer': 'as:Offer', + 'OrderedCollection': 'as:OrderedCollection', + 'OrderedCollectionPage': 'as:OrderedCollectionPage', + 'Organization': 'as:Organization', + 'Page': 'as:Page', + 'Person': 'as:Person', + 'Place': 'as:Place', + 'Profile': 'as:Profile', + 'Question': 'as:Question', + 'Reject': 'as:Reject', + 'Remove': 'as:Remove', + 'Service': 'as:Service', + 'TentativeAccept': 'as:TentativeAccept', + 'TentativeReject': 'as:TentativeReject', + 'Tombstone': 'as:Tombstone', + 'Undo': 'as:Undo', + 'Update': 'as:Update', + 'Video': 'as:Video', + 'View': 'as:View', + 'Listen': 'as:Listen', + 'Read': 'as:Read', + 'Move': 'as:Move', + 'Travel': 'as:Travel', + 'IsFollowing': 'as:IsFollowing', + 'IsFollowedBy': 'as:IsFollowedBy', + 'IsContact': 'as:IsContact', + 'IsMember': 'as:IsMember', + 'subject': { + '@id': 'as:subject', + '@type': '@id', + }, + 'relationship': { + '@id': 'as:relationship', + '@type': '@id', + }, + 'actor': { + '@id': 'as:actor', + '@type': '@id', + }, + 'attributedTo': { + '@id': 'as:attributedTo', + '@type': '@id', + }, + 'attachment': { + '@id': 'as:attachment', + '@type': '@id', + }, + 'bcc': { + '@id': 'as:bcc', + '@type': '@id', + }, + 'bto': { + '@id': 'as:bto', + '@type': '@id', + }, + 'cc': { + '@id': 'as:cc', + '@type': '@id', + }, + 'context': { + '@id': 'as:context', + '@type': '@id', + }, + 'current': { + '@id': 'as:current', + '@type': '@id', + }, + 'first': { + '@id': 'as:first', + '@type': '@id', + }, + 'generator': { + '@id': 'as:generator', + '@type': '@id', + }, + 'icon': { + '@id': 'as:icon', + '@type': '@id', + }, + 'image': { + '@id': 'as:image', + '@type': '@id', + }, + 'inReplyTo': { + '@id': 'as:inReplyTo', + '@type': '@id', + }, + 'items': { + '@id': 'as:items', + '@type': '@id', + }, + 'instrument': { + '@id': 'as:instrument', + '@type': '@id', + }, + 'orderedItems': { + '@id': 'as:items', + '@type': '@id', + '@container': '@list', + }, + 'last': { + '@id': 'as:last', + '@type': '@id', + }, + 'location': { + '@id': 'as:location', + '@type': '@id', + }, + 'next': { + '@id': 'as:next', + '@type': '@id', + }, + 'object': { + '@id': 'as:object', + '@type': '@id', + }, + 'oneOf': { + '@id': 'as:oneOf', + '@type': '@id', + }, + 'anyOf': { + '@id': 'as:anyOf', + '@type': '@id', + }, + 'closed': { + '@id': 'as:closed', + '@type': 'xsd:dateTime', + }, + 'origin': { + '@id': 'as:origin', + '@type': '@id', + }, + 'accuracy': { + '@id': 'as:accuracy', + '@type': 'xsd:float', + }, + 'prev': { + '@id': 'as:prev', + '@type': '@id', + }, + 'preview': { + '@id': 'as:preview', + '@type': '@id', + }, + 'replies': { + '@id': 'as:replies', + '@type': '@id', + }, + 'result': { + '@id': 'as:result', + '@type': '@id', + }, + 'audience': { + '@id': 'as:audience', + '@type': '@id', + }, + 'partOf': { + '@id': 'as:partOf', + '@type': '@id', + }, + 'tag': { + '@id': 'as:tag', + '@type': '@id', + }, + 'target': { + '@id': 'as:target', + '@type': '@id', + }, + 'to': { + '@id': 'as:to', + '@type': '@id', + }, + 'url': { + '@id': 'as:url', + '@type': '@id', + }, + 'altitude': { + '@id': 'as:altitude', + '@type': 'xsd:float', + }, + 'content': 'as:content', + 'contentMap': { + '@id': 'as:content', + '@container': '@language', + }, + 'name': 'as:name', + 'nameMap': { + '@id': 'as:name', + '@container': '@language', + }, + 'duration': { + '@id': 'as:duration', + '@type': 'xsd:duration', + }, + 'endTime': { + '@id': 'as:endTime', + '@type': 'xsd:dateTime', + }, + 'height': { + '@id': 'as:height', + '@type': 'xsd:nonNegativeInteger', + }, + 'href': { + '@id': 'as:href', + '@type': '@id', + }, + 'hreflang': 'as:hreflang', + 'latitude': { + '@id': 'as:latitude', + '@type': 'xsd:float', + }, + 'longitude': { + '@id': 'as:longitude', + '@type': 'xsd:float', + }, + 'mediaType': 'as:mediaType', + 'published': { + '@id': 'as:published', + '@type': 'xsd:dateTime', + }, + 'radius': { + '@id': 'as:radius', + '@type': 'xsd:float', + }, + 'rel': 'as:rel', + 'startIndex': { + '@id': 'as:startIndex', + '@type': 'xsd:nonNegativeInteger', + }, + 'startTime': { + '@id': 'as:startTime', + '@type': 'xsd:dateTime', + }, + 'summary': 'as:summary', + 'summaryMap': { + '@id': 'as:summary', + '@container': '@language', + }, + 'totalItems': { + '@id': 'as:totalItems', + '@type': 'xsd:nonNegativeInteger', + }, + 'units': 'as:units', + 'updated': { + '@id': 'as:updated', + '@type': 'xsd:dateTime', + }, + 'width': { + '@id': 'as:width', + '@type': 'xsd:nonNegativeInteger', + }, + 'describes': { + '@id': 'as:describes', + '@type': '@id', + }, + 'formerType': { + '@id': 'as:formerType', + '@type': '@id', + }, + 'deleted': { + '@id': 'as:deleted', + '@type': 'xsd:dateTime', + }, + 'inbox': { + '@id': 'ldp:inbox', + '@type': '@id', + }, + 'outbox': { + '@id': 'as:outbox', + '@type': '@id', + }, + 'following': { + '@id': 'as:following', + '@type': '@id', + }, + 'followers': { + '@id': 'as:followers', + '@type': '@id', + }, + 'streams': { + '@id': 'as:streams', + '@type': '@id', + }, + 'preferredUsername': 'as:preferredUsername', + 'endpoints': { + '@id': 'as:endpoints', + '@type': '@id', + }, + 'uploadMedia': { + '@id': 'as:uploadMedia', + '@type': '@id', + }, + 'proxyUrl': { + '@id': 'as:proxyUrl', + '@type': '@id', + }, + 'liked': { + '@id': 'as:liked', + '@type': '@id', + }, + 'oauthAuthorizationEndpoint': { + '@id': 'as:oauthAuthorizationEndpoint', + '@type': '@id', + }, + 'oauthTokenEndpoint': { + '@id': 'as:oauthTokenEndpoint', + '@type': '@id', + }, + 'provideClientKey': { + '@id': 'as:provideClientKey', + '@type': '@id', + }, + 'signClientKey': { + '@id': 'as:signClientKey', + '@type': '@id', + }, + 'sharedInbox': { + '@id': 'as:sharedInbox', + '@type': '@id', + }, + 'Public': { + '@id': 'as:Public', + '@type': '@id', + }, + 'source': 'as:source', + 'likes': { + '@id': 'as:likes', + '@type': '@id', + }, + 'shares': { + '@id': 'as:shares', + '@type': '@id', + }, + 'alsoKnownAs': { + '@id': 'as:alsoKnownAs', + '@type': '@id', + }, + }, }; -export const CONTEXTS: Record = { - "https://w3id.org/identity/v1": id_v1, - "https://w3id.org/security/v1": security_v1, - "https://www.w3.org/ns/activitystreams": activitystreams, +export const CONTEXTS: Record = { + 'https://w3id.org/identity/v1': id_v1, + 'https://w3id.org/security/v1': security_v1, + 'https://www.w3.org/ns/activitystreams': activitystreams, }; diff --git a/packages/backend/src/remote/activitypub/models/person.ts b/packages/backend/src/remote/activitypub/models/person.ts index 95db46bff..9e9cb3a96 100644 --- a/packages/backend/src/remote/activitypub/models/person.ts +++ b/packages/backend/src/remote/activitypub/models/person.ts @@ -163,7 +163,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise /users/:id のように入力がaliasなときにエラーになることがあるのを対応 const u = await Users.findOne({ - uri: person.id + uri: person.id, }); if (u) { @@ -218,11 +218,11 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise img == null ? Promise.resolve(null) - : resolveImage(user!, img).catch(() => null) + : resolveImage(user!, img).catch(() => null), )); const avatarId = avatar ? avatar.id : null; @@ -258,7 +258,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise emoji.name); await Users.update(user!.id, { - emojis: emojiNames + emojis: emojiNames, }); //#endregion @@ -301,11 +301,11 @@ export async function updatePerson(uri: string, resolver?: Resolver | null, hint // アバターとヘッダー画像をフェッチ const [avatar, banner] = await Promise.all([ person.icon, - person.image + person.image, ].map(img => img == null ? Promise.resolve(null) - : resolveImage(exist, img).catch(() => null) + : resolveImage(exist, img).catch(() => null), )); // カスタム絵文字取得 @@ -355,7 +355,7 @@ export async function updatePerson(uri: string, resolver?: Resolver | null, hint if (person.publicKey) { await UserPublickeys.update({ userId: exist.id }, { keyId: person.publicKey.id, - keyPem: person.publicKey.publicKeyPem + keyPem: person.publicKey.publicKeyPem, }); } @@ -372,9 +372,9 @@ export async function updatePerson(uri: string, resolver?: Resolver | null, hint // 該当ユーザーが既にフォロワーになっていた場合はFollowingもアップデートする await Followings.update({ - followerId: exist.id + followerId: exist.id, }, { - followerSharedInbox: person.sharedInbox || (person.endpoints ? person.endpoints.sharedInbox : undefined) + followerSharedInbox: person.sharedInbox || (person.endpoints ? person.endpoints.sharedInbox : undefined), }); await updateFeatured(exist.id).catch(err => logger.error(err)); @@ -411,8 +411,9 @@ const services: { }; const $discord = (id: string, name: string) => { - if (typeof name !== 'string') + if (typeof name !== 'string') { name = 'unknown#0000'; + } const [username, discriminator] = name.split('#'); return { id, username, discriminator }; }; @@ -420,13 +421,15 @@ const $discord = (id: string, name: string) => { function addService(target: { [x: string]: any }, source: IApPropertyValue) { const service = services[source.name]; - if (typeof source.value !== 'string') + if (typeof source.value !== 'string') { source.value = 'unknown'; + } const [id, username] = source.value.split('@'); - if (service) + if (service) { target[source.name.split(':')[2]] = service(id, username); + } } export function analyzeAttachments(attachments: IObject | IObject[] | undefined) { @@ -443,7 +446,7 @@ export function analyzeAttachments(attachments: IObject | IObject[] | undefined) } else { fields.push({ name: attachment.name, - value: fromHtml(attachment.value) + value: fromHtml(attachment.value), }); } } @@ -487,7 +490,7 @@ export async function updateFeatured(userId: User['id']) { id: genId(new Date(Date.now() + td)), createdAt: new Date(), userId: user.id, - noteId: note!.id + noteId: note!.id, }); } }); diff --git a/packages/backend/src/remote/activitypub/renderer/question.ts b/packages/backend/src/remote/activitypub/renderer/question.ts index 246d599ba..c800e73a5 100644 --- a/packages/backend/src/remote/activitypub/renderer/question.ts +++ b/packages/backend/src/remote/activitypub/renderer/question.ts @@ -8,7 +8,7 @@ export default async function renderQuestion(user: { id: User['id'] }, note: Not type: 'Question', id: `${config.url}/questions/${note.id}`, actor: `${config.url}/users/${user.id}`, - content: note.text || '', + content: note.text || '', [poll.multiple ? 'anyOf' : 'oneOf']: poll.choices.map((text, i) => ({ name: text, _misskey_votes: poll.votes[i], diff --git a/packages/backend/src/server/api/2fa.ts b/packages/backend/src/server/api/2fa.ts index 117446383..2c8c842a1 100644 --- a/packages/backend/src/server/api/2fa.ts +++ b/packages/backend/src/server/api/2fa.ts @@ -6,7 +6,7 @@ const ECC_PRELUDE = Buffer.from([0x04]); const NULL_BYTE = Buffer.from([0]); const PEM_PRELUDE = Buffer.from( '3059301306072a8648ce3d020106082a8648ce3d030107034200', - 'hex' + 'hex', ); // Android Safetynet attestations are signed with this cert: @@ -68,7 +68,7 @@ function verifyCertificateChain(certificates: string[]) { const signatureHex = certificate.getSignatureValueHex(); // Verify against CA - const Signature = new jsrsasign.KJUR.crypto.Signature({alg: algorithm}); + const Signature = new jsrsasign.KJUR.crypto.Signature({ alg: algorithm }); Signature.init(CACert); Signature.updateHex(certStruct); valid = valid && !!Signature.verify(signatureHex); // true if CA signed the certificate @@ -134,7 +134,7 @@ export function verifyLogin({ const verificationData = Buffer.concat( [authenticatorData, hash(clientDataJSON)], - 32 + authenticatorData.length + 32 + authenticatorData.length, ); return crypto @@ -145,7 +145,7 @@ export function verifyLogin({ export const procedures = { none: { - verify({publicKey}: {publicKey: Map}) { + verify({ publicKey }: {publicKey: Map}) { const negTwo = publicKey.get(-2); if (!negTwo || negTwo.length != 32) { @@ -158,14 +158,14 @@ export const procedures = { const publicKeyU2F = Buffer.concat( [ECC_PRELUDE, negTwo, negThree], - 1 + 32 + 32 + 1 + 32 + 32, ); return { publicKey: publicKeyU2F, - valid: true + valid: true, }; - } + }, }, 'android-key': { verify({ @@ -174,7 +174,7 @@ export const procedures = { clientDataHash, publicKey, rpIdHash, - credentialId + credentialId, }: { attStmt: any, authenticatorData: Buffer, @@ -189,7 +189,7 @@ export const procedures = { const verificationData = Buffer.concat([ authenticatorData, - clientDataHash + clientDataHash, ]); const attCert: Buffer = attStmt.x5c[0]; @@ -206,7 +206,7 @@ export const procedures = { const publicKeyData = Buffer.concat( [ECC_PRELUDE, negTwo, negThree], - 1 + 32 + 32 + 1 + 32 + 32, ); if (!attCert.equals(publicKeyData)) { @@ -222,9 +222,9 @@ export const procedures = { return { valid: isValid, - publicKey: publicKeyData + publicKey: publicKeyData, }; - } + }, }, // what a stupid attestation 'android-safetynet': { @@ -234,7 +234,7 @@ export const procedures = { clientDataHash, publicKey, rpIdHash, - credentialId + credentialId, }: { attStmt: any, authenticatorData: Buffer, @@ -244,14 +244,14 @@ export const procedures = { credentialId: Buffer, }) { const verificationData = hash( - Buffer.concat([authenticatorData, clientDataHash]) + Buffer.concat([authenticatorData, clientDataHash]), ); const jwsParts = attStmt.response.toString('utf-8').split('.'); const header = JSON.parse(base64URLDecode(jwsParts[0]).toString('utf-8')); const response = JSON.parse( - base64URLDecode(jwsParts[1]).toString('utf-8') + base64URLDecode(jwsParts[1]).toString('utf-8'), ); const signature = jwsParts[2]; @@ -273,7 +273,7 @@ export const procedures = { const signatureBase = Buffer.from( jwsParts[0] + '.' + jwsParts[1], - 'utf-8' + 'utf-8', ); const valid = crypto @@ -293,13 +293,13 @@ export const procedures = { const publicKeyData = Buffer.concat( [ECC_PRELUDE, negTwo, negThree], - 1 + 32 + 32 + 1 + 32 + 32, ); return { valid, - publicKey: publicKeyData + publicKey: publicKeyData, }; - } + }, }, packed: { verify({ @@ -308,7 +308,7 @@ export const procedures = { clientDataHash, publicKey, rpIdHash, - credentialId + credentialId, }: { attStmt: any, authenticatorData: Buffer, @@ -319,7 +319,7 @@ export const procedures = { }) { const verificationData = Buffer.concat([ authenticatorData, - clientDataHash + clientDataHash, ]); if (attStmt.x5c) { @@ -342,12 +342,12 @@ export const procedures = { const publicKeyData = Buffer.concat( [ECC_PRELUDE, negTwo, negThree], - 1 + 32 + 32 + 1 + 32 + 32, ); return { valid: validSignature, - publicKey: publicKeyData + publicKey: publicKeyData, }; } else if (attStmt.ecdaaKeyId) { // https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-ecdaa-algorithm-v2.0-id-20180227.html#ecdaa-verify-operation @@ -357,7 +357,7 @@ export const procedures = { throw new Error('self attestation is not supported'); } - } + }, }, 'fido-u2f': { @@ -367,7 +367,7 @@ export const procedures = { clientDataHash, publicKey, rpIdHash, - credentialId + credentialId, }: { attStmt: any, authenticatorData: Buffer, @@ -397,7 +397,7 @@ export const procedures = { const publicKeyU2F = Buffer.concat( [ECC_PRELUDE, negTwo, negThree], - 1 + 32 + 32 + 1 + 32 + 32, ); const verificationData = Buffer.concat([ @@ -405,7 +405,7 @@ export const procedures = { rpIdHash, clientDataHash, credentialId, - publicKeyU2F + publicKeyU2F, ]); const validSignature = crypto @@ -415,8 +415,8 @@ export const procedures = { return { valid: validSignature, - publicKey: publicKeyU2F + publicKey: publicKeyU2F, }; - } - } + }, + }, }; diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index e9584e7b8..d2d1ede3c 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -244,8 +244,9 @@ export default define(meta, async (ps, user) => { if (ps.poll) { if (typeof ps.poll.expiresAt === 'number') { - if (ps.poll.expiresAt < Date.now()) + if (ps.poll.expiresAt < Date.now()) { throw new ApiError(meta.errors.cannotCreateAlreadyExpiredPoll); + } } else if (typeof ps.poll.expiredAfter === 'number') { ps.poll.expiresAt = Date.now() + ps.poll.expiredAfter; } diff --git a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts index f67050138..e7a653702 100644 --- a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts +++ b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts @@ -112,8 +112,9 @@ export default define(meta, async (ps, user) => { if (exist.length) { if (poll.multiple) { - if (exist.some(x => x.choice == ps.choice)) + if (exist.some(x => x.choice == ps.choice)) { throw new ApiError(meta.errors.alreadyVoted); + } } else { throw new ApiError(meta.errors.alreadyVoted); } diff --git a/packages/backend/src/server/api/service/github.ts b/packages/backend/src/server/api/service/github.ts index 0616f3f77..07b4fe717 100644 --- a/packages/backend/src/server/api/service/github.ts +++ b/packages/backend/src/server/api/service/github.ts @@ -42,7 +42,7 @@ router.get('/disconnect/github', async ctx => { const user = await Users.findOneOrFail({ host: null, - token: userToken + token: userToken, }); const profile = await UserProfiles.findOneOrFail(user.id); @@ -58,7 +58,7 @@ router.get('/disconnect/github', async ctx => { // Publish i updated event publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, { detail: true, - includeSecrets: true + includeSecrets: true, })); }); @@ -209,12 +209,13 @@ router.get('/gh/cb', async ctx => { code, { redirect_uri }, (err, accessToken, refresh, result) => { - if (err) + if (err) { rej(err); - else if (result.error) + } else if (result.error) { rej(result.error); - else + } else { res({ accessToken }); + } })); const { login, id } = await getJson('https://api.github.com/user', 'application/vnd.github.v3+json', 10 * 1000, { diff --git a/packages/backend/src/server/well-known.ts b/packages/backend/src/server/well-known.ts index 5e99b0065..0f65f6e58 100644 --- a/packages/backend/src/server/well-known.ts +++ b/packages/backend/src/server/well-known.ts @@ -41,8 +41,8 @@ router.get('/.well-known/host-meta', async ctx => { ctx.set('Content-Type', xrd); ctx.body = XRD({ element: 'Link', attributes: { type: xrd, - template: `${config.url}${webFingerPath}?resource={uri}` - }}); + template: `${config.url}${webFingerPath}?resource={uri}`, + } }); }); router.get('/.well-known/host-meta.json', async ctx => { @@ -51,8 +51,8 @@ router.get('/.well-known/host-meta.json', async ctx => { links: [{ rel: 'lrdd', type: jrd, - template: `${config.url}${webFingerPath}?resource={uri}` - }] + template: `${config.url}${webFingerPath}?resource={uri}`, + }], }; }); From 7042933b3bece2ac13983bf1bb7b25f37b91b5d6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 14 Nov 2021 00:07:07 +0900 Subject: [PATCH 03/29] Update build.js --- scripts/build.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scripts/build.js b/scripts/build.js index 6d4bb6c6e..783af7827 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -17,12 +17,6 @@ const execa = require('execa'); stderr: process.stderr, }); - await execa('npm', ['run', 'build'], { - cwd: __dirname + '/../packages/client', - stdout: process.stdout, - stderr: process.stderr, - }); - console.log('build finishing ...'); await execa('npm', ['run', 'gulp'], { From 974250da6c8153dfc284c0587a178e2b213e414d Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sun, 14 Nov 2021 10:43:19 +0900 Subject: [PATCH 04/29] Fix v12.96.x Docker (#7982) --- Dockerfile | 1 - package.json | 3 ++- packages/client/package.json | 1 + packages/client/yarn.lock | 5 +++++ yarn.lock | 12 ++++++++++++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6ba8d296d..df8603430 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,6 @@ COPY --from=builder /misskey/built ./built COPY --from=builder /misskey/packages/backend/node_modules ./packages/backend/node_modules COPY --from=builder /misskey/packages/backend/built ./packages/backend/built COPY --from=builder /misskey/packages/client/node_modules ./packages/client/node_modules -COPY --from=builder /misskey/packages/client/built ./packages/client/built COPY . ./ CMD ["npm", "run", "migrateandstart"] diff --git a/package.json b/package.json index a6a735341..d712e21e2 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "gulp-cssnano": "2.1.3", "gulp-rename": "2.0.0", "gulp-replace": "1.1.3", - "gulp-terser": "2.1.0" + "gulp-terser": "2.1.0", + "js-yaml": "4.1.0" }, "devDependencies": { "@redocly/openapi-core": "1.0.0-beta.54", diff --git a/packages/client/package.json b/packages/client/package.json index 02ccb57e1..57cc51953 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -106,6 +106,7 @@ "punycode": "2.1.1", "pureimage": "0.3.5", "qrcode": "1.4.4", + "querystring": "0.2.1", "random-seed": "0.3.0", "ratelimiter": "3.4.1", "reflect-metadata": "0.1.13", diff --git a/packages/client/yarn.lock b/packages/client/yarn.lock index 34b936c45..50f476a49 100644 --- a/packages/client/yarn.lock +++ b/packages/client/yarn.lock @@ -5237,6 +5237,11 @@ querystring@0.2.0: resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA= +querystring@0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.1.tgz#40d77615bb09d16902a85c3e38aa8b5ed761c2dd" + integrity sha512-wkvS7mL/JMugcup3/rMitHmd9ecIGd2lhFhK9N3UUQ450h66d1r3Y9nvXzQAW1Lq+wyx61k/1pfKS5KuKiyEbg== + quick-lru@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" diff --git a/yarn.lock b/yarn.lock index 792e08830..8900fcad6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -323,6 +323,11 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + arr-diff@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" @@ -2300,6 +2305,13 @@ js-levenshtein@^1.1.6: resolved "https://registry.yarnpkg.com/js-levenshtein/-/js-levenshtein-1.1.6.tgz#c6cee58eb3550372df8deb85fad5ce66ce01d59d" integrity sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g== +js-yaml@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== + dependencies: + argparse "^2.0.1" + js-yaml@^3.14.1: version "3.14.1" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" From 8a40026c5cc4acb8a290eca81dcfdd5b565a2123 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 14 Nov 2021 13:13:05 +0900 Subject: [PATCH 05/29] fix(client): improve error handling --- packages/backend/src/server/web/boot.js | 2 -- packages/client/src/init.ts | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/server/web/boot.js b/packages/backend/src/server/web/boot.js index d4a2529e6..751e8619b 100644 --- a/packages/backend/src/server/web/boot.js +++ b/packages/backend/src/server/web/boot.js @@ -45,8 +45,6 @@ localStorage.setItem('lang', lang); localStorage.setItem('locale', await res.text()); localStorage.setItem('localeVersion', v); - } else if (localeOutdated) { - // nop } else { await checkUpdate(); renderError('LOCALE_FETCH_FAILED'); diff --git a/packages/client/src/init.ts b/packages/client/src/init.ts index da5b0489a..27ed78106 100644 --- a/packages/client/src/init.ts +++ b/packages/client/src/init.ts @@ -42,10 +42,6 @@ import { getAccountFromId } from '@/scripts/get-account-from-id'; console.info(`Misskey v${version}`); -// boot.jsのやつを解除 -window.onerror = null; -window.onunhandledrejection = null; - if (_DEV_) { console.warn('Development mode!!!'); @@ -224,6 +220,10 @@ const rootEl = document.createElement('div'); document.body.appendChild(rootEl); app.mount(rootEl); +// boot.jsのやつを解除 +window.onerror = null; +window.onunhandledrejection = null; + reactionPicker.init(); if (splash) { From 50e1040f1eecf418069324ad059b30d782c86968 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 14 Nov 2021 13:13:22 +0900 Subject: [PATCH 06/29] fix(client): fix tooltip style --- .../components/reactions-viewer.details.vue | 40 +++++++++++-------- .../client/src/components/renote.details.vue | 38 ++++++++++++------ 2 files changed, 50 insertions(+), 28 deletions(-) diff --git a/packages/client/src/components/reactions-viewer.details.vue b/packages/client/src/components/reactions-viewer.details.vue index d80f9b9e8..ecf138969 100644 --- a/packages/client/src/components/reactions-viewer.details.vue +++ b/packages/client/src/components/reactions-viewer.details.vue @@ -6,21 +6,11 @@
{{ reaction.replace('@.', '') }}
- - +
+ + +
+
+{{ count - 10 }}
@@ -81,13 +71,31 @@ export default defineComponent({ } > .users { - display: flex; flex: 1; min-width: 0; font-size: 0.9em; border-left: solid 0.5px var(--divider); padding-left: 10px; margin-left: 10px; + margin-right: 14px; + text-align: left; + + > .user { + line-height: 24px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + + &:not(:last-child) { + margin-bottom: 3px; + } + + > .avatar { + width: 24px; + height: 24px; + margin-right: 3px; + } + } } } diff --git a/packages/client/src/components/renote.details.vue b/packages/client/src/components/renote.details.vue index 128d97d8d..ff9c4505a 100644 --- a/packages/client/src/components/renote.details.vue +++ b/packages/client/src/components/renote.details.vue @@ -1,11 +1,11 @@ @@ -36,11 +36,25 @@ export default defineComponent({ From c864d700d24ba218aeaabb9d782abbbe8c97f6c0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 14 Nov 2021 13:27:46 +0900 Subject: [PATCH 07/29] =?UTF-8?q?feat(client):=20=E3=82=A2=E3=82=AB?= =?UTF-8?q?=E3=82=A6=E3=83=B3=E3=83=88=E5=89=8A=E9=99=A4=E3=81=AB=E7=A2=BA?= =?UTF-8?q?=E8=AA=8D=E3=83=80=E3=82=A4=E3=82=A2=E3=83=AD=E3=82=B0=E3=82=92?= =?UTF-8?q?=E5=87=BA=E3=81=99=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 7 +++++++ locales/ja-JP.yml | 1 + packages/client/src/pages/settings/delete-account.vue | 9 +++++++++ 3 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd90898fe..0fc5351d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ --> +## 12.x.x (unreleased) + +### Improvements +- アカウント削除に確認ダイアログを出すように + +### Bugfixes + ## 12.96.1 (2021/11/13) ### Improvements - npm scriptの互換性を向上 diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index ababad4f0..0dbe35216 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -806,6 +806,7 @@ muteThread: "スレッドをミュート" unmuteThread: "スレッドのミュートを解除" ffVisibility: "つながりの公開範囲" ffVisibilityDescription: "自分のフォロー/フォロワー情報の公開範囲を設定できます。" +deleteAccountConfirm: "アカウントが削除されます。よろしいですか?" _emailUnavailable: used: "既に使用されています" diff --git a/packages/client/src/pages/settings/delete-account.vue b/packages/client/src/pages/settings/delete-account.vue index 018f7c795..77dc0fe2a 100644 --- a/packages/client/src/pages/settings/delete-account.vue +++ b/packages/client/src/pages/settings/delete-account.vue @@ -45,6 +45,15 @@ export default defineComponent({ methods: { async deleteAccount() { + { + const { canceled } = await os.dialog({ + type: 'warning', + text: this.$ts.deleteAccountConfirm, + showCancelButton: true + }); + if (canceled) return; + } + const { canceled, result: password } = await os.dialog({ title: this.$ts.password, input: { From 76a7b5f0678ce22baa68e8bddeb0032bc68eccd4 Mon Sep 17 00:00:00 2001 From: futchitwo <74236683+futchitwo@users.noreply.github.com> Date: Thu, 18 Nov 2021 17:38:58 +0900 Subject: [PATCH 08/29] fix(client):fix search all users (#7993) --- packages/client/src/pages/explore.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/pages/explore.vue b/packages/client/src/pages/explore.vue index 7b1fcd091..92d940144 100644 --- a/packages/client/src/pages/explore.vue +++ b/packages/client/src/pages/explore.vue @@ -68,9 +68,9 @@ + - From d35f0247a20ebfab83188099966d8623590260e7 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 18 Nov 2021 17:40:20 +0900 Subject: [PATCH 09/29] Update CHANGELOG.md --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fc5351d0..e17c3332a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,11 @@ ## 12.x.x (unreleased) ### Improvements -- アカウント削除に確認ダイアログを出すように +- クライアント: アカウント削除に確認ダイアログを出すように ### Bugfixes +- クライアント: ユーザー検索の「全て」が動作しない問題を修正 +- クライアント: リアクション一覧、Renote一覧ツールチップのスタイルを修正 ## 12.96.1 (2021/11/13) ### Improvements From dded3912f8a950013179f2eb301fd26fd776f53c Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 18 Nov 2021 17:41:19 +0900 Subject: [PATCH 10/29] ci: cache node_modules --- .github/workflows/lint.yml | 4 ++++ .github/workflows/test.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0b3bbc186..9ba110f77 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,5 +17,9 @@ jobs: - uses: actions/setup-node@v1 with: node-version: 12.x + - uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - run: yarn install - run: yarn lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e220d714d..6a684eaa4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -75,6 +75,10 @@ jobs: uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} + - uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn install - name: Check yarn.lock From ea9aeef9d8790db51c59a99927cd47ea9423be88 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 18 Nov 2021 18:45:58 +0900 Subject: [PATCH 11/29] refactor(client): refactor dialog functions to improve type inference --- .../src/components/abuse-report-window.vue | 2 +- packages/client/src/components/drive.file.vue | 13 +- .../client/src/components/drive.folder.vue | 16 +-- packages/client/src/components/drive.vue | 31 ++-- .../client/src/components/follow-button.vue | 3 +- .../client/src/components/note-detailed.vue | 23 ++- packages/client/src/components/note.vue | 23 ++- .../src/components/page/page.button.vue | 4 +- packages/client/src/components/page/page.vue | 4 +- .../src/components/post-form-attaches.vue | 6 +- packages/client/src/components/post-form.vue | 5 +- packages/client/src/components/sample.vue | 2 +- packages/client/src/components/signin.vue | 6 +- packages/client/src/components/signup.vue | 4 +- packages/client/src/os.ts | 134 +++++++++++++++++- packages/client/src/pages/admin/ads.vue | 3 +- .../client/src/pages/admin/announcements.vue | 11 +- .../client/src/pages/admin/email-settings.vue | 7 +- .../src/pages/admin/emoji-edit-dialog.vue | 3 +- .../client/src/pages/admin/file-dialog.vue | 3 +- packages/client/src/pages/admin/files.vue | 5 +- packages/client/src/pages/admin/index.vue | 4 +- packages/client/src/pages/admin/queue.vue | 3 +- packages/client/src/pages/admin/relays.vue | 11 +- packages/client/src/pages/admin/users.vue | 7 +- .../src/pages/advanced-theme-editor.vue | 15 +- .../client/src/pages/antenna-timeline.vue | 7 +- packages/client/src/pages/clip.vue | 3 +- packages/client/src/pages/follow.vue | 5 +- packages/client/src/pages/gallery/edit.vue | 3 +- packages/client/src/pages/gallery/post.vue | 3 +- packages/client/src/pages/messaging/index.vue | 14 +- .../pages/messaging/messaging-room.form.vue | 15 +- .../src/pages/messaging/messaging-room.vue | 2 +- .../client/src/pages/my-antennas/editor.vue | 3 +- packages/client/src/pages/my-groups/group.vue | 9 +- packages/client/src/pages/my-groups/index.vue | 3 +- packages/client/src/pages/my-lists/index.vue | 3 +- packages/client/src/pages/my-lists/list.vue | 9 +- .../page-editor/els/page-editor.el.if.vue | 8 +- .../els/page-editor.el.section.vue | 16 +-- .../page-editor/page-editor.script-block.vue | 8 +- .../src/pages/page-editor/page-editor.vue | 30 ++-- packages/client/src/pages/page.vue | 3 +- packages/client/src/pages/room/room.vue | 20 +-- packages/client/src/pages/scratchpad.vue | 7 +- packages/client/src/pages/settings/2fa.vue | 26 ++-- packages/client/src/pages/settings/api.vue | 2 +- .../client/src/pages/settings/custom-css.vue | 3 +- packages/client/src/pages/settings/deck.vue | 9 +- .../src/pages/settings/delete-account.vue | 11 +- .../src/pages/settings/email-address.vue | 6 +- .../client/src/pages/settings/general.vue | 3 +- .../src/pages/settings/import-export.vue | 8 +- packages/client/src/pages/settings/menu.vue | 18 +-- .../src/pages/settings/plugin.install.vue | 8 +- .../client/src/pages/settings/profile.vue | 2 +- .../client/src/pages/settings/reaction.vue | 3 +- .../src/pages/settings/registry.value.vue | 8 +- .../client/src/pages/settings/security.vue | 26 ++-- .../src/pages/settings/theme.install.vue | 8 +- packages/client/src/pages/share.vue | 2 +- packages/client/src/pages/test.vue | 3 +- packages/client/src/pages/theme-editor.vue | 13 +- packages/client/src/pages/timeline.vue | 7 +- packages/client/src/pages/user-info.vue | 13 +- .../client/src/pages/user-list-timeline.vue | 7 +- packages/client/src/pages/welcome.setup.vue | 2 +- packages/client/src/scripts/aiscript/api.ts | 5 +- packages/client/src/scripts/get-user-menu.ts | 31 ++-- packages/client/src/scripts/hpml/evaluator.ts | 3 +- packages/client/src/scripts/lookup-user.ts | 5 +- packages/client/src/scripts/search.ts | 5 +- packages/client/src/scripts/select-file.ts | 11 +- .../src/scripts/show-suspended-dialog.ts | 2 +- packages/client/src/ui/chat/note.vue | 23 ++- packages/client/src/ui/chat/pages/channel.vue | 3 +- packages/client/src/ui/chat/post-form.vue | 5 +- packages/client/src/ui/deck.vue | 12 +- .../client/src/ui/deck/antenna-column.vue | 12 +- packages/client/src/ui/deck/list-column.vue | 14 +- packages/client/src/ui/deck/tl-column.vue | 23 ++- packages/client/src/widgets/aiscript.vue | 7 +- packages/client/src/widgets/button.vue | 7 +- 84 files changed, 415 insertions(+), 460 deletions(-) diff --git a/packages/client/src/components/abuse-report-window.vue b/packages/client/src/components/abuse-report-window.vue index 700ce30bb..d6d229bc8 100644 --- a/packages/client/src/components/abuse-report-window.vue +++ b/packages/client/src/components/abuse-report-window.vue @@ -61,7 +61,7 @@ export default defineComponent({ userId: this.user.id, comment: this.comment, }, undefined, res => { - os.dialog({ + os.alert({ type: 'success', text: this.$ts.abuseReported }); diff --git a/packages/client/src/components/drive.file.vue b/packages/client/src/components/drive.file.vue index c191127e8..7e510e4f5 100644 --- a/packages/client/src/components/drive.file.vue +++ b/packages/client/src/components/drive.file.vue @@ -138,13 +138,11 @@ export default defineComponent({ }, rename() { - os.dialog({ + os.inputText({ title: this.$ts.renameFile, - input: { - placeholder: this.$ts.inputNewFileName, - default: this.file.name, - allowEmpty: false - } + placeholder: this.$ts.inputNewFileName, + default: this.file.name, + allowEmpty: false }).then(({ canceled, result: name }) => { if (canceled) return; os.api('drive/files/update', { @@ -191,10 +189,9 @@ export default defineComponent({ }, async deleteFile() { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'warning', text: this.$t('driveFileDeleteConfirm', { name: this.file.name }), - showCancelButton: true }); if (canceled) return; diff --git a/packages/client/src/components/drive.folder.vue b/packages/client/src/components/drive.folder.vue index 91e27cc8a..95690b7e6 100644 --- a/packages/client/src/components/drive.folder.vue +++ b/packages/client/src/components/drive.folder.vue @@ -151,13 +151,13 @@ export default defineComponent({ }).catch(err => { switch (err) { case 'detected-circular-definition': - os.dialog({ + os.alert({ title: this.$ts.unableToProcess, text: this.$ts.circularReferenceFolder }); break; default: - os.dialog({ + os.alert({ type: 'error', text: this.$ts.somethingHappened }); @@ -191,12 +191,10 @@ export default defineComponent({ }, rename() { - os.dialog({ + os.inputText({ title: this.$ts.renameFolder, - input: { - placeholder: this.$ts.inputNewFolderName, - default: this.folder.name - } + placeholder: this.$ts.inputNewFolderName, + default: this.folder.name }).then(({ canceled, result: name }) => { if (canceled) return; os.api('drive/folders/update', { @@ -216,14 +214,14 @@ export default defineComponent({ }).catch(err => { switch(err.id) { case 'b0fc8a17-963c-405d-bfbc-859a487295e1': - os.dialog({ + os.alert({ type: 'error', title: this.$ts.unableToDelete, text: this.$ts.hasChildFilesOrFolders }); break; default: - os.dialog({ + os.alert({ type: 'error', text: this.$ts.unableToDelete }); diff --git a/packages/client/src/components/drive.vue b/packages/client/src/components/drive.vue index 2b72a0a1c..a785751ad 100644 --- a/packages/client/src/components/drive.vue +++ b/packages/client/src/components/drive.vue @@ -274,13 +274,13 @@ export default defineComponent({ }).catch(err => { switch (err) { case 'detected-circular-definition': - os.dialog({ + os.alert({ title: this.$ts.unableToProcess, text: this.$ts.circularReferenceFolder }); break; default: - os.dialog({ + os.alert({ type: 'error', text: this.$ts.somethingHappened }); @@ -295,11 +295,10 @@ export default defineComponent({ }, urlUpload() { - os.dialog({ + os.inputText({ title: this.$ts.uploadFromUrl, - input: { - placeholder: this.$ts.uploadFromUrlDescription - } + type: 'url', + placeholder: this.$ts.uploadFromUrlDescription }).then(({ canceled, result: url }) => { if (canceled) return; os.api('drive/files/upload-from-url', { @@ -307,7 +306,7 @@ export default defineComponent({ folderId: this.folder ? this.folder.id : undefined }); - os.dialog({ + os.alert({ title: this.$ts.uploadFromUrlRequested, text: this.$ts.uploadFromUrlMayTakeTime }); @@ -315,11 +314,9 @@ export default defineComponent({ }, createFolder() { - os.dialog({ + os.inputText({ title: this.$ts.createFolder, - input: { - placeholder: this.$ts.folderName - } + placeholder: this.$ts.folderName }).then(({ canceled, result: name }) => { if (canceled) return; os.api('drive/folders/create', { @@ -332,12 +329,10 @@ export default defineComponent({ }, renameFolder(folder) { - os.dialog({ + os.inputText({ title: this.$ts.renameFolder, - input: { - placeholder: this.$ts.inputNewFolderName, - default: folder.name - } + placeholder: this.$ts.inputNewFolderName, + default: folder.name }).then(({ canceled, result: name }) => { if (canceled) return; os.api('drive/folders/update', { @@ -359,14 +354,14 @@ export default defineComponent({ }).catch(err => { switch(err.id) { case 'b0fc8a17-963c-405d-bfbc-859a487295e1': - os.dialog({ + os.alert({ type: 'error', title: this.$ts.unableToDelete, text: this.$ts.hasChildFilesOrFolders }); break; default: - os.dialog({ + os.alert({ type: 'error', text: this.$ts.unableToDelete }); diff --git a/packages/client/src/components/follow-button.vue b/packages/client/src/components/follow-button.vue index a96899027..ab19c6476 100644 --- a/packages/client/src/components/follow-button.vue +++ b/packages/client/src/components/follow-button.vue @@ -94,10 +94,9 @@ export default defineComponent({ try { if (this.isFollowing) { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'warning', text: this.$t('unfollowConfirm', { name: this.user.name || this.user.username }), - showCancelButton: true }); if (canceled) return; diff --git a/packages/client/src/components/note-detailed.vue b/packages/client/src/components/note-detailed.vue index 3b5b12a60..55e0fb861 100644 --- a/packages/client/src/components/note-detailed.vue +++ b/packages/client/src/components/note-detailed.vue @@ -456,18 +456,18 @@ export default defineComponent({ os.apiWithDialog('notes/create', { renoteId: this.appearNote.id }, undefined, (res: any) => { - os.dialog({ + os.alert({ type: 'success', text: this.$ts.renoted, }); }, (e: Error) => { if (e.id === 'b5c90186-4ab0-49c8-9bba-a1f76c282ba4') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.cantRenote, }); } else if (e.id === 'fd4cc33e-2a37-48dd-99cc-9b806eb2031a') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.cantReRenote, }); @@ -508,18 +508,18 @@ export default defineComponent({ os.apiWithDialog('notes/favorites/create', { noteId: this.appearNote.id }, undefined, (res: any) => { - os.dialog({ + os.alert({ type: 'success', text: this.$ts.favorited, }); }, (e: Error) => { if (e.id === 'a402c12b-34dd-41d2-97d8-4d2ffd96a1a6') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.alreadyFavorited, }); } else if (e.id === '6dd26674-e060-4816-909a-45ba3f4da458') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.cantFavorite, }); @@ -528,10 +528,9 @@ export default defineComponent({ }, del() { - os.dialog({ + os.confirm({ type: 'warning', text: this.$ts.noteDeleteConfirm, - showCancelButton: true }).then(({ canceled }) => { if (canceled) return; @@ -542,10 +541,9 @@ export default defineComponent({ }, delEdit() { - os.dialog({ + os.confirm({ type: 'warning', text: this.$ts.deleteAndEditConfirm, - showCancelButton: true }).then(({ canceled }) => { if (canceled) return; @@ -781,7 +779,7 @@ export default defineComponent({ noteId: this.appearNote.id }, undefined, null, e => { if (e.id === '72dab508-c64d-498f-8740-a8eec1ba385a') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.pinLimitExceeded }); @@ -828,9 +826,8 @@ export default defineComponent({ }, async promote() { - const { canceled, result: days } = await os.dialog({ + const { canceled, result: days } = await os.inputNumber({ title: this.$ts.numberOfDays, - input: { type: 'number' } }); if (canceled) return; diff --git a/packages/client/src/components/note.vue b/packages/client/src/components/note.vue index 2ab769db4..a948ca2e4 100644 --- a/packages/client/src/components/note.vue +++ b/packages/client/src/components/note.vue @@ -432,18 +432,18 @@ export default defineComponent({ os.apiWithDialog('notes/create', { renoteId: this.appearNote.id }, undefined, (res: any) => { - os.dialog({ + os.alert({ type: 'success', text: this.$ts.renoted, }); }, (e: Error) => { if (e.id === 'b5c90186-4ab0-49c8-9bba-a1f76c282ba4') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.cantRenote, }); } else if (e.id === 'fd4cc33e-2a37-48dd-99cc-9b806eb2031a') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.cantReRenote, }); @@ -484,18 +484,18 @@ export default defineComponent({ os.apiWithDialog('notes/favorites/create', { noteId: this.appearNote.id }, undefined, (res: any) => { - os.dialog({ + os.alert({ type: 'success', text: this.$ts.favorited, }); }, (e: Error) => { if (e.id === 'a402c12b-34dd-41d2-97d8-4d2ffd96a1a6') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.alreadyFavorited, }); } else if (e.id === '6dd26674-e060-4816-909a-45ba3f4da458') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.cantFavorite, }); @@ -504,10 +504,9 @@ export default defineComponent({ }, del() { - os.dialog({ + os.confirm({ type: 'warning', text: this.$ts.noteDeleteConfirm, - showCancelButton: true }).then(({ canceled }) => { if (canceled) return; @@ -518,10 +517,9 @@ export default defineComponent({ }, delEdit() { - os.dialog({ + os.confirm({ type: 'warning', text: this.$ts.deleteAndEditConfirm, - showCancelButton: true }).then(({ canceled }) => { if (canceled) return; @@ -757,7 +755,7 @@ export default defineComponent({ noteId: this.appearNote.id }, undefined, null, e => { if (e.id === '72dab508-c64d-498f-8740-a8eec1ba385a') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.pinLimitExceeded }); @@ -804,9 +802,8 @@ export default defineComponent({ }, async promote() { - const { canceled, result: days } = await os.dialog({ + const { canceled, result: days } = await os.inputNumber({ title: this.$ts.numberOfDays, - input: { type: 'number' } }); if (canceled) return; diff --git a/packages/client/src/components/page/page.button.vue b/packages/client/src/components/page/page.button.vue index 51da84bd4..d6fa42bd5 100644 --- a/packages/client/src/components/page/page.button.vue +++ b/packages/client/src/components/page/page.button.vue @@ -29,7 +29,7 @@ export default defineComponent({ click() { if (this.block.action === 'dialog') { this.hpml.eval(); - os.dialog({ + os.alert({ text: this.hpml.interpolate(this.block.content) }); } else if (this.block.action === 'resetRandom') { @@ -44,7 +44,7 @@ export default defineComponent({ } : {}) }); - os.dialog({ + os.alert({ type: 'success', text: this.hpml.interpolate(this.block.message) }); diff --git a/packages/client/src/components/page/page.vue b/packages/client/src/components/page/page.vue index 6d1c419a4..cd81b16c5 100644 --- a/packages/client/src/components/page/page.vue +++ b/packages/client/src/components/page/page.vue @@ -40,7 +40,7 @@ export default defineComponent({ ast = parse(props.page.script); } catch (e) { console.error(e); - /*os.dialog({ + /*os.alert({ type: 'error', text: 'Syntax error :(' });*/ @@ -50,7 +50,7 @@ export default defineComponent({ hpml.eval(); }).catch(e => { console.error(e); - /*os.dialog({ + /*os.alert({ type: 'error', text: e });*/ diff --git a/packages/client/src/components/post-form-attaches.vue b/packages/client/src/components/post-form-attaches.vue index dff0dec21..23ccd54dd 100644 --- a/packages/client/src/components/post-form-attaches.vue +++ b/packages/client/src/components/post-form-attaches.vue @@ -73,11 +73,9 @@ export default defineComponent({ }); }, async rename(file) { - const { canceled, result } = await os.dialog({ + const { canceled, result } = await os.inputText({ title: this.$ts.enterFileName, - input: { - default: file.name - }, + default: file.name, allowEmpty: false }); if (canceled) return; diff --git a/packages/client/src/components/post-form.vue b/packages/client/src/components/post-form.vue index 882a71a37..88b88e17e 100644 --- a/packages/client/src/components/post-form.vue +++ b/packages/client/src/components/post-form.vue @@ -554,10 +554,9 @@ export default defineComponent({ if (!this.renote && !this.quoteId && paste.startsWith(url + '/notes/')) { e.preventDefault(); - os.dialog({ + os.confirm({ type: 'info', text: this.$ts.quoteQuestion, - showCancelButton: true }).then(({ canceled }) => { if (canceled) { insertTextAtCursor(this.$refs.text, paste); @@ -676,7 +675,7 @@ export default defineComponent({ }); }).catch(err => { this.posting = false; - os.dialog({ + os.alert({ type: 'error', text: err.message + '\n' + (err as any).id, }); diff --git a/packages/client/src/components/sample.vue b/packages/client/src/components/sample.vue index ba6c682c4..03ad6a983 100644 --- a/packages/client/src/components/sample.vue +++ b/packages/client/src/components/sample.vue @@ -57,7 +57,7 @@ export default defineComponent({ methods: { async openDialog() { - os.dialog({ + os.alert({ type: 'warning', title: 'Oh my Aichan', text: 'Lorem ipsum dolor sit amet, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', diff --git a/packages/client/src/components/signin.vue b/packages/client/src/components/signin.vue index 68bbd5368..ef299090f 100644 --- a/packages/client/src/components/signin.vue +++ b/packages/client/src/components/signin.vue @@ -150,7 +150,7 @@ export default defineComponent({ return this.onLogin(res); }).catch(err => { if (err === null) return; - os.dialog({ + os.alert({ type: 'error', text: this.$ts.signinFailed }); @@ -190,7 +190,7 @@ export default defineComponent({ loginFailed(err) { switch (err.id) { case '6cc579cc-885d-43d8-95c2-b8c7fc963280': { - os.dialog({ + os.alert({ type: 'error', title: this.$ts.loginFailed, text: this.$ts.noSuchUser @@ -202,7 +202,7 @@ export default defineComponent({ break; } default: { - os.dialog({ + os.alert({ type: 'error', title: this.$ts.loginFailed, text: JSON.stringify(err) diff --git a/packages/client/src/components/signup.vue b/packages/client/src/components/signup.vue index 621f30486..0572fdaa7 100644 --- a/packages/client/src/components/signup.vue +++ b/packages/client/src/components/signup.vue @@ -220,7 +220,7 @@ export default defineComponent({ 'g-recaptcha-response': this.reCaptchaResponse, }).then(() => { if (this.meta.emailRequiredForSignup) { - os.dialog({ + os.alert({ type: 'success', title: this.$ts._signup.almostThere, text: this.$t('_signup.emailSent', { email: this.email }), @@ -243,7 +243,7 @@ export default defineComponent({ this.$refs.hcaptcha?.reset?.(); this.$refs.recaptcha?.reset?.(); - os.dialog({ + os.alert({ type: 'error', text: this.$ts.somethingHappened }); diff --git a/packages/client/src/os.ts b/packages/client/src/os.ts index a570ffc9e..4f547ba5a 100644 --- a/packages/client/src/os.ts +++ b/packages/client/src/os.ts @@ -214,13 +214,141 @@ export function modalPageWindow(path: string) { }, {}, 'closed'); } -export function dialog(props: { - type: 'error' | 'info' | 'success' | 'warning' | 'waiting'; +export function alert(props: { + type?: 'error' | 'info' | 'success' | 'warning' | 'waiting' | 'question'; title?: string | null; text?: string | null; -}) { +}): Promise { return new Promise((resolve, reject) => { popup(import('@/components/dialog.vue'), props, { + done: result => { + resolve(); + }, + }, 'closed'); + }); +} + +export function confirm(props: { + type: 'error' | 'info' | 'success' | 'warning' | 'waiting' | 'question'; + title?: string | null; + text?: string | null; +}): Promise<{ canceled: boolean }> { + return new Promise((resolve, reject) => { + popup(import('@/components/dialog.vue'), { + ...props, + showCancelButton: true, + }, { + done: result => { + resolve(result ? result : { canceled: true }); + }, + }, 'closed'); + }); +} + +export function inputText(props: { + type?: 'text' | 'email' | 'password' | 'url'; + title?: string | null; + text?: string | null; + placeholder?: string | null; + default?: string | null; +}): Promise<{ canceled: true; result: undefined; } | { + canceled: false; result: string; +}> { + return new Promise((resolve, reject) => { + popup(import('@/components/dialog.vue'), { + title: props.title, + text: props.text, + input: { + type: props.type, + placeholder: props.placeholder, + default: props.default, + } + }, { + done: result => { + resolve(result ? result : { canceled: true }); + }, + }, 'closed'); + }); +} + +export function inputNumber(props: { + title?: string | null; + text?: string | null; + placeholder?: string | null; + default?: number | null; +}): Promise<{ canceled: true; result: undefined; } | { + canceled: false; result: number; +}> { + return new Promise((resolve, reject) => { + popup(import('@/components/dialog.vue'), { + title: props.title, + text: props.text, + input: { + type: 'number', + placeholder: props.placeholder, + default: props.default, + } + }, { + done: result => { + resolve(result ? result : { canceled: true }); + }, + }, 'closed'); + }); +} + +export function inputDate(props: { + title?: string | null; + text?: string | null; + placeholder?: string | null; + default?: Date | null; +}): Promise<{ canceled: true; result: undefined; } | { + canceled: false; result: Date; +}> { + return new Promise((resolve, reject) => { + popup(import('@/components/dialog.vue'), { + title: props.title, + text: props.text, + input: { + type: 'date', + placeholder: props.placeholder, + default: props.default, + } + }, { + done: result => { + resolve(result ? { result: new Date(result.result), canceled: false } : { canceled: true }); + }, + }, 'closed'); + }); +} + +export function select(props: { + title?: string | null; + text?: string | null; + default?: string | null; + items?: { + value: string; + text: string; + }[]; + groupedItems?: { + label: string; + items: { + value: string; + text: string; + }[]; + }[]; +}): Promise<{ canceled: true; result: undefined; } | { + canceled: false; result: string; +}> { + return new Promise((resolve, reject) => { + popup(import('@/components/dialog.vue'), { + title: props.title, + text: props.text, + select: { + items: props.items, + groupedItems: props.groupedItems, + default: props.default, + } + }, { done: result => { resolve(result ? result : { canceled: true }); }, diff --git a/packages/client/src/pages/admin/ads.vue b/packages/client/src/pages/admin/ads.vue index df6c9d5d0..5652080cd 100644 --- a/packages/client/src/pages/admin/ads.vue +++ b/packages/client/src/pages/admin/ads.vue @@ -101,10 +101,9 @@ export default defineComponent({ }, remove(ad) { - os.dialog({ + os.confirm({ type: 'warning', text: this.$t('removeAreYouSure', { x: ad.url }), - showCancelButton: true }).then(({ canceled }) => { if (canceled) return; this.ads = this.ads.filter(x => x != ad); diff --git a/packages/client/src/pages/admin/announcements.vue b/packages/client/src/pages/admin/announcements.vue index a64008967..301b0f9f5 100644 --- a/packages/client/src/pages/admin/announcements.vue +++ b/packages/client/src/pages/admin/announcements.vue @@ -76,10 +76,9 @@ export default defineComponent({ }, remove(announcement) { - os.dialog({ + os.confirm({ type: 'warning', text: this.$t('removeAreYouSure', { x: announcement.title }), - showCancelButton: true }).then(({ canceled }) => { if (canceled) return; this.announcements = this.announcements.filter(x => x != announcement); @@ -90,24 +89,24 @@ export default defineComponent({ save(announcement) { if (announcement.id == null) { os.api('admin/announcements/create', announcement).then(() => { - os.dialog({ + os.alert({ type: 'success', text: this.$ts.saved }); }).catch(e => { - os.dialog({ + os.alert({ type: 'error', text: e }); }); } else { os.api('admin/announcements/update', announcement).then(() => { - os.dialog({ + os.alert({ type: 'success', text: this.$ts.saved }); }).catch(e => { - os.dialog({ + os.alert({ type: 'error', text: e }); diff --git a/packages/client/src/pages/admin/email-settings.vue b/packages/client/src/pages/admin/email-settings.vue index 3733f53a2..aad971830 100644 --- a/packages/client/src/pages/admin/email-settings.vue +++ b/packages/client/src/pages/admin/email-settings.vue @@ -96,11 +96,10 @@ export default defineComponent({ }, async testEmail() { - const { canceled, result: destination } = await os.dialog({ + const { canceled, result: destination } = await os.inputText({ title: this.$ts.destination, - input: { - placeholder: this.$instance.maintainerEmail - } + type: 'email', + placeholder: this.$instance.maintainerEmail }); if (canceled) return; os.apiWithDialog('admin/send-email', { diff --git a/packages/client/src/pages/admin/emoji-edit-dialog.vue b/packages/client/src/pages/admin/emoji-edit-dialog.vue index e61285510..dcc5a9cbe 100644 --- a/packages/client/src/pages/admin/emoji-edit-dialog.vue +++ b/packages/client/src/pages/admin/emoji-edit-dialog.vue @@ -89,10 +89,9 @@ export default defineComponent({ }, async del() { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'warning', text: this.$t('removeAreYouSure', { x: this.emoji.name }), - showCancelButton: true }); if (canceled) return; diff --git a/packages/client/src/pages/admin/file-dialog.vue b/packages/client/src/pages/admin/file-dialog.vue index 016a012ea..0d3627655 100644 --- a/packages/client/src/pages/admin/file-dialog.vue +++ b/packages/client/src/pages/admin/file-dialog.vue @@ -86,10 +86,9 @@ export default defineComponent({ }, async del() { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'warning', text: this.$t('removeAreYouSure', { x: this.file.name }), - showCancelButton: true }); if (canceled) return; diff --git a/packages/client/src/pages/admin/files.vue b/packages/client/src/pages/admin/files.vue index e291d97bb..30bef1335 100644 --- a/packages/client/src/pages/admin/files.vue +++ b/packages/client/src/pages/admin/files.vue @@ -124,10 +124,9 @@ export default defineComponent({ methods: { clear() { - os.dialog({ + os.confirm({ type: 'warning', text: this.$ts.clearCachedFilesConfirm, - showCancelButton: true }).then(({ canceled }) => { if (canceled) return; @@ -146,7 +145,7 @@ export default defineComponent({ this.show(file); }).catch(e => { if (e.code === 'NO_SUCH_FILE') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.notFound }); diff --git a/packages/client/src/pages/admin/index.vue b/packages/client/src/pages/admin/index.vue index d3f9406db..24ca2f65f 100644 --- a/packages/client/src/pages/admin/index.vue +++ b/packages/client/src/pages/admin/index.vue @@ -281,12 +281,12 @@ export default defineComponent({ const invite = () => { os.api('admin/invite').then(x => { - os.dialog({ + os.alert({ type: 'info', text: x.code }); }).catch(e => { - os.dialog({ + os.alert({ type: 'error', text: e }); diff --git a/packages/client/src/pages/admin/queue.vue b/packages/client/src/pages/admin/queue.vue index 896298840..0886216c7 100644 --- a/packages/client/src/pages/admin/queue.vue +++ b/packages/client/src/pages/admin/queue.vue @@ -57,11 +57,10 @@ export default defineComponent({ methods: { clear() { - os.dialog({ + os.confirm({ type: 'warning', title: this.$ts.clearQueueConfirmTitle, text: this.$ts.clearQueueConfirmText, - showCancelButton: true }).then(({ canceled }) => { if (canceled) return; diff --git a/packages/client/src/pages/admin/relays.vue b/packages/client/src/pages/admin/relays.vue index fd0ce97d5..f4cfc2a88 100644 --- a/packages/client/src/pages/admin/relays.vue +++ b/packages/client/src/pages/admin/relays.vue @@ -53,11 +53,10 @@ export default defineComponent({ methods: { async addRelay() { - const { canceled, result: inbox } = await os.dialog({ + const { canceled, result: inbox } = await os.inputText({ title: this.$ts.addRelay, - input: { - placeholder: this.$ts.inboxUrl - } + type: 'url', + placeholder: this.$ts.inboxUrl }); if (canceled) return; os.api('admin/relays/add', { @@ -65,7 +64,7 @@ export default defineComponent({ }).then((relay: any) => { this.refresh(); }).catch((e: any) => { - os.dialog({ + os.alert({ type: 'error', text: e.message || e }); @@ -78,7 +77,7 @@ export default defineComponent({ }).then(() => { this.refresh(); }).catch((e: any) => { - os.dialog({ + os.alert({ type: 'error', text: e.message || e }); diff --git a/packages/client/src/pages/admin/users.vue b/packages/client/src/pages/admin/users.vue index f4a2ffa6d..3c43c7aa3 100644 --- a/packages/client/src/pages/admin/users.vue +++ b/packages/client/src/pages/admin/users.vue @@ -150,15 +150,14 @@ export default defineComponent({ }, async addUser() { - const { canceled: canceled1, result: username } = await os.dialog({ + const { canceled: canceled1, result: username } = await os.inputText({ title: this.$ts.username, - input: true }); if (canceled1) return; - const { canceled: canceled2, result: password } = await os.dialog({ + const { canceled: canceled2, result: password } = await os.inputText({ title: this.$ts.password, - input: { type: 'password' } + type: 'password' }); if (canceled2) return; diff --git a/packages/client/src/pages/advanced-theme-editor.vue b/packages/client/src/pages/advanced-theme-editor.vue index eebfc21b3..122c7821b 100644 --- a/packages/client/src/pages/advanced-theme-editor.vue +++ b/packages/client/src/pages/advanced-theme-editor.vue @@ -175,10 +175,9 @@ export default defineComponent({ }, async confirm(): Promise { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'warning', text: this.$ts.leaveConfirm, - showCancelButton: true }); return !canceled; }, @@ -192,9 +191,8 @@ export default defineComponent({ }, async del(i: number) { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'warning', - showCancelButton: true, text: this.$t('_theme.deleteConstantConfirm', { const: this.theme[i][0] }), }); if (canceled) return; @@ -202,9 +200,8 @@ export default defineComponent({ }, async addConst() { - const { canceled, result } = await os.dialog({ + const { canceled, result } = await os.inputText({ title: this.$ts._theme.inputConstantName, - input: true }); if (canceled) return; this.theme.push([ '$' + result, '#000000']); @@ -213,7 +210,7 @@ export default defineComponent({ save() { const theme = convertToMisskeyTheme(this.theme, this.name, this.description, this.author, this.baseTheme); addTheme(theme); - os.dialog({ + os.alert({ type: 'success', text: this.$t('_theme.installed', { name: theme.name }) }); @@ -225,7 +222,7 @@ export default defineComponent({ try { applyTheme(theme, false); } catch (e) { - os.dialog({ + os.alert({ type: 'error', text: e.message }); @@ -246,7 +243,7 @@ export default defineComponent({ this.theme = convertToViewModel(theme); this.themeToImport = ''; } catch (e) { - os.dialog({ + os.alert({ type: 'error', text: e.message }); diff --git a/packages/client/src/pages/antenna-timeline.vue b/packages/client/src/pages/antenna-timeline.vue index f7f6990fa..a874ca602 100644 --- a/packages/client/src/pages/antenna-timeline.vue +++ b/packages/client/src/pages/antenna-timeline.vue @@ -93,15 +93,12 @@ export default defineComponent({ }, async timetravel() { - const { canceled, result: date } = await os.dialog({ + const { canceled, result: date } = await os.inputDate({ title: this.$ts.date, - input: { - type: 'date' - } }); if (canceled) return; - this.$refs.tl.timetravel(new Date(date)); + this.$refs.tl.timetravel(date); }, settings() { diff --git a/packages/client/src/pages/clip.vue b/packages/client/src/pages/clip.vue index 510a73ce6..dc7abf36b 100644 --- a/packages/client/src/pages/clip.vue +++ b/packages/client/src/pages/clip.vue @@ -114,10 +114,9 @@ export default defineComponent({ text: this.$ts.delete, danger: true, action: async () => { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'warning', text: this.$t('deleteAreYouSure', { x: this.clip.name }), - showCancelButton: true }); if (canceled) return; diff --git a/packages/client/src/pages/follow.vue b/packages/client/src/pages/follow.vue index e8eaad73b..d8a6824dc 100644 --- a/packages/client/src/pages/follow.vue +++ b/packages/client/src/pages/follow.vue @@ -25,7 +25,7 @@ export default defineComponent({ } else if (res.type === 'Note') { this.$router.push(`/notes/${res.object.id}`); } else { - os.dialog({ + os.alert({ type: 'error', text: 'Not a user' }).then(() => { @@ -45,10 +45,9 @@ export default defineComponent({ methods: { async follow(user) { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'question', text: this.$t('followConfirm', { name: user.name || user.username }), - showCancelButton: true }); if (canceled) { diff --git a/packages/client/src/pages/gallery/edit.vue b/packages/client/src/pages/gallery/edit.vue index 1ee3a9390..b34928713 100644 --- a/packages/client/src/pages/gallery/edit.vue +++ b/packages/client/src/pages/gallery/edit.vue @@ -126,10 +126,9 @@ export default defineComponent({ }, async del() { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'warning', text: this.$ts.deleteConfirm, - showCancelButton: true }); if (canceled) return; await os.apiWithDialog('gallery/posts/delete', { diff --git a/packages/client/src/pages/gallery/post.vue b/packages/client/src/pages/gallery/post.vue index 255954def..531ecda8d 100644 --- a/packages/client/src/pages/gallery/post.vue +++ b/packages/client/src/pages/gallery/post.vue @@ -148,9 +148,8 @@ export default defineComponent({ }, async unlike() { - const confirm = await os.dialog({ + const confirm = await os.confirm({ type: 'warning', - showCancelButton: true, text: this.$ts.unlikeConfirm, }); if (confirm.canceled) return; diff --git a/packages/client/src/pages/messaging/index.vue b/packages/client/src/pages/messaging/index.vue index 896c3927c..d0a02aa44 100644 --- a/packages/client/src/pages/messaging/index.vue +++ b/packages/client/src/pages/messaging/index.vue @@ -140,22 +140,18 @@ export default defineComponent({ const groups1 = await os.api('users/groups/owned'); const groups2 = await os.api('users/groups/joined'); if (groups1.length === 0 && groups2.length === 0) { - os.dialog({ + os.alert({ type: 'warning', title: this.$ts.youHaveNoGroups, text: this.$ts.joinOrCreateGroup, }); return; } - const { canceled, result: group } = await os.dialog({ - type: null, + const { canceled, result: group } = await os.select({ title: this.$ts.group, - select: { - items: groups1.concat(groups2).map(group => ({ - value: group, text: group.name - })) - }, - showCancelButton: true + items: groups1.concat(groups2).map(group => ({ + value: group, text: group.name + })) }); if (canceled) return; this.$router.push(`/my/messaging/group/${group.id}`); diff --git a/packages/client/src/pages/messaging/messaging-room.form.vue b/packages/client/src/pages/messaging/messaging-room.form.vue index aafed2632..d378fc186 100644 --- a/packages/client/src/pages/messaging/messaging-room.form.vue +++ b/packages/client/src/pages/messaging/messaging-room.form.vue @@ -95,20 +95,11 @@ export default defineComponent({ const lio = file.name.lastIndexOf('.'); const ext = lio >= 0 ? file.name.slice(lio) : ''; const formatted = `${formatTimeString(new Date(file.lastModified), this.$store.state.pastedFileName).replace(/{{number}}/g, '1')}${ext}`; - const name = this.$store.state.pasteDialog - ? await os.dialog({ - title: this.$ts.enterFileName, - input: { - default: formatted - }, - allowEmpty: false - }).then(({ canceled, result }) => canceled ? false : result) - : formatted; - if (name) this.upload(file, name); + if (formatted) this.upload(file, formatted); } } else { if (items[0].kind == 'file') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.onlyOneFileCanBeAttached }); @@ -133,7 +124,7 @@ export default defineComponent({ return; } else if (e.dataTransfer.files.length > 1) { e.preventDefault(); - os.dialog({ + os.alert({ type: 'error', text: this.$ts.onlyOneFileCanBeAttached }); diff --git a/packages/client/src/pages/messaging/messaging-room.vue b/packages/client/src/pages/messaging/messaging-room.vue index 3a19b1276..d71e415c8 100644 --- a/packages/client/src/pages/messaging/messaging-room.vue +++ b/packages/client/src/pages/messaging/messaging-room.vue @@ -182,7 +182,7 @@ const Component = defineComponent({ this.form.upload(e.dataTransfer.files[0]); return; } else if (e.dataTransfer.files.length > 1) { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.onlyOneFileCanBeAttached }); diff --git a/packages/client/src/pages/my-antennas/editor.vue b/packages/client/src/pages/my-antennas/editor.vue index 5ad3d5048..bf3ed25b4 100644 --- a/packages/client/src/pages/my-antennas/editor.vue +++ b/packages/client/src/pages/my-antennas/editor.vue @@ -150,10 +150,9 @@ export default defineComponent({ }, async deleteAntenna() { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'warning', text: this.$t('removeAreYouSure', { x: this.antenna.name }), - showCancelButton: true }); if (canceled) return; diff --git a/packages/client/src/pages/my-groups/group.vue b/packages/client/src/pages/my-groups/group.vue index 9548c374d..b79e1cb49 100644 --- a/packages/client/src/pages/my-groups/group.vue +++ b/packages/client/src/pages/my-groups/group.vue @@ -106,11 +106,9 @@ export default defineComponent({ }, async renameGroup() { - const { canceled, result: name } = await os.dialog({ + const { canceled, result: name } = await os.inputText({ title: this.$ts.groupName, - input: { - default: this.group.name - } + default: this.group.name }); if (canceled) return; @@ -132,10 +130,9 @@ export default defineComponent({ }, async deleteGroup() { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'warning', text: this.$t('removeAreYouSure', { x: this.group.name }), - showCancelButton: true }); if (canceled) return; diff --git a/packages/client/src/pages/my-groups/index.vue b/packages/client/src/pages/my-groups/index.vue index 77e7d6088..1c66eb14d 100644 --- a/packages/client/src/pages/my-groups/index.vue +++ b/packages/client/src/pages/my-groups/index.vue @@ -88,9 +88,8 @@ export default defineComponent({ methods: { async create() { - const { canceled, result: name } = await os.dialog({ + const { canceled, result: name } = await os.inputText({ title: this.$ts.groupName, - input: true }); if (canceled) return; await os.api('users/groups/create', { name: name }); diff --git a/packages/client/src/pages/my-lists/index.vue b/packages/client/src/pages/my-lists/index.vue index adb59db66..a1b0fee31 100644 --- a/packages/client/src/pages/my-lists/index.vue +++ b/packages/client/src/pages/my-lists/index.vue @@ -46,9 +46,8 @@ export default defineComponent({ methods: { async create() { - const { canceled, result: name } = await os.dialog({ + const { canceled, result: name } = await os.inputText({ title: this.$ts.enterListName, - input: true }); if (canceled) return; await os.api('users/lists/create', { name: name }); diff --git a/packages/client/src/pages/my-lists/list.vue b/packages/client/src/pages/my-lists/list.vue index f2a02cadc..fd986b409 100644 --- a/packages/client/src/pages/my-lists/list.vue +++ b/packages/client/src/pages/my-lists/list.vue @@ -100,11 +100,9 @@ export default defineComponent({ }, async renameList() { - const { canceled, result: name } = await os.dialog({ + const { canceled, result: name } = await os.inputText({ title: this.$ts.enterListName, - input: { - default: this.list.name - } + default: this.list.name }); if (canceled) return; @@ -117,10 +115,9 @@ export default defineComponent({ }, async deleteList() { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'warning', text: this.$t('removeAreYouSure', { x: this.list.name }), - showCancelButton: true }); if (canceled) return; diff --git a/packages/client/src/pages/page-editor/els/page-editor.el.if.vue b/packages/client/src/pages/page-editor/els/page-editor.el.if.vue index f76d59abe..9a49de846 100644 --- a/packages/client/src/pages/page-editor/els/page-editor.el.if.vue +++ b/packages/client/src/pages/page-editor/els/page-editor.el.if.vue @@ -60,13 +60,9 @@ export default defineComponent({ methods: { async add() { - const { canceled, result: type } = await os.dialog({ - type: null, + const { canceled, result: type } = await os.select({ title: this.$ts._pages.chooseBlock, - select: { - groupedItems: this.getPageBlockList() - }, - showCancelButton: true + groupedItems: this.getPageBlockList() }); if (canceled) return; diff --git a/packages/client/src/pages/page-editor/els/page-editor.el.section.vue b/packages/client/src/pages/page-editor/els/page-editor.el.section.vue index 16e32d840..6be31a39c 100644 --- a/packages/client/src/pages/page-editor/els/page-editor.el.section.vue +++ b/packages/client/src/pages/page-editor/els/page-editor.el.section.vue @@ -57,26 +57,18 @@ export default defineComponent({ methods: { async rename() { - const { canceled, result: title } = await os.dialog({ + const { canceled, result: title } = await os.inputText({ title: 'Enter title', - input: { - type: 'text', - default: this.value.title - }, - showCancelButton: true + default: this.value.title }); if (canceled) return; this.value.title = title; }, async add() { - const { canceled, result: type } = await os.dialog({ - type: null, + const { canceled, result: type } = await os.select({ title: this.$ts._pages.chooseBlock, - select: { - groupedItems: this.getPageBlockList() - }, - showCancelButton: true + groupedItems: this.getPageBlockList() }); if (canceled) return; diff --git a/packages/client/src/pages/page-editor/page-editor.script-block.vue b/packages/client/src/pages/page-editor/page-editor.script-block.vue index 07958c902..610c33ad8 100644 --- a/packages/client/src/pages/page-editor/page-editor.script-block.vue +++ b/packages/client/src/pages/page-editor/page-editor.script-block.vue @@ -212,13 +212,9 @@ export default defineComponent({ methods: { async changeType() { - const { canceled, result: type } = await os.dialog({ - type: null, + const { canceled, result: type } = await os.select({ title: this.$ts._pages.selectType, - select: { - groupedItems: this.getScriptBlockList(this.getExpectedType ? this.getExpectedType() : null) - }, - showCancelButton: true + groupedItems: this.getScriptBlockList(this.getExpectedType ? this.getExpectedType() : null) }); if (canceled) return; this.modelValue.type = type; diff --git a/packages/client/src/pages/page-editor/page-editor.vue b/packages/client/src/pages/page-editor/page-editor.vue index 684b1f8c7..31b1dddef 100644 --- a/packages/client/src/pages/page-editor/page-editor.vue +++ b/packages/client/src/pages/page-editor/page-editor.vue @@ -272,14 +272,14 @@ export default defineComponent({ const onError = err => { if (err.id == '3d81ceae-475f-4600-b2a8-2bc116157532') { if (err.info.param == 'name') { - os.dialog({ + os.alert({ type: 'error', title: this.$ts._pages.invalidNameTitle, text: this.$ts._pages.invalidNameText }); } } else if (err.code == 'NAME_ALREADY_EXISTS') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts._pages.nameAlreadyExists }); @@ -291,7 +291,7 @@ export default defineComponent({ os.api('pages/update', options) .then(page => { this.currentName = this.name.trim(); - os.dialog({ + os.alert({ type: 'success', text: this.$ts._pages.updated }); @@ -301,7 +301,7 @@ export default defineComponent({ .then(page => { this.pageId = page.id; this.currentName = this.name.trim(); - os.dialog({ + os.alert({ type: 'success', text: this.$ts._pages.created }); @@ -311,16 +311,15 @@ export default defineComponent({ }, del() { - os.dialog({ + os.confirm({ type: 'warning', text: this.$t('removeAreYouSure', { x: this.title.trim() }), - showCancelButton: true }).then(({ canceled }) => { if (canceled) return; os.api('pages/delete', { pageId: this.pageId, }).then(() => { - os.dialog({ + os.alert({ type: 'success', text: this.$ts._pages.deleted }); @@ -335,7 +334,7 @@ export default defineComponent({ os.api('pages/create', this.getSaveOptions()).then(page => { this.pageId = page.id; this.currentName = this.name.trim(); - os.dialog({ + os.alert({ type: 'success', text: this.$ts._pages.created }); @@ -344,13 +343,10 @@ export default defineComponent({ }, async add() { - const { canceled, result: type } = await os.dialog({ + const { canceled, result: type } = await os.select({ type: null, title: this.$ts._pages.chooseBlock, - select: { - groupedItems: this.getPageBlockList() - }, - showCancelButton: true + groupedItems: this.getPageBlockList() }); if (canceled) return; @@ -359,19 +355,15 @@ export default defineComponent({ }, async addVariable() { - let { canceled, result: name } = await os.dialog({ + let { canceled, result: name } = await os.inputText({ title: this.$ts._pages.enterVariableName, - input: { - type: 'text', - }, - showCancelButton: true }); if (canceled) return; name = name.trim(); if (this.hpml.isUsedName(name)) { - os.dialog({ + os.alert({ type: 'error', text: this.$ts._pages.variableNameIsAlreadyUsed }); diff --git a/packages/client/src/pages/page.vue b/packages/client/src/pages/page.vue index 1eff1a98c..5cc56e443 100644 --- a/packages/client/src/pages/page.vue +++ b/packages/client/src/pages/page.vue @@ -168,9 +168,8 @@ export default defineComponent({ }, async unlike() { - const confirm = await os.dialog({ + const confirm = await os.confirm({ type: 'warning', - showCancelButton: true, text: this.$ts.unlikeConfirm, }); if (confirm.canceled) return; diff --git a/packages/client/src/pages/room/room.vue b/packages/client/src/pages/room/room.vue index 1671bcd58..926a681e8 100644 --- a/packages/client/src/pages/room/room.vue +++ b/packages/client/src/pages/room/room.vue @@ -137,10 +137,9 @@ export default defineComponent({ beforeRouteLeave(to, from, next) { if (this.changed) { - os.dialog({ + os.confirm({ type: 'warning', text: this.$ts.leaveConfirm, - showCancelButton: true }).then(({ canceled }) => { if (canceled) { next(false); @@ -167,15 +166,11 @@ export default defineComponent({ }, async add() { - const { canceled, result: id } = await os.dialog({ - type: null, + const { canceled, result: id } = await os.select({ title: this.$ts._rooms.addFurniture, - select: { - items: storeItems.map(item => ({ - value: item.id, text: this.$t('_rooms._furnitures.' + item.id) - })) - }, - showCancelButton: true + items: storeItems.map(item => ({ + value: item.id, text: this.$t('_rooms._furnitures.' + item.id) + })) }); if (canceled) return; room.addFurniture(id); @@ -196,7 +191,7 @@ export default defineComponent({ this.changed = false; os.success(); }).catch((e: any) => { - os.dialog({ + os.alert({ type: 'error', text: e.message }); @@ -204,10 +199,9 @@ export default defineComponent({ }, clear() { - os.dialog({ + os.confirm({ type: 'warning', text: this.$ts._rooms.clearConfirm, - showCancelButton: true }).then(({ canceled }) => { if (canceled) return; room.removeAllFurnitures(); diff --git a/packages/client/src/pages/scratchpad.vue b/packages/client/src/pages/scratchpad.vue index c26658cbc..65f6fa07d 100644 --- a/packages/client/src/pages/scratchpad.vue +++ b/packages/client/src/pages/scratchpad.vue @@ -74,9 +74,8 @@ export default defineComponent({ }), { in: (q) => { return new Promise(ok => { - os.dialog({ + os.inputText({ title: q, - input: {} }).then(({ canceled, result: a }) => { ok(a); }); @@ -105,7 +104,7 @@ export default defineComponent({ try { ast = parse(this.code); } catch (e) { - os.dialog({ + os.alert({ type: 'error', text: 'Syntax error :(' }); @@ -114,7 +113,7 @@ export default defineComponent({ try { await aiscript.exec(ast); } catch (e) { - os.dialog({ + os.alert({ type: 'error', text: e }); diff --git a/packages/client/src/pages/settings/2fa.vue b/packages/client/src/pages/settings/2fa.vue index dce217559..67c8b626e 100644 --- a/packages/client/src/pages/settings/2fa.vue +++ b/packages/client/src/pages/settings/2fa.vue @@ -105,11 +105,9 @@ export default defineComponent({ methods: { register() { - os.dialog({ + os.inputText({ title: this.$ts.password, - input: { - type: 'password' - } + type: 'password' }).then(({ canceled, result: password }) => { if (canceled) return; os.api('i/2fa/register', { @@ -121,11 +119,9 @@ export default defineComponent({ }, unregister() { - os.dialog({ + os.inputText({ title: this.$ts.password, - input: { - type: 'password' - } + type: 'password' }).then(({ canceled, result: password }) => { if (canceled) return; os.api('i/2fa/unregister', { @@ -147,7 +143,7 @@ export default defineComponent({ os.success(); this.$i.twoFactorEnabled = true; }).catch(e => { - os.dialog({ + os.alert({ type: 'error', text: e }); @@ -171,11 +167,9 @@ export default defineComponent({ }, unregisterKey(key) { - os.dialog({ + os.inputText({ title: this.$ts.password, - input: { - type: 'password' - } + type: 'password' }).then(({ canceled, result: password }) => { if (canceled) return; return os.api('i/2fa/remove-key', { @@ -191,11 +185,9 @@ export default defineComponent({ }, addSecurityKey() { - os.dialog({ + os.inputText({ title: this.$ts.password, - input: { - type: 'password' - } + type: 'password' }).then(({ canceled, result: password }) => { if (canceled) return; os.api('i/2fa/register-key', { diff --git a/packages/client/src/pages/settings/api.vue b/packages/client/src/pages/settings/api.vue index 1def0189e..b6bff51c7 100644 --- a/packages/client/src/pages/settings/api.vue +++ b/packages/client/src/pages/settings/api.vue @@ -52,7 +52,7 @@ export default defineComponent({ permission: permissions, }); - os.dialog({ + os.alert({ type: 'success', title: this.$ts.token, text: token diff --git a/packages/client/src/pages/settings/custom-css.vue b/packages/client/src/pages/settings/custom-css.vue index 8c878fb08..155956923 100644 --- a/packages/client/src/pages/settings/custom-css.vue +++ b/packages/client/src/pages/settings/custom-css.vue @@ -59,10 +59,9 @@ export default defineComponent({ async apply() { localStorage.setItem('customCss', this.localCustomCss); - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'info', text: this.$ts.reloadToApplySetting, - showCancelButton: true }); if (canceled) return; diff --git a/packages/client/src/pages/settings/deck.vue b/packages/client/src/pages/settings/deck.vue index a96c6cd68..bc82b0ca8 100644 --- a/packages/client/src/pages/settings/deck.vue +++ b/packages/client/src/pages/settings/deck.vue @@ -75,10 +75,9 @@ export default defineComponent({ watch: { async navWindow() { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'info', text: this.$ts.reloadToApplySetting, - showCancelButton: true }); if (canceled) return; @@ -92,11 +91,9 @@ export default defineComponent({ methods: { async setProfile() { - const { canceled, result: name } = await os.dialog({ + const { canceled, result: name } = await os.inputText({ title: this.$ts._deck.profile, - input: { - allowEmpty: false - } + allowEmpty: false }); if (canceled) return; this.profile = name; diff --git a/packages/client/src/pages/settings/delete-account.vue b/packages/client/src/pages/settings/delete-account.vue index 77dc0fe2a..d5ad64893 100644 --- a/packages/client/src/pages/settings/delete-account.vue +++ b/packages/client/src/pages/settings/delete-account.vue @@ -46,19 +46,16 @@ export default defineComponent({ methods: { async deleteAccount() { { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'warning', text: this.$ts.deleteAccountConfirm, - showCancelButton: true }); if (canceled) return; } - const { canceled, result: password } = await os.dialog({ + const { canceled, result: password } = await os.inputText({ title: this.$ts.password, - input: { - type: 'password' - } + type: 'password' }); if (canceled) return; @@ -66,7 +63,7 @@ export default defineComponent({ password: password }); - await os.dialog({ + await os.alert({ title: this.$ts._accountDelete.started, }); diff --git a/packages/client/src/pages/settings/email-address.vue b/packages/client/src/pages/settings/email-address.vue index 476d0c0e1..c2c56ed0a 100644 --- a/packages/client/src/pages/settings/email-address.vue +++ b/packages/client/src/pages/settings/email-address.vue @@ -52,11 +52,9 @@ export default defineComponent({ methods: { save() { - os.dialog({ + os.inputText({ title: this.$ts.password, - input: { - type: 'password' - } + type: 'password' }).then(({ canceled, result: password }) => { if (canceled) return; os.apiWithDialog('i/update-email', { diff --git a/packages/client/src/pages/settings/general.vue b/packages/client/src/pages/settings/general.vue index 8e3dcc3e4..e0fcf7010 100644 --- a/packages/client/src/pages/settings/general.vue +++ b/packages/client/src/pages/settings/general.vue @@ -209,10 +209,9 @@ export default defineComponent({ methods: { async reloadAsk() { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'info', text: this.$ts.reloadToApplySetting, - showCancelButton: true }); if (canceled) return; diff --git a/packages/client/src/pages/settings/import-export.vue b/packages/client/src/pages/settings/import-export.vue index 8923483b9..4cc92adfb 100644 --- a/packages/client/src/pages/settings/import-export.vue +++ b/packages/client/src/pages/settings/import-export.vue @@ -67,12 +67,12 @@ export default defineComponent({ target === 'muting' ? 'i/export-mute' : null, {}) .then(() => { - os.dialog({ + os.alert({ type: 'info', text: this.$ts.exportRequested }); }).catch((e: any) => { - os.dialog({ + os.alert({ type: 'error', text: e.message }); @@ -90,12 +90,12 @@ export default defineComponent({ null, { fileId: file.id }).then(() => { - os.dialog({ + os.alert({ type: 'info', text: this.$ts.importRequested }); }).catch((e: any) => { - os.dialog({ + os.alert({ type: 'error', text: e.message }); diff --git a/packages/client/src/pages/settings/menu.vue b/packages/client/src/pages/settings/menu.vue index e40740a3a..6027910e0 100644 --- a/packages/client/src/pages/settings/menu.vue +++ b/packages/client/src/pages/settings/menu.vue @@ -76,17 +76,13 @@ export default defineComponent({ methods: { async addItem() { const menu = Object.keys(this.menuDef).filter(k => !this.$store.state.menu.includes(k)); - const { canceled, result: item } = await os.dialog({ - type: null, + const { canceled, result: item } = await os.select({ title: this.$ts.addItem, - select: { - items: [...menu.map(k => ({ - value: k, text: this.$ts[this.menuDef[k].title] - })), ...[{ - value: '-', text: this.$ts.divider - }]] - }, - showCancelButton: true + items: [...menu.map(k => ({ + value: k, text: this.$ts[this.menuDef[k].title] + })), ...[{ + value: '-', text: this.$ts.divider + }]] }); if (canceled) return; this.items = [...this.splited, item].join('\n'); @@ -103,7 +99,7 @@ export default defineComponent({ }, async reloadAsk() { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'info', text: this.$ts.reloadToApplySetting, showCancelButton: true diff --git a/packages/client/src/pages/settings/plugin.install.vue b/packages/client/src/pages/settings/plugin.install.vue index 9958f98f5..d79979bc2 100644 --- a/packages/client/src/pages/settings/plugin.install.vue +++ b/packages/client/src/pages/settings/plugin.install.vue @@ -76,7 +76,7 @@ export default defineComponent({ try { ast = parse(this.code); } catch (e) { - os.dialog({ + os.alert({ type: 'error', text: 'Syntax error :(' }); @@ -84,7 +84,7 @@ export default defineComponent({ } const meta = AiScript.collectMetadata(ast); if (meta == null) { - os.dialog({ + os.alert({ type: 'error', text: 'No metadata found :(' }); @@ -92,7 +92,7 @@ export default defineComponent({ } const data = meta.get(null); if (data == null) { - os.dialog({ + os.alert({ type: 'error', text: 'No metadata found :(' }); @@ -100,7 +100,7 @@ export default defineComponent({ } const { name, version, author, description, permissions, config } = data; if (name == null || version == null || author == null) { - os.dialog({ + os.alert({ type: 'error', text: 'Required property not found :(' }); diff --git a/packages/client/src/pages/settings/profile.vue b/packages/client/src/pages/settings/profile.vue index a7ddc6d17..e7d0d9b41 100644 --- a/packages/client/src/pages/settings/profile.vue +++ b/packages/client/src/pages/settings/profile.vue @@ -221,7 +221,7 @@ export default defineComponent({ }).then(i => { os.success(); }).catch(err => { - os.dialog({ + os.alert({ type: 'error', text: err.id }); diff --git a/packages/client/src/pages/settings/reaction.vue b/packages/client/src/pages/settings/reaction.vue index 905a3e495..8878b4149 100644 --- a/packages/client/src/pages/settings/reaction.vue +++ b/packages/client/src/pages/settings/reaction.vue @@ -111,10 +111,9 @@ export default defineComponent({ }, async setDefault() { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'warning', text: this.$ts.resetAreYouSure, - showCancelButton: true }); if (canceled) return; diff --git a/packages/client/src/pages/settings/registry.value.vue b/packages/client/src/pages/settings/registry.value.vue index 36f989dbc..6604cf056 100644 --- a/packages/client/src/pages/settings/registry.value.vue +++ b/packages/client/src/pages/settings/registry.value.vue @@ -110,17 +110,16 @@ export default defineComponent({ try { JSON5.parse(this.valueForEditor); } catch (e) { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.invalidValue }); return; } - os.dialog({ + os.confirm({ type: 'warning', text: this.$ts.saveConfirm, - showCancelButton: true }).then(({ canceled }) => { if (canceled) return; os.apiWithDialog('i/registry/set', { @@ -132,10 +131,9 @@ export default defineComponent({ }, del() { - os.dialog({ + os.confirm({ type: 'warning', text: this.$ts.deleteConfirm, - showCancelButton: true }).then(({ canceled }) => { if (canceled) return; os.apiWithDialog('i/registry/remove', { diff --git a/packages/client/src/pages/settings/security.vue b/packages/client/src/pages/settings/security.vue index 4d81bf1b9..879fd83f7 100644 --- a/packages/client/src/pages/settings/security.vue +++ b/packages/client/src/pages/settings/security.vue @@ -64,32 +64,26 @@ export default defineComponent({ methods: { async change() { - const { canceled: canceled1, result: currentPassword } = await os.dialog({ + const { canceled: canceled1, result: currentPassword } = await os.inputText({ title: this.$ts.currentPassword, - input: { - type: 'password' - } + type: 'password' }); if (canceled1) return; - const { canceled: canceled2, result: newPassword } = await os.dialog({ + const { canceled: canceled2, result: newPassword } = await os.inputText({ title: this.$ts.newPassword, - input: { - type: 'password' - } + type: 'password' }); if (canceled2) return; - const { canceled: canceled3, result: newPassword2 } = await os.dialog({ + const { canceled: canceled3, result: newPassword2 } = await os.inputText({ title: this.$ts.newPasswordRetype, - input: { - type: 'password' - } + type: 'password' }); if (canceled3) return; if (newPassword !== newPassword2) { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.retypedNotMatch }); @@ -103,11 +97,9 @@ export default defineComponent({ }, regenerateToken() { - os.dialog({ + os.inputText({ title: this.$ts.password, - input: { - type: 'password' - } + type: 'password' }).then(({ canceled, result: password }) => { if (canceled) return; os.api('i/regenerate_token', { diff --git a/packages/client/src/pages/settings/theme.install.vue b/packages/client/src/pages/settings/theme.install.vue index 59ad3ad9b..95c6f4c7e 100644 --- a/packages/client/src/pages/settings/theme.install.vue +++ b/packages/client/src/pages/settings/theme.install.vue @@ -62,21 +62,21 @@ export default defineComponent({ try { theme = JSON5.parse(code); } catch (e) { - os.dialog({ + os.alert({ type: 'error', text: this.$ts._theme.invalid }); return false; } if (!validateTheme(theme)) { - os.dialog({ + os.alert({ type: 'error', text: this.$ts._theme.invalid }); return false; } if (getThemes().some(t => t.id === theme.id)) { - os.dialog({ + os.alert({ type: 'info', text: this.$ts._theme.alreadyInstalled }); @@ -95,7 +95,7 @@ export default defineComponent({ const theme = this.parseThemeCode(code); if (!theme) return; await addTheme(theme); - os.dialog({ + os.alert({ type: 'success', text: this.$t('_theme.installed', { name: theme.name }) }); diff --git a/packages/client/src/pages/share.vue b/packages/client/src/pages/share.vue index c0af44fdd..488c432f2 100644 --- a/packages/client/src/pages/share.vue +++ b/packages/client/src/pages/share.vue @@ -154,7 +154,7 @@ export default defineComponent({ } //#endregion } catch (e) { - os.dialog({ + os.alert({ type: 'error', title: e.message, text: e.name diff --git a/packages/client/src/pages/test.vue b/packages/client/src/pages/test.vue index 9dd9ae5e0..d05e00d37 100644 --- a/packages/client/src/pages/test.vue +++ b/packages/client/src/pages/test.vue @@ -202,6 +202,7 @@ export default defineComponent({ methods: { async showDialog() { this.dialogResult = null; + /* this.dialogResult = await os.dialog({ type: this.dialogType, title: this.dialogTitle, @@ -209,7 +210,7 @@ export default defineComponent({ showCancelButton: this.dialogCancel, cancelableByBgClick: this.dialogCancelByBgClick, input: this.dialogInput ? {} : null - }); + });*/ }, async form() { diff --git a/packages/client/src/pages/theme-editor.vue b/packages/client/src/pages/theme-editor.vue index d1a892629..c0bb1bd53 100644 --- a/packages/client/src/pages/theme-editor.vue +++ b/packages/client/src/pages/theme-editor.vue @@ -155,10 +155,9 @@ export default defineComponent({ }, async leaveConfirm(): Promise { - const { canceled } = await os.dialog({ + const { canceled } = await os.confirm({ type: 'warning', text: this.$ts.leaveConfirm, - showCancelButton: true }); return !canceled; }, @@ -205,7 +204,7 @@ export default defineComponent({ try { parsed = JSON5.parse(this.themeCode); } catch (e) { - os.dialog({ + os.alert({ type: 'error', text: this.$ts._theme.invalid }); @@ -216,11 +215,9 @@ export default defineComponent({ }, async saveAs() { - const { canceled, result: name } = await os.dialog({ + const { canceled, result: name } = await os.inputText({ title: this.$ts.name, - input: { - allowEmpty: false - } + allowEmpty: false }); if (canceled) return; @@ -236,7 +233,7 @@ export default defineComponent({ ColdDeviceStorage.set('lightTheme', this.theme); } this.changed = false; - os.dialog({ + os.alert({ type: 'success', text: this.$t('_theme.installed', { name: this.theme.name }) }); diff --git a/packages/client/src/pages/timeline.vue b/packages/client/src/pages/timeline.vue index 911d6f5c6..71e823826 100644 --- a/packages/client/src/pages/timeline.vue +++ b/packages/client/src/pages/timeline.vue @@ -171,15 +171,12 @@ export default defineComponent({ }, async timetravel() { - const { canceled, result: date } = await os.dialog({ + const { canceled, result: date } = await os.inputDate({ title: this.$ts.date, - input: { - type: 'date' - } }); if (canceled) return; - this.$refs.tl.timetravel(new Date(date)); + this.$refs.tl.timetravel(date); }, focus() { diff --git a/packages/client/src/pages/user-info.vue b/packages/client/src/pages/user-info.vue index b77d879a7..28cef97db 100644 --- a/packages/client/src/pages/user-info.vue +++ b/packages/client/src/pages/user-info.vue @@ -171,16 +171,15 @@ export default defineComponent({ userId: this.user.id, }); - os.dialog({ + os.alert({ type: 'success', text: this.$t('newPasswordIs', { password }) }); }, async toggleSilence(v) { - const confirm = await os.dialog({ + const confirm = await os.confirm({ type: 'warning', - showCancelButton: true, text: v ? this.$ts.silenceConfirm : this.$ts.unsilenceConfirm, }); if (confirm.canceled) { @@ -192,9 +191,8 @@ export default defineComponent({ }, async toggleSuspend(v) { - const confirm = await os.dialog({ + const confirm = await os.confirm({ type: 'warning', - showCancelButton: true, text: v ? this.$ts.suspendConfirm : this.$ts.unsuspendConfirm, }); if (confirm.canceled) { @@ -211,9 +209,8 @@ export default defineComponent({ }, async deleteAllFiles() { - const confirm = await os.dialog({ + const confirm = await os.confirm({ type: 'warning', - showCancelButton: true, text: this.$ts.deleteAllFilesConfirm, }); if (confirm.canceled) return; @@ -222,7 +219,7 @@ export default defineComponent({ os.success(); }; await process().catch(e => { - os.dialog({ + os.alert({ type: 'error', text: e.toString() }); diff --git a/packages/client/src/pages/user-list-timeline.vue b/packages/client/src/pages/user-list-timeline.vue index 2fc2476fb..a2773e2d4 100644 --- a/packages/client/src/pages/user-list-timeline.vue +++ b/packages/client/src/pages/user-list-timeline.vue @@ -97,15 +97,12 @@ export default defineComponent({ }, async timetravel() { - const { canceled, result: date } = await os.dialog({ + const { canceled, result: date } = await os.inputDate({ title: this.$ts.date, - input: { - type: 'date' - } }); if (canceled) return; - this.$refs.tl.timetravel(new Date(date)); + this.$refs.tl.timetravel(date); }, focus() { diff --git a/packages/client/src/pages/welcome.setup.vue b/packages/client/src/pages/welcome.setup.vue index 8c88720cf..3dca5b3e7 100644 --- a/packages/client/src/pages/welcome.setup.vue +++ b/packages/client/src/pages/welcome.setup.vue @@ -57,7 +57,7 @@ export default defineComponent({ }).catch(() => { this.submitting = false; - os.dialog({ + os.alert({ type: 'error', text: this.$ts.somethingHappened }); diff --git a/packages/client/src/scripts/aiscript/api.ts b/packages/client/src/scripts/aiscript/api.ts index 20c15d809..01b8fd05f 100644 --- a/packages/client/src/scripts/aiscript/api.ts +++ b/packages/client/src/scripts/aiscript/api.ts @@ -9,16 +9,15 @@ export function createAiScriptEnv(opts) { USER_NAME: $i ? values.STR($i.name) : values.NULL, USER_USERNAME: $i ? values.STR($i.username) : values.NULL, 'Mk:dialog': values.FN_NATIVE(async ([title, text, type]) => { - await os.dialog({ + await os.alert({ type: type ? type.value : 'info', title: title.value, text: text.value, }); }), 'Mk:confirm': values.FN_NATIVE(async ([title, text, type]) => { - const confirm = await os.dialog({ + const confirm = await os.confirm({ type: type ? type.value : 'question', - showCancelButton: true, title: title.value, text: text.value, }); diff --git a/packages/client/src/scripts/get-user-menu.ts b/packages/client/src/scripts/get-user-menu.ts index 8d767afa2..0c0454710 100644 --- a/packages/client/src/scripts/get-user-menu.ts +++ b/packages/client/src/scripts/get-user-menu.ts @@ -14,21 +14,17 @@ export function getUserMenu(user) { const t = i18n.locale.selectList; // なぜか後で参照すると null になるので最初にメモリに確保しておく const lists = await os.api('users/lists/list'); if (lists.length === 0) { - os.dialog({ + os.alert({ type: 'error', text: i18n.locale.youHaveNoLists }); return; } - const { canceled, result: listId } = await os.dialog({ - type: null, + const { canceled, result: listId } = await os.select({ title: t, - select: { - items: lists.map(list => ({ - value: list.id, text: list.name - })) - }, - showCancelButton: true + items: lists.map(list => ({ + value: list.id, text: list.name + })) }); if (canceled) return; os.apiWithDialog('users/lists/push', { @@ -40,21 +36,17 @@ export function getUserMenu(user) { async function inviteGroup() { const groups = await os.api('users/groups/owned'); if (groups.length === 0) { - os.dialog({ + os.alert({ type: 'error', text: i18n.locale.youHaveNoGroups }); return; } - const { canceled, result: groupId } = await os.dialog({ - type: null, + const { canceled, result: groupId } = await os.select({ title: i18n.locale.group, - select: { - items: groups.map(group => ({ - value: group.id, text: group.name - })) - }, - showCancelButton: true + items: groups.map(group => ({ + value: group.id, text: group.name + })) }); if (canceled) return; os.apiWithDialog('users/groups/invite', { @@ -108,9 +100,8 @@ export function getUserMenu(user) { } async function getConfirmed(text: string): Promise { - const confirm = await os.dialog({ + const confirm = await os.confirm({ type: 'warning', - showCancelButton: true, title: 'confirm', text, }); diff --git a/packages/client/src/scripts/hpml/evaluator.ts b/packages/client/src/scripts/hpml/evaluator.ts index 20261d333..6329c0860 100644 --- a/packages/client/src/scripts/hpml/evaluator.ts +++ b/packages/client/src/scripts/hpml/evaluator.ts @@ -39,9 +39,8 @@ export class Hpml { }), ...initAiLib(this)}, { in: (q) => { return new Promise(ok => { - os.dialog({ + os.inputText({ title: q, - input: {} }).then(({ canceled, result: a }) => { ok(a); }); diff --git a/packages/client/src/scripts/lookup-user.ts b/packages/client/src/scripts/lookup-user.ts index 174fa9f87..64874f86f 100644 --- a/packages/client/src/scripts/lookup-user.ts +++ b/packages/client/src/scripts/lookup-user.ts @@ -3,9 +3,8 @@ import { i18n } from '@/i18n'; import * as os from '@/os'; export async function lookupUser() { - const { canceled, result } = await os.dialog({ + const { canceled, result } = await os.inputText({ title: i18n.locale.usernameOrUserId, - input: true }); if (canceled) return; @@ -18,7 +17,7 @@ export async function lookupUser() { let _notFound = false; const notFound = () => { if (_notFound) { - os.dialog({ + os.alert({ type: 'error', text: i18n.locale.noSuchUser }); diff --git a/packages/client/src/scripts/search.ts b/packages/client/src/scripts/search.ts index b28cccfab..a070b1121 100644 --- a/packages/client/src/scripts/search.ts +++ b/packages/client/src/scripts/search.ts @@ -3,9 +3,8 @@ import { i18n } from '@/i18n'; import { router } from '@/router'; export async function search() { - const { canceled, result: query } = await os.dialog({ + const { canceled, result: query } = await os.inputText({ title: i18n.locale.search, - input: true }); if (canceled || query == null || query === '') return; @@ -35,7 +34,7 @@ export async function search() { // TODO //v.$root.$emit('warp', date); - os.dialog({ + os.alert({ icon: 'fas fa-history', iconOnly: true, autoClose: true }); diff --git a/packages/client/src/scripts/select-file.ts b/packages/client/src/scripts/select-file.ts index 5fbc545b2..0c6bd7ccd 100644 --- a/packages/client/src/scripts/select-file.ts +++ b/packages/client/src/scripts/select-file.ts @@ -14,7 +14,7 @@ export function selectFile(src: any, label: string | null, multiple = false) { Promise.all(promises).then(driveFiles => { res(multiple ? driveFiles : driveFiles[0]); }).catch(e => { - os.dialog({ + os.alert({ type: 'error', text: e }); @@ -38,11 +38,10 @@ export function selectFile(src: any, label: string | null, multiple = false) { }; const chooseFileFromUrl = () => { - os.dialog({ + os.inputText({ title: i18n.locale.uploadFromUrl, - input: { - placeholder: i18n.locale.uploadFromUrlDescription - } + type: 'url', + placeholder: i18n.locale.uploadFromUrlDescription }).then(({ canceled, result: url }) => { if (canceled) return; @@ -62,7 +61,7 @@ export function selectFile(src: any, label: string | null, multiple = false) { marker }); - os.dialog({ + os.alert({ title: i18n.locale.uploadFromUrlRequested, text: i18n.locale.uploadFromUrlMayTakeTime }); diff --git a/packages/client/src/scripts/show-suspended-dialog.ts b/packages/client/src/scripts/show-suspended-dialog.ts index 3bc480003..dcbb66933 100644 --- a/packages/client/src/scripts/show-suspended-dialog.ts +++ b/packages/client/src/scripts/show-suspended-dialog.ts @@ -2,7 +2,7 @@ import * as os from '@/os'; import { i18n } from '@/i18n'; export function showSuspendedDialog() { - return os.dialog({ + return os.alert({ type: 'error', title: i18n.locale.yourAccountSuspendedTitle, text: i18n.locale.yourAccountSuspendedDescription diff --git a/packages/client/src/ui/chat/note.vue b/packages/client/src/ui/chat/note.vue index c0b5cebd9..412f47e31 100644 --- a/packages/client/src/ui/chat/note.vue +++ b/packages/client/src/ui/chat/note.vue @@ -459,18 +459,18 @@ export default defineComponent({ os.apiWithDialog('notes/create', { renoteId: this.appearNote.id }, undefined, (res: any) => { - os.dialog({ + os.alert({ type: 'success', text: this.$ts.renoted, }); }, (e: Error) => { if (e.id === 'b5c90186-4ab0-49c8-9bba-a1f76c282ba4') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.cantRenote, }); } else if (e.id === 'fd4cc33e-2a37-48dd-99cc-9b806eb2031a') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.cantReRenote, }); @@ -513,18 +513,18 @@ export default defineComponent({ os.apiWithDialog('notes/favorites/create', { noteId: this.appearNote.id }, undefined, (res: any) => { - os.dialog({ + os.alert({ type: 'success', text: this.$ts.favorited, }); }, (e: Error) => { if (e.id === 'a402c12b-34dd-41d2-97d8-4d2ffd96a1a6') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.alreadyFavorited, }); } else if (e.id === '6dd26674-e060-4816-909a-45ba3f4da458') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.cantFavorite, }); @@ -533,10 +533,9 @@ export default defineComponent({ }, del() { - os.dialog({ + os.confirm({ type: 'warning', text: this.$ts.noteDeleteConfirm, - showCancelButton: true }).then(({ canceled }) => { if (canceled) return; @@ -547,10 +546,9 @@ export default defineComponent({ }, delEdit() { - os.dialog({ + os.confirm({ type: 'warning', text: this.$ts.deleteAndEditConfirm, - showCancelButton: true }).then(({ canceled }) => { if (canceled) return; @@ -770,7 +768,7 @@ export default defineComponent({ noteId: this.appearNote.id }, undefined, null, e => { if (e.id === '72dab508-c64d-498f-8740-a8eec1ba385a') { - os.dialog({ + os.alert({ type: 'error', text: this.$ts.pinLimitExceeded }); @@ -817,9 +815,8 @@ export default defineComponent({ }, async promote() { - const { canceled, result: days } = await os.dialog({ + const { canceled, result: days } = await os.inputNumber({ title: this.$ts.numberOfDays, - input: { type: 'number' } }); if (canceled) return; diff --git a/packages/client/src/ui/chat/pages/channel.vue b/packages/client/src/ui/chat/pages/channel.vue index 5152af20f..f2488347d 100644 --- a/packages/client/src/ui/chat/pages/channel.vue +++ b/packages/client/src/ui/chat/pages/channel.vue @@ -155,9 +155,8 @@ export default defineComponent({ }, async inChannelSearch() { - const { canceled, result: query } = await os.dialog({ + const { canceled, result: query } = await os.inputText({ title: this.$ts.inChannelSearch, - input: true }); if (canceled || query == null || query === '') return; router.push(`/search?q=${encodeURIComponent(query)}&channel=${this.channelId}`); diff --git a/packages/client/src/ui/chat/post-form.vue b/packages/client/src/ui/chat/post-form.vue index 62aa3a6aa..1f272c360 100644 --- a/packages/client/src/ui/chat/post-form.vue +++ b/packages/client/src/ui/chat/post-form.vue @@ -450,10 +450,9 @@ export default defineComponent({ if (!this.renote && !this.quoteId && paste.startsWith(url + '/notes/')) { e.preventDefault(); - os.dialog({ + os.confirm({ type: 'info', text: this.$ts.quoteQuestion, - showCancelButton: true }).then(({ canceled }) => { if (canceled) { insertTextAtCursor(this.$refs.text, paste); @@ -567,7 +566,7 @@ export default defineComponent({ }); }).catch(err => { this.posting = false; - os.dialog({ + os.alert({ type: 'error', text: err.message + '\n' + (err as any).id, }); diff --git a/packages/client/src/ui/deck.vue b/packages/client/src/ui/deck.vue index cc8bf5a51..596d14c5c 100644 --- a/packages/client/src/ui/deck.vue +++ b/packages/client/src/ui/deck.vue @@ -118,15 +118,11 @@ export default defineComponent({ 'direct', ]; - const { canceled, result: column } = await os.dialog({ + const { canceled, result: column } = await os.select({ title: this.$ts._deck.addColumn, - type: null, - select: { - items: columns.map(column => ({ - value: column, text: this.$t('_deck._columns.' + column) - })) - }, - showCancelButton: true + items: columns.map(column => ({ + value: column, text: this.$t('_deck._columns.' + column) + })) }); if (canceled) return; diff --git a/packages/client/src/ui/deck/antenna-column.vue b/packages/client/src/ui/deck/antenna-column.vue index d42b8a5a1..198ebbbef 100644 --- a/packages/client/src/ui/deck/antenna-column.vue +++ b/packages/client/src/ui/deck/antenna-column.vue @@ -52,16 +52,12 @@ export default defineComponent({ methods: { async setAntenna() { const antennas = await os.api('antennas/list'); - const { canceled, result: antenna } = await os.dialog({ + const { canceled, result: antenna } = await os.select({ title: this.$ts.selectAntenna, - type: null, - select: { - items: antennas.map(x => ({ - value: x, text: x.name - })), + items: antennas.map(x => ({ + value: x, text: x.name + })), default: this.column.antennaId - }, - showCancelButton: true }); if (canceled) return; updateColumn(this.column.id, { diff --git a/packages/client/src/ui/deck/list-column.vue b/packages/client/src/ui/deck/list-column.vue index 3ebba8032..ab04aee4e 100644 --- a/packages/client/src/ui/deck/list-column.vue +++ b/packages/client/src/ui/deck/list-column.vue @@ -52,16 +52,12 @@ export default defineComponent({ methods: { async setList() { const lists = await os.api('users/lists/list'); - const { canceled, result: list } = await os.dialog({ + const { canceled, result: list } = await os.select({ title: this.$ts.selectList, - type: null, - select: { - items: lists.map(x => ({ - value: x, text: x.name - })), - default: this.column.listId - }, - showCancelButton: true + items: lists.map(x => ({ + value: x, text: x.name + })), + default: this.column.listId }); if (canceled) return; updateColumn(this.column.id, { diff --git a/packages/client/src/ui/deck/tl-column.vue b/packages/client/src/ui/deck/tl-column.vue index faf692c44..802168833 100644 --- a/packages/client/src/ui/deck/tl-column.vue +++ b/packages/client/src/ui/deck/tl-column.vue @@ -69,20 +69,17 @@ export default defineComponent({ methods: { async setType() { - const { canceled, result: src } = await os.dialog({ + const { canceled, result: src } = await os.select({ title: this.$ts.timeline, - type: null, - select: { - items: [{ - value: 'home', text: this.$ts._timelines.home - }, { - value: 'local', text: this.$ts._timelines.local - }, { - value: 'social', text: this.$ts._timelines.social - }, { - value: 'global', text: this.$ts._timelines.global - }] - }, + items: [{ + value: 'home', text: this.$ts._timelines.home + }, { + value: 'local', text: this.$ts._timelines.local + }, { + value: 'social', text: this.$ts._timelines.social + }, { + value: 'global', text: this.$ts._timelines.global + }] }); if (canceled) { if (this.column.tl == null) { diff --git a/packages/client/src/widgets/aiscript.vue b/packages/client/src/widgets/aiscript.vue index 992ec2f8a..f2ea5e268 100644 --- a/packages/client/src/widgets/aiscript.vue +++ b/packages/client/src/widgets/aiscript.vue @@ -57,9 +57,8 @@ export default defineComponent({ }), { in: (q) => { return new Promise(ok => { - os.dialog({ + os.inputText({ title: q, - input: {} }).then(({ canceled, result: a }) => { ok(a); }); @@ -88,7 +87,7 @@ export default defineComponent({ try { ast = parse(this.props.script); } catch (e) { - os.dialog({ + os.alert({ type: 'error', text: 'Syntax error :(' }); @@ -97,7 +96,7 @@ export default defineComponent({ try { await aiscript.exec(ast); } catch (e) { - os.dialog({ + os.alert({ type: 'error', text: e }); diff --git a/packages/client/src/widgets/button.vue b/packages/client/src/widgets/button.vue index 3417181d0..e98570862 100644 --- a/packages/client/src/widgets/button.vue +++ b/packages/client/src/widgets/button.vue @@ -50,9 +50,8 @@ export default defineComponent({ }), { in: (q) => { return new Promise(ok => { - os.dialog({ + os.inputText({ title: q, - input: {} }).then(({ canceled, result: a }) => { ok(a); }); @@ -70,7 +69,7 @@ export default defineComponent({ try { ast = parse(this.props.script); } catch (e) { - os.dialog({ + os.alert({ type: 'error', text: 'Syntax error :(' }); @@ -79,7 +78,7 @@ export default defineComponent({ try { await aiscript.exec(ast); } catch (e) { - os.dialog({ + os.alert({ type: 'error', text: e }); From 037db7c5ef1cd0c63ed7950e12ee83215a20f362 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 18 Nov 2021 20:12:50 +0900 Subject: [PATCH 12/29] lint: warn non-null-assertion to reduce unexpected behaviour --- packages/backend/.eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/.eslintrc.js b/packages/backend/.eslintrc.js index 0978f8ab4..7e99ef86e 100644 --- a/packages/backend/.eslintrc.js +++ b/packages/backend/.eslintrc.js @@ -63,7 +63,7 @@ module.exports = { '@typescript-eslint/no-var-requires': ['warn'], '@typescript-eslint/no-inferrable-types': ['warn'], '@typescript-eslint/no-empty-function': ['off'], - '@typescript-eslint/no-non-null-assertion': ['off'], + '@typescript-eslint/no-non-null-assertion': ['warn'], '@typescript-eslint/no-misused-promises': ['error', { 'checksVoidReturn': false, }], From 12fad68f58cffbec67b2ed49319c0810d782475a Mon Sep 17 00:00:00 2001 From: Johann150 Date: Thu, 18 Nov 2021 14:11:44 +0100 Subject: [PATCH 13/29] limit depth of reply posts (#7979) * limit depth of reply posts * some tweaks Co-authored-by: syuilo --- locales/ja-JP.yml | 1 + packages/client/src/components/note.sub.vue | 32 ++++++++++++++------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 0dbe35216..9877248eb 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -806,6 +806,7 @@ muteThread: "スレッドをミュート" unmuteThread: "スレッドのミュートを解除" ffVisibility: "つながりの公開範囲" ffVisibilityDescription: "自分のフォロー/フォロワー情報の公開範囲を設定できます。" +continueThread: "さらにスレッドを見る" deleteAccountConfirm: "アカウントが削除されます。よろしいですか?" _emailUnavailable: diff --git a/packages/client/src/components/note.sub.vue b/packages/client/src/components/note.sub.vue index 45204854b..2e3636550 100644 --- a/packages/client/src/components/note.sub.vue +++ b/packages/client/src/components/note.sub.vue @@ -1,5 +1,5 @@ @@ -138,9 +144,13 @@ export default defineComponent({ } } - > .reply { + > .reply, > .more { border-left: solid 0.5px var(--divider); margin-top: 10px; } + + > .more { + padding: 10px 0 0 16px; + } } From c850cef7110313311242bf3e53fa82e6670842e5 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 18 Nov 2021 22:12:17 +0900 Subject: [PATCH 14/29] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e17c3332a..350658881 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ## 12.x.x (unreleased) ### Improvements +- クライアント: 長いスレッドの表示を改善 - クライアント: アカウント削除に確認ダイアログを出すように ### Bugfixes From 73b5c129278bbcc19a95f2c599ac76f68f023c3a Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 18 Nov 2021 23:32:43 +0900 Subject: [PATCH 15/29] introduce lint for client Resolve #7998 --- package.json | 4 +- packages/backend/.eslintrc.js | 66 +-- packages/client/.eslintrc | 32 -- packages/client/.eslintrc.js | 46 ++ packages/client/package.json | 7 +- .../src/components/date-separated-list.vue | 4 - packages/client/src/components/post-form.vue | 7 +- packages/client/src/components/sparkle.vue | 32 +- packages/client/src/components/ui/menu.vue | 8 +- packages/client/src/components/ui/popup.vue | 2 + .../page-editor/els/page-editor.el.button.vue | 2 + .../page-editor/els/page-editor.el.canvas.vue | 2 + .../els/page-editor.el.counter.vue | 2 + .../page-editor/els/page-editor.el.if.vue | 2 + .../page-editor/els/page-editor.el.image.vue | 2 + .../page-editor/els/page-editor.el.note.vue | 2 + .../els/page-editor.el.number-input.vue | 2 + .../page-editor/els/page-editor.el.post.vue | 2 + .../els/page-editor.el.radio-button.vue | 2 + .../els/page-editor.el.section.vue | 2 + .../page-editor/els/page-editor.el.switch.vue | 2 + .../els/page-editor.el.text-input.vue | 2 + .../page-editor/els/page-editor.el.text.vue | 2 + .../els/page-editor.el.textarea-input.vue | 2 + .../els/page-editor.el.textarea.vue | 2 + .../page-editor/page-editor.script-block.vue | 2 + packages/client/src/pages/settings/index.vue | 1 + packages/client/src/pages/settings/theme.vue | 2 +- packages/client/src/pages/share.vue | 2 +- .../client/src/pages/welcome.timeline.vue | 2 +- .../client/src/scripts/reaction-picker.ts | 6 +- .../src/ui/chat/date-separated-list.vue | 6 - packages/client/src/ui/chat/index.vue | 4 - packages/client/src/ui/chat/note.sub.vue | 2 +- packages/client/src/ui/chat/post-form.vue | 2 +- packages/client/src/ui/visitor/kanban.vue | 2 +- packages/client/yarn.lock | 410 +++++++++++++++++- packages/shared/.eslintrc.js | 69 +++ scripts/lint.js | 8 + yarn.lock | 214 ++++++++- 40 files changed, 817 insertions(+), 153 deletions(-) delete mode 100644 packages/client/.eslintrc create mode 100644 packages/client/.eslintrc.js create mode 100644 packages/shared/.eslintrc.js diff --git a/package.json b/package.json index d712e21e2..dd7d36e6e 100644 --- a/package.json +++ b/package.json @@ -46,8 +46,10 @@ "devDependencies": { "@redocly/openapi-core": "1.0.0-beta.54", "@types/fluent-ffmpeg": "2.1.17", + "@typescript-eslint/parser": "5.4.0", "cross-env": "7.0.3", "cypress": "9.0.0", - "start-server-and-test": "1.14.0" + "start-server-and-test": "1.14.0", + "typescript": "4.5.2" } } diff --git a/packages/backend/.eslintrc.js b/packages/backend/.eslintrc.js index 7e99ef86e..e2e31e9e3 100644 --- a/packages/backend/.eslintrc.js +++ b/packages/backend/.eslintrc.js @@ -1,73 +1,9 @@ module.exports = { - root: true, - parser: '@typescript-eslint/parser', parserOptions: { tsconfigRootDir: __dirname, project: ['./tsconfig.json'], }, - plugins: [ - '@typescript-eslint', - 'import' - ], extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:import/recommended', - 'plugin:import/typescript' + '../shared/.eslintrc.js', ], - rules: { - 'indent': ['warn', 'tab', { - 'SwitchCase': 1, - 'MemberExpression': 'off', - 'flatTernaryExpressions': true, - 'ArrayExpression': 'first', - 'ObjectExpression': 'first', - }], - 'eol-last': ['error', 'always'], - 'semi': ['error', 'always'], - 'quotes': ['warn', 'single'], - 'comma-dangle': ['warn', 'always-multiline'], - 'keyword-spacing': ['error', { - 'before': true, - 'after': true, - }], - 'key-spacing': ['error', { - 'beforeColon': false, - 'afterColon': true, - }], - /* TODO: path aliasを使わないとwarnする - 'no-restricted-imports': ['warn', { - 'patterns': [ - ] - }], - */ - 'no-multi-spaces': ['error'], - 'no-var': ['error'], - 'prefer-arrow-callback': ['error'], - 'no-throw-literal': ['warn'], - 'no-param-reassign': ['warn'], - 'no-constant-condition': ['warn'], - 'no-empty-pattern': ['warn'], - 'no-async-promise-executor': ['off'], - 'no-useless-escape': ['off'], - 'no-multi-spaces': ['warn'], - 'no-multiple-empty-lines': ['error', { 'max': 1 }], - 'no-control-regex': ['warn'], - 'no-empty': ['warn'], - 'no-inner-declarations': ['off'], - 'no-sparse-arrays': ['off'], - 'nonblock-statement-body-position': ['error', 'beside'], - 'object-curly-spacing': ['error', 'always'], - 'space-infix-ops': ['error'], - 'space-before-blocks': ['error', 'always'], - '@typescript-eslint/no-var-requires': ['warn'], - '@typescript-eslint/no-inferrable-types': ['warn'], - '@typescript-eslint/no-empty-function': ['off'], - '@typescript-eslint/no-non-null-assertion': ['warn'], - '@typescript-eslint/no-misused-promises': ['error', { - 'checksVoidReturn': false, - }], - 'import/no-unresolved': ['off'], - 'import/no-default-export': ['warn'], - }, }; diff --git a/packages/client/.eslintrc b/packages/client/.eslintrc deleted file mode 100644 index b3b631e1d..000000000 --- a/packages/client/.eslintrc +++ /dev/null @@ -1,32 +0,0 @@ -{ - "env": { - "node": false - }, - "extends": [ - "eslint:recommended", - "plugin:vue/recommended" - ], - "rules": { - "vue/require-v-for-key": 0, - "vue/max-attributes-per-line": 0, - "vue/html-indent": 0, - "vue/html-self-closing": 0, - "vue/no-unused-vars": 0, - "vue/attributes-order": 0, - "vue/require-prop-types": 0, - "vue/require-default-prop": 0, - "vue/html-closing-bracket-spacing": 0, - "vue/singleline-html-element-content-newline": 0, - "vue/no-v-html": 0 - }, - "globals": { - "_DEV_": false, - "_LANGS_": false, - "_VERSION_": false, - "_ENV_": false, - "_PERF_PREFIX_": false, - "_DATA_TRANSFER_DRIVE_FILE_": false, - "_DATA_TRANSFER_DRIVE_FOLDER_": false, - "_DATA_TRANSFER_DECK_COLUMN_": false - } -} diff --git a/packages/client/.eslintrc.js b/packages/client/.eslintrc.js new file mode 100644 index 000000000..18f312a15 --- /dev/null +++ b/packages/client/.eslintrc.js @@ -0,0 +1,46 @@ +module.exports = { + root: true, + env: { + "node": false + }, + parser: "vue-eslint-parser", + parserOptions: { + "parser": "@typescript-eslint/parser", + tsconfigRootDir: __dirname, + //project: ['./tsconfig.json'], + }, + extends: [ + //"../shared/.eslintrc.js", + "plugin:vue/vue3-recommended" + ], + rules: { + "vue/html-indent": ["warn", "tab", { + "attribute": 1, + "baseIndent": 0, + "closeBracket": 0, + "alignAttributesVertically": true, + "ignores": [] + }], + "vue/html-closing-bracket-spacing": ["warn", { + "startTag": "never", + "endTag": "never", + "selfClosingTag": "never" + }], + "vue/multi-word-component-names": "warn", + "vue/require-v-for-key": "warn", + "vue/no-unused-components": "warn", + "vue/valid-v-for": "warn", + "vue/return-in-computed-property": "warn", + }, + globals: { + "require": false, + "_DEV_": false, + "_LANGS_": false, + "_VERSION_": false, + "_ENV_": false, + "_PERF_PREFIX_": false, + "_DATA_TRANSFER_DRIVE_FILE_": false, + "_DATA_TRANSFER_DRIVE_FOLDER_": false, + "_DATA_TRANSFER_DECK_COLUMN_": false + } +} diff --git a/packages/client/package.json b/packages/client/package.json index 57cc51953..911dadcee 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -2,7 +2,8 @@ "private": true, "scripts": { "watch": "webpack --watch", - "build": "webpack" + "build": "webpack", + "lint": "eslint --quiet src/**/*.{ts,vue}" }, "resolutions": { "chokidar": "^3.3.1", @@ -72,7 +73,7 @@ "dateformat": "4.5.1", "escape-regexp": "0.0.1", "eslint": "8.2.0", - "eslint-plugin-vue": "8.0.3", + "eslint-plugin-vue": "8.1.1", "eventemitter3": "4.0.7", "feed": "4.2.2", "glob": "7.2.0", @@ -152,8 +153,10 @@ "devDependencies": { "@redocly/openapi-core": "1.0.0-beta.54", "@types/fluent-ffmpeg": "2.1.17", + "@typescript-eslint/eslint-plugin": "5.4.0", "cross-env": "7.0.3", "cypress": "8.5.0", + "eslint-plugin-import": "2.25.3", "start-server-and-test": "1.14.0" } } diff --git a/packages/client/src/components/date-separated-list.vue b/packages/client/src/components/date-separated-list.vue index 1aea9fd35..aa84c6f60 100644 --- a/packages/client/src/components/date-separated-list.vue +++ b/packages/client/src/components/date-separated-list.vue @@ -31,10 +31,6 @@ export default defineComponent({ }, methods: { - focus() { - this.$slots.default[0].elm.focus(); - }, - getDateText(time: string) { const date = new Date(time).getDate(); const month = new Date(time).getMonth() + 1; diff --git a/packages/client/src/components/post-form.vue b/packages/client/src/components/post-form.vue index 88b88e17e..6cbcc57a7 100644 --- a/packages/client/src/components/post-form.vue +++ b/packages/client/src/components/post-form.vue @@ -128,7 +128,7 @@ export default defineComponent({ type: Boolean, required: false }, - visibleUsers: { + initialVisibleUsers: { type: Array, required: false, default: () => [] @@ -167,6 +167,7 @@ export default defineComponent({ cw: null, localOnly: this.$store.state.rememberNoteVisibility ? this.$store.state.localOnly : this.$store.state.defaultNoteLocalOnly, visibility: (this.$store.state.rememberNoteVisibility ? this.$store.state.visibility : this.$store.state.defaultNoteVisibility) as typeof noteVisibilities[number], + visibleUsers: [], autocomplete: null, draghover: false, quoteId: null, @@ -273,6 +274,10 @@ export default defineComponent({ this.localOnly = this.initialLocalOnly; } + if (this.initialVisibleUsers) { + this.visibleUsers = this.initialVisibleUsers; + } + if (this.mention) { this.text = this.mention.host ? `@${this.mention.username}@${toASCII(this.mention.host)}` : `@${this.mention.username}`; this.text += ' '; diff --git a/packages/client/src/components/sparkle.vue b/packages/client/src/components/sparkle.vue index 3aaf03995..21b57f158 100644 --- a/packages/client/src/components/sparkle.vue +++ b/packages/client/src/components/sparkle.vue @@ -33,11 +33,25 @@ export default defineComponent({ ctx: null, }; }, + unmounted() { + window.cancelAnimationFrame(this.anim); + }, + mounted() { + this.ctx = this.$refs.canvas.getContext('2d'); + + new ResizeObserver(this.resize).observe(this.$refs.content); + + this.resize(); + this.tick(); + }, + updated() { + this.resize(); + }, methods: { createSparkles(w, h, count) { - var holder = []; + const holder = []; - for (var i = 0; i < count; i++) { + for (let i = 0; i < count; i++) { const color = '#' + ('000000' + Math.floor(Math.random() * 16777215).toString(16)).slice(-6); @@ -143,20 +157,6 @@ export default defineComponent({ } }, }, - mounted() { - this.ctx = this.$refs.canvas.getContext('2d'); - - new ResizeObserver(this.resize).observe(this.$refs.content); - - this.resize(); - this.tick(); - }, - updated() { - this.resize(); - }, - destroyed() { - window.cancelAnimationFrame(this.anim); - }, }); diff --git a/packages/client/src/components/ui/menu.vue b/packages/client/src/components/ui/menu.vue index 5938fb00a..c17cc43ce 100644 --- a/packages/client/src/components/ui/menu.vue +++ b/packages/client/src/components/ui/menu.vue @@ -5,7 +5,7 @@ @contextmenu.self="e => e.preventDefault()" v-hotkey="keymap" > -