@blogmcp/community 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blogmcp-community-private.global.js +4 -0
- package/dist/blogmcp-community.global.js +3 -3
- package/dist/chunks/{mount-Ts_r2fwt.js → mount-SKmc4NgD.js} +39 -9
- package/dist/chunks/private-mount-bhCQeScD.js +5397 -0
- package/dist/core/attrs.d.ts +15 -0
- package/dist/core/settings.d.ts +5 -0
- package/dist/index.js +2 -2
- package/dist/private/core/dock.d.ts +38 -0
- package/dist/private/core/push.d.ts +49 -0
- package/dist/private/core/realtime.d.ts +57 -0
- package/dist/private/core/setup.d.ts +43 -0
- package/dist/private/core/view.d.ts +179 -0
- package/dist/private/dm/composer.d.ts +34 -0
- package/dist/private/dm/controller.d.ts +162 -0
- package/dist/private/dm/index.d.ts +14 -0
- package/dist/private/dm/links.d.ts +33 -0
- package/dist/private/dm/muted.d.ts +37 -0
- package/dist/private/dm/search.d.ts +7 -0
- package/dist/private/dm/text.d.ts +27 -0
- package/dist/private/dm/ui/DmBlocks.vue.d.ts +8 -0
- package/dist/private/dm/ui/DmCases.vue.d.ts +8 -0
- package/dist/private/dm/ui/DmComposer.vue.d.ts +20 -0
- package/dist/private/dm/ui/DmInbox.vue.d.ts +12 -0
- package/dist/private/dm/ui/DmLinkWarning.vue.d.ts +8 -0
- package/dist/private/dm/ui/DmLocalAids.vue.d.ts +8 -0
- package/dist/private/dm/ui/DmMessageText.vue.d.ts +8 -0
- package/dist/private/dm/ui/DmNew.vue.d.ts +12 -0
- package/dist/private/dm/ui/DmReport.vue.d.ts +8 -0
- package/dist/private/dm/ui/DmRequests.vue.d.ts +12 -0
- package/dist/private/dm/ui/DmScreens.vue.d.ts +9 -0
- package/dist/private/dm/ui/DmThread.vue.d.ts +9 -0
- package/dist/private/element.d.ts +23 -0
- package/dist/private/global.d.ts +10 -0
- package/dist/private/i18n.d.ts +41 -0
- package/dist/private/index.d.ts +32 -0
- package/dist/private/index.js +57 -0
- package/dist/private/mount.d.ts +55 -0
- package/dist/private/pages/api.d.ts +44 -0
- package/dist/private/pages/element.d.ts +6 -0
- package/dist/private/pages/fragment.d.ts +43 -0
- package/dist/private/pages/i18n.d.ts +25 -0
- package/dist/private/pages/index.d.ts +1 -0
- package/dist/private/pages/pages.d.ts +276 -0
- package/dist/private/pages/proof.d.ts +36 -0
- package/dist/private/pages/provider-view.d.ts +33 -0
- package/dist/private/pages/setup.d.ts +42 -0
- package/dist/private/pages/ui/AccountPageRoot.vue.d.ts +9 -0
- package/dist/private/pages/ui/PageActivation.vue.d.ts +9 -0
- package/dist/private/pages/ui/PageAddress.vue.d.ts +8 -0
- package/dist/private/pages/ui/PageDeviceApprove.vue.d.ts +8 -0
- package/dist/private/pages/ui/PageDevices.vue.d.ts +8 -0
- package/dist/private/pages/ui/PageExport.vue.d.ts +8 -0
- package/dist/private/pages/ui/PageMessages.vue.d.ts +9 -0
- package/dist/private/react.d.ts +12 -0
- package/dist/private/react.js +36 -0
- package/dist/private/ui/ChatDockRoot.vue.d.ts +20 -0
- package/dist/private/ui/LegalText.vue.d.ts +13 -0
- package/dist/private/ui/PrivateScreens.vue.d.ts +14 -0
- package/dist/private/ui/PrivateViewRoot.vue.d.ts +23 -0
- package/dist/private/ui/PromiseBlock.vue.d.ts +9 -0
- package/dist/private/ui/ProviderLine.vue.d.ts +8 -0
- package/dist/private/ui/ScreenActivation.vue.d.ts +8 -0
- package/dist/private/ui/ScreenAddress.vue.d.ts +8 -0
- package/dist/private/ui/ScreenApproval.vue.d.ts +8 -0
- package/dist/private/ui/ScreenDevices.vue.d.ts +8 -0
- package/dist/private/ui/ScreenHome.vue.d.ts +12 -0
- package/dist/private/ui/ScreenNotifications.vue.d.ts +8 -0
- package/dist/private/ui/ScreenReads.vue.d.ts +8 -0
- package/dist/private/ui/ScreenSettings.vue.d.ts +8 -0
- package/dist/private/ui/root.d.ts +35 -0
- package/dist/private/ui/text.d.ts +22 -0
- package/dist/private/vue.d.ts +88 -0
- package/dist/private/vue.js +72 -0
- package/dist/react.js +14 -14
- package/dist/vue.js +14 -14
- package/package.json +23 -6
- package/src/core/attrs.ts +19 -0
- package/src/core/settings.ts +55 -12
- package/src/private/core/dock.ts +105 -0
- package/src/private/core/push.ts +166 -0
- package/src/private/core/realtime.ts +109 -0
- package/src/private/core/setup.ts +75 -0
- package/src/private/core/view.ts +920 -0
- package/src/private/dm/composer.ts +74 -0
- package/src/private/dm/controller.ts +636 -0
- package/src/private/dm/index.ts +14 -0
- package/src/private/dm/links.ts +55 -0
- package/src/private/dm/muted.ts +160 -0
- package/src/private/dm/search.ts +18 -0
- package/src/private/dm/text.ts +60 -0
- package/src/private/dm/ui/DmBlocks.vue +27 -0
- package/src/private/dm/ui/DmCases.vue +58 -0
- package/src/private/dm/ui/DmComposer.vue +68 -0
- package/src/private/dm/ui/DmInbox.vue +34 -0
- package/src/private/dm/ui/DmLinkWarning.vue +27 -0
- package/src/private/dm/ui/DmLocalAids.vue +43 -0
- package/src/private/dm/ui/DmMessageText.vue +16 -0
- package/src/private/dm/ui/DmNew.vue +46 -0
- package/src/private/dm/ui/DmReport.vue +93 -0
- package/src/private/dm/ui/DmRequests.vue +50 -0
- package/src/private/dm/ui/DmScreens.vue +66 -0
- package/src/private/dm/ui/DmThread.vue +235 -0
- package/src/private/element.ts +90 -0
- package/src/private/global.ts +14 -0
- package/src/private/i18n.ts +127 -0
- package/src/private/index.ts +68 -0
- package/src/private/messages/cs.json +311 -0
- package/src/private/messages/en.json +319 -0
- package/src/private/mount.ts +103 -0
- package/src/private/pages/api.ts +96 -0
- package/src/private/pages/build.d.mts +2 -0
- package/src/private/pages/build.mjs +72 -0
- package/src/private/pages/element.ts +49 -0
- package/src/private/pages/fragment.ts +63 -0
- package/src/private/pages/i18n.ts +82 -0
- package/src/private/pages/index.ts +10 -0
- package/src/private/pages/messages/cs.json +97 -0
- package/src/private/pages/messages/en.json +97 -0
- package/src/private/pages/pages.ts +410 -0
- package/src/private/pages/proof.ts +110 -0
- package/src/private/pages/provider-view.ts +121 -0
- package/src/private/pages/setup.ts +79 -0
- package/src/private/pages/ui/AccountPageRoot.vue +45 -0
- package/src/private/pages/ui/PageActivation.vue +42 -0
- package/src/private/pages/ui/PageAddress.vue +39 -0
- package/src/private/pages/ui/PageDeviceApprove.vue +62 -0
- package/src/private/pages/ui/PageDevices.vue +84 -0
- package/src/private/pages/ui/PageExport.vue +35 -0
- package/src/private/pages/ui/PageMessages.vue +39 -0
- package/src/private/pages/ui/account.css +6 -0
- package/src/private/react.ts +49 -0
- package/src/private/shims.d.ts +6 -0
- package/src/private/ui/ChatDockRoot.vue +119 -0
- package/src/private/ui/LegalText.vue +18 -0
- package/src/private/ui/PrivateScreens.vue +61 -0
- package/src/private/ui/PrivateViewRoot.vue +70 -0
- package/src/private/ui/PromiseBlock.vue +18 -0
- package/src/private/ui/ProviderLine.vue +20 -0
- package/src/private/ui/ScreenActivation.vue +82 -0
- package/src/private/ui/ScreenAddress.vue +37 -0
- package/src/private/ui/ScreenApproval.vue +71 -0
- package/src/private/ui/ScreenDevices.vue +42 -0
- package/src/private/ui/ScreenHome.vue +29 -0
- package/src/private/ui/ScreenNotifications.vue +44 -0
- package/src/private/ui/ScreenReads.vue +23 -0
- package/src/private/ui/ScreenSettings.vue +44 -0
- package/src/private/ui/private.css +81 -0
- package/src/private/ui/root.ts +89 -0
- package/src/private/ui/text.ts +40 -0
- package/src/private/vue.ts +87 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A message's text as the conversation shows it (m4-contracts.md §7.8 DM8b): plain text, with the web addresses a
|
|
3
|
+
* member wrote marked as links that open only after a warning on click. Nothing here is markup — the segments are
|
|
4
|
+
* rendered as text nodes and an `<a>` whose `href` is the address this module re-serialised — and nothing here asks
|
|
5
|
+
* anything of anyone: an address is checked locally, never fetched, previewed or reported.
|
|
6
|
+
*
|
|
7
|
+
* Only an address written with `http://` or `https://` is a link. Anything else (`javascript:`, `data:`, `www.…`
|
|
8
|
+
* without a scheme, a bare word with a dot) stays text: guessing a scheme would make the client decide where a member
|
|
9
|
+
* is sent, and the warning shows the address exactly as it was written. The private entry may not import the public text glue
|
|
10
|
+
* (`core/text.ts`, which reaches `@blogmcp/sanitize/url`; test/closed-paths.spec.ts), so the check is the URL parser's:
|
|
11
|
+
* an address that does not parse, or parses to another scheme, is text.
|
|
12
|
+
*
|
|
13
|
+
* A request's links are inactive (§7.3: "links inactive in the client"): `segmentsOf(text, { links: false })` gives one
|
|
14
|
+
* text segment.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export type DmTextSegment = { readonly kind: 'text'; readonly text: string } | { readonly kind: 'link'; readonly text: string; readonly href: string; readonly host: string }
|
|
18
|
+
|
|
19
|
+
/** An address with its scheme, up to a blank or a character no address carries. */
|
|
20
|
+
const ADDRESS = /\bhttps?:\/\/[^\s<>"'`]+/gi
|
|
21
|
+
/** Punctuation that ends a sentence rather than the address it follows. */
|
|
22
|
+
const TRAILING = /[.,;:!?)\]}»“”’]+$/
|
|
23
|
+
|
|
24
|
+
/** The address, re-serialised by the URL parser, and its host; null for anything that is not an http(s) address. */
|
|
25
|
+
export function linkOf(written: string): { href: string; host: string } | null {
|
|
26
|
+
let url: URL
|
|
27
|
+
try {
|
|
28
|
+
url = new URL(written)
|
|
29
|
+
} catch {
|
|
30
|
+
return null
|
|
31
|
+
}
|
|
32
|
+
if (url.protocol !== 'https:' && url.protocol !== 'http:') return null
|
|
33
|
+
if (url.username !== '' || url.password !== '' || url.hostname === '') return null
|
|
34
|
+
return { href: url.href, host: url.hostname }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The segments of a message's text (see the module doc). */
|
|
38
|
+
export function segmentsOf(text: string, options: { links?: boolean } = {}): DmTextSegment[] {
|
|
39
|
+
if (options.links === false || text === '') return [{ kind: 'text', text }]
|
|
40
|
+
const out: DmTextSegment[] = []
|
|
41
|
+
let at = 0
|
|
42
|
+
for (const m of text.matchAll(ADDRESS)) {
|
|
43
|
+
const start = m.index ?? 0
|
|
44
|
+
const raw = m[0]
|
|
45
|
+
const trailing = raw.match(TRAILING)?.[0] ?? ''
|
|
46
|
+
const written = raw.slice(0, raw.length - trailing.length)
|
|
47
|
+
const link = linkOf(written)
|
|
48
|
+
if (!link) continue
|
|
49
|
+
if (start > at) out.push({ kind: 'text', text: text.slice(at, start) })
|
|
50
|
+
out.push({ kind: 'link', text: written, href: link.href, host: link.host })
|
|
51
|
+
at = start + written.length
|
|
52
|
+
}
|
|
53
|
+
if (at < text.length) out.push({ kind: 'text', text: text.slice(at) })
|
|
54
|
+
return out.length > 0 ? out : [{ kind: 'text', text }]
|
|
55
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Muted words (m4-contracts.md §7.8 DM8b): the member's list of words whose messages the conversation folds away, kept
|
|
3
|
+
* on this device only — in this browser's IndexedDB — and matched in the browser. The list never leaves the device: this
|
|
4
|
+
* module imports nothing, names no transport and no private client, and the server never learns which words a member
|
|
5
|
+
* mutes or which messages were folded (test/private/dm/nothing-leaves.spec.ts holds it to that).
|
|
6
|
+
*
|
|
7
|
+
* The store is per member (`scope`, the member's id: two members on one browser keep two lists). Where IndexedDB is
|
|
8
|
+
* missing or refuses (a private window, a blocked storage), the list lives in this tab's memory and the screen says
|
|
9
|
+
* that it is not kept (`persistent: false`).
|
|
10
|
+
*
|
|
11
|
+
* Matching ignores case and diacritics and takes a muted word as the start of a word: „houb“ folds „houby“, „HOUBY“
|
|
12
|
+
* and „Houbička“, but not „chouba“ — so a member need not list every form a Czech word takes.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const MUTED_DB_NAME = 'blogmcp-private-muted'
|
|
16
|
+
export const MUTED_DB_STORE = 'words'
|
|
17
|
+
/** At most this many words, each at most this long: the list is matched against every message shown. */
|
|
18
|
+
export const MUTED_MAX_WORDS = 100
|
|
19
|
+
export const MUTED_MAX_LENGTH = 40
|
|
20
|
+
|
|
21
|
+
export interface MutedStore {
|
|
22
|
+
/** The member's words (empty when none were stored or the store is unreadable). */
|
|
23
|
+
load(): Promise<string[]>
|
|
24
|
+
/** Keep the member's words; false when this browser could not keep them (they stay in memory for this tab). */
|
|
25
|
+
save(words: readonly string[]): Promise<boolean>
|
|
26
|
+
readonly persistent: () => boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Lower case, without diacritics, blanks collapsed: the form both a muted word and a message are compared in. */
|
|
30
|
+
export function foldText(text: string): string {
|
|
31
|
+
return text.normalize('NFD').replace(/\p{M}+/gu, '').toLowerCase().replace(/\s+/g, ' ').trim()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** A word as the list keeps it: trimmed, folded, bounded; null for a blank one. */
|
|
35
|
+
export function mutedWordOf(input: string): string | null {
|
|
36
|
+
const w = foldText(input)
|
|
37
|
+
return w === '' ? null : w.slice(0, MUTED_MAX_LENGTH)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The list cleaned: folded, without blanks and repeats, bounded. */
|
|
41
|
+
export function cleanMutedWords(words: readonly unknown[]): string[] {
|
|
42
|
+
const out: string[] = []
|
|
43
|
+
for (const w of words) {
|
|
44
|
+
if (typeof w !== 'string') continue
|
|
45
|
+
const word = mutedWordOf(w)
|
|
46
|
+
if (word !== null && !out.includes(word)) out.push(word)
|
|
47
|
+
if (out.length >= MUTED_MAX_WORDS) break
|
|
48
|
+
}
|
|
49
|
+
return out
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Whether `text` holds a muted word at the start of one of its words (see the module doc). */
|
|
53
|
+
export function mutedMatch(text: string | null | undefined, words: readonly string[]): boolean {
|
|
54
|
+
if (!text || words.length === 0) return false
|
|
55
|
+
const folded = ` ${wordsOnly(foldText(text))}`
|
|
56
|
+
// The word goes through the same fold as the text: „e-mail“ and „o'brien“ are matched as „e mail“ and „o brien“,
|
|
57
|
+
// which is what the text becomes, instead of never matching at all.
|
|
58
|
+
return words.some((w) => {
|
|
59
|
+
const fw = wordsOnly(w)
|
|
60
|
+
return fw !== '' && folded.includes(` ${fw}`)
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Punctuation to blanks, blanks collapsed: the form in which words are compared (after `foldText`). */
|
|
65
|
+
function wordsOnly(folded: string): string {
|
|
66
|
+
return folded.replace(/[^\p{L}\p{N}\s]+/gu, ' ').replace(/\s+/g, ' ').trim()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The list in this tab's memory only. */
|
|
70
|
+
export function memoryMutedStore(initial: readonly string[] = []): MutedStore {
|
|
71
|
+
let words = cleanMutedWords(initial)
|
|
72
|
+
return {
|
|
73
|
+
load: async () => [...words],
|
|
74
|
+
save: async (next) => {
|
|
75
|
+
words = cleanMutedWords(next)
|
|
76
|
+
return false
|
|
77
|
+
},
|
|
78
|
+
persistent: () => false,
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function request<T>(r: IDBRequest<T>): Promise<T> {
|
|
83
|
+
return new Promise((resolve, reject) => {
|
|
84
|
+
r.onsuccess = () => resolve(r.result)
|
|
85
|
+
r.onerror = () => reject(r.error)
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The member's list in this browser's IndexedDB, or in memory where IndexedDB is not there (see the module doc). */
|
|
90
|
+
export function indexedDbMutedStore(scope: string, idb: IDBFactory | null = typeof indexedDB === 'undefined' ? null : indexedDB): MutedStore {
|
|
91
|
+
const memory = memoryMutedStore()
|
|
92
|
+
let persistent = idb !== null
|
|
93
|
+
let opening: Promise<IDBDatabase | null> | null = null
|
|
94
|
+
|
|
95
|
+
function open(): Promise<IDBDatabase | null> {
|
|
96
|
+
if (!idb) return Promise.resolve(null)
|
|
97
|
+
opening ??= new Promise<IDBDatabase | null>((resolve) => {
|
|
98
|
+
try {
|
|
99
|
+
const r = idb.open(MUTED_DB_NAME, 1)
|
|
100
|
+
r.onupgradeneeded = () => {
|
|
101
|
+
try {
|
|
102
|
+
if (!r.result.objectStoreNames.contains(MUTED_DB_STORE)) r.result.createObjectStore(MUTED_DB_STORE, { keyPath: 'scope' })
|
|
103
|
+
} catch {
|
|
104
|
+
// The open then fails or succeeds without the store; either way load() and save() fall back to memory.
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
r.onsuccess = () => resolve(r.result)
|
|
108
|
+
r.onerror = () => resolve(null)
|
|
109
|
+
r.onblocked = () => resolve(null)
|
|
110
|
+
} catch {
|
|
111
|
+
resolve(null)
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
return opening
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
async load() {
|
|
119
|
+
const db = await open()
|
|
120
|
+
if (!db) {
|
|
121
|
+
persistent = false
|
|
122
|
+
return memory.load()
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
const value: unknown = await request(db.transaction(MUTED_DB_STORE, 'readonly').objectStore(MUTED_DB_STORE).get(scope))
|
|
126
|
+
const stored = typeof value === 'object' && value !== null ? (value as { words?: unknown }).words : null
|
|
127
|
+
const words = cleanMutedWords(Array.isArray(stored) ? stored : [])
|
|
128
|
+
await memory.save(words)
|
|
129
|
+
return words
|
|
130
|
+
} catch {
|
|
131
|
+
persistent = false
|
|
132
|
+
return memory.load()
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
async save(words) {
|
|
136
|
+
const clean = cleanMutedWords(words)
|
|
137
|
+
await memory.save(clean)
|
|
138
|
+
const db = await open()
|
|
139
|
+
if (!db) {
|
|
140
|
+
persistent = false
|
|
141
|
+
return false
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
const tx = db.transaction(MUTED_DB_STORE, 'readwrite')
|
|
145
|
+
tx.objectStore(MUTED_DB_STORE).put({ scope, words: clean })
|
|
146
|
+
await new Promise<void>((resolve, reject) => {
|
|
147
|
+
tx.oncomplete = () => resolve()
|
|
148
|
+
tx.onerror = () => reject(tx.error)
|
|
149
|
+
tx.onabort = () => reject(tx.error)
|
|
150
|
+
})
|
|
151
|
+
persistent = true
|
|
152
|
+
return true
|
|
153
|
+
} catch {
|
|
154
|
+
persistent = false
|
|
155
|
+
return false
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
persistent: () => persistent,
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search in a conversation (m4-contracts.md §7.8 DM8b): only in the messages this device has loaded and decrypted for
|
|
3
|
+
* the open thread — there is no server search, because kb-api would have to keep a searchable form of the texts it
|
|
4
|
+
* holds encrypted, and the query itself would be private content leaving the device. This module imports nothing and
|
|
5
|
+
* names no transport (test/private/dm/nothing-leaves.spec.ts); the settings say plainly that older messages are found
|
|
6
|
+
* only once they are loaded („Načíst starší“).
|
|
7
|
+
*/
|
|
8
|
+
import { foldText } from './muted'
|
|
9
|
+
|
|
10
|
+
/** The smallest query that searches (a single letter would mark nearly every message). */
|
|
11
|
+
export const DM_SEARCH_MIN_LENGTH = 2
|
|
12
|
+
|
|
13
|
+
/** The seqs of the loaded messages whose text holds the query, ignoring case and diacritics, in the thread's order. */
|
|
14
|
+
export function searchLoaded(messages: ReadonlyArray<{ readonly seq: number; readonly text: string | null }>, query: string): number[] {
|
|
15
|
+
const q = foldText(query)
|
|
16
|
+
if (q.length < DM_SEARCH_MIN_LENGTH) return []
|
|
17
|
+
return messages.filter((m) => typeof m.text === 'string' && foldText(m.text).includes(q)).map((m) => m.seq)
|
|
18
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The conversations' words: the private catalogue (i18n.ts) through the screens' helper, a refusal of the
|
|
3
|
+
* conversations by its own key (`dmErrorKey`), and a counterpart's name — the deleted placeholder's words for an erased
|
|
4
|
+
* member, never an empty line.
|
|
5
|
+
*/
|
|
6
|
+
import type { PrivateDmCounterpart } from '@blogmcp/sdk/community/private'
|
|
7
|
+
import { errorKey, type Lang } from '../i18n'
|
|
8
|
+
import { screenText, type ScreenText } from '../ui/text'
|
|
9
|
+
import { dmErrorKey } from './controller'
|
|
10
|
+
|
|
11
|
+
export interface DmText extends ScreenText {
|
|
12
|
+
/** A refusal code's sentence. */
|
|
13
|
+
err(code: string | null | undefined): string
|
|
14
|
+
/**
|
|
15
|
+
* The counterpart's display name (and handle), the deleted placeholder's words for an erased member, or — while the
|
|
16
|
+
* counterpart is not known yet (a conversation just opened by handle) — the conversations' title.
|
|
17
|
+
*/
|
|
18
|
+
who(c: PrivateDmCounterpart | null | undefined): string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function dmText(lang: Lang): DmText {
|
|
22
|
+
const base = screenText(lang)
|
|
23
|
+
return {
|
|
24
|
+
...base,
|
|
25
|
+
err: (code) => base.pt(dmErrorKey(code, errorKey)),
|
|
26
|
+
who(c) {
|
|
27
|
+
if (!c) return base.pt('private.dm.title')
|
|
28
|
+
if (c.memberId === null) return base.pt('private.dm.counterpart.deleted')
|
|
29
|
+
return base.pt('private.dm.counterpart.name', { name: c.displayName, handle: c.handle })
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The keys of the report's lines and categories, spelt out: test/private/text.spec.ts checks every literal key against
|
|
36
|
+
* the catalogue, and a key built from a value (`` `…${line}` ``) would be a family that scan does not know.
|
|
37
|
+
*/
|
|
38
|
+
export const DM_LINE_KEYS = Object.freeze({
|
|
39
|
+
rules: 'private.dm.report.line.rules',
|
|
40
|
+
illegal: 'private.dm.report.line.illegal',
|
|
41
|
+
} as const)
|
|
42
|
+
|
|
43
|
+
export const DM_CATEGORY_KEYS: Readonly<Record<string, string>> = Object.freeze({
|
|
44
|
+
fraud_spam: 'private.dm.report.category.fraud_spam',
|
|
45
|
+
harassment: 'private.dm.report.category.harassment',
|
|
46
|
+
hate: 'private.dm.report.category.hate',
|
|
47
|
+
threats: 'private.dm.report.category.threats',
|
|
48
|
+
sexual_content: 'private.dm.report.category.sexual_content',
|
|
49
|
+
child_at_risk: 'private.dm.report.category.child_at_risk',
|
|
50
|
+
self_harm: 'private.dm.report.category.self_harm',
|
|
51
|
+
doxxing: 'private.dm.report.category.doxxing',
|
|
52
|
+
copyright: 'private.dm.report.category.copyright',
|
|
53
|
+
terrorism: 'private.dm.report.category.terrorism',
|
|
54
|
+
drugs: 'private.dm.report.category.drugs',
|
|
55
|
+
other_illegal: 'private.dm.report.category.other_illegal',
|
|
56
|
+
rules: 'private.dm.report.category.rules',
|
|
57
|
+
adverse_event: 'private.dm.report.category.adverse_event',
|
|
58
|
+
third_party_health_data: 'private.dm.report.category.third_party_health_data',
|
|
59
|
+
suspected_minor: 'private.dm.report.category.suspected_minor',
|
|
60
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/** The member's private blocks (§7.3 `blocks/list`), each with „Odblokovat“; a blocked person sees only that they cannot write now. */
|
|
3
|
+
import { computed } from 'vue'
|
|
4
|
+
import type { Lang } from '../../i18n'
|
|
5
|
+
import type { DmViewController } from '../controller'
|
|
6
|
+
import { dmText } from '../text'
|
|
7
|
+
|
|
8
|
+
const props = defineProps<{ dm: DmViewController; lang: Lang }>()
|
|
9
|
+
const tx = computed(() => dmText(props.lang))
|
|
10
|
+
const s = computed(() => props.dm.state)
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<section class="bcm-p-screen" data-dm-screen="blocks">
|
|
15
|
+
<h3>{{ tx.pt('private.dm.blocks.title') }}</h3>
|
|
16
|
+
<p class="bcm-p-muted">{{ tx.pt('private.dm.blocks.why') }}</p>
|
|
17
|
+
<p v-if="s.failures.blocks" class="bcm-p-error" role="alert">{{ tx.err(s.failures.blocks) }}</p>
|
|
18
|
+
<p v-if="s.blocks && s.blocks.length === 0" class="bcm-p-muted" data-blocks-empty>{{ tx.pt('private.dm.blocks.empty') }}</p>
|
|
19
|
+
<ul v-if="s.blocks && s.blocks.length > 0" class="bcm-p-list">
|
|
20
|
+
<li v-for="b in s.blocks" :key="b.memberId" :data-block="b.memberId">
|
|
21
|
+
<span>{{ tx.who(b.author) }}</span>
|
|
22
|
+
<span class="bcm-p-muted"> {{ tx.pt('private.dm.blocks.since', { date: tx.when(b.blockedAt, false) }) }}</span>
|
|
23
|
+
<button type="button" class="bcm-p-btn" :disabled="s.busy" data-action="unblock" @click="dm.unblock(b.memberId)">{{ tx.pt('private.dm.block.remove') }}</button>
|
|
24
|
+
</li>
|
|
25
|
+
</ul>
|
|
26
|
+
</section>
|
|
27
|
+
</template>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* The member's private cases (§7.5 `cases/list|get`), the statement of reasons of a decided one (`statements/get`) and
|
|
4
|
+
* the appeal against it (`appeals/submit`, until the statement's `closesAt`). Codes and times only: a case says neither
|
|
5
|
+
* who reported nor what the package held. Until kb-api serves them (DM5) the screen says they are not available yet.
|
|
6
|
+
*/
|
|
7
|
+
import { computed, ref } from 'vue'
|
|
8
|
+
import type { Lang } from '../../i18n'
|
|
9
|
+
import type { DmViewController } from '../controller'
|
|
10
|
+
import { DM_LINE_KEYS, dmText } from '../text'
|
|
11
|
+
|
|
12
|
+
const props = defineProps<{ dm: DmViewController; lang: Lang }>()
|
|
13
|
+
const tx = computed(() => dmText(props.lang))
|
|
14
|
+
const s = computed(() => props.dm.state)
|
|
15
|
+
const appealText = ref('')
|
|
16
|
+
const appealOpen = computed(() => {
|
|
17
|
+
const st = s.value.statement
|
|
18
|
+
if (!st || s.value.appealDone) return false
|
|
19
|
+
return st.closesAt === null || Date.parse(st.closesAt) > Date.now()
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
async function appeal(): Promise<void> {
|
|
23
|
+
const st = s.value.statement
|
|
24
|
+
if (st && (await props.dm.appeal(st.decisionId, appealText.value))) appealText.value = ''
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<section class="bcm-p-screen" data-dm-screen="cases">
|
|
30
|
+
<h3>{{ tx.pt('private.dm.cases.title') }}</h3>
|
|
31
|
+
<p v-if="s.failures.cases" class="bcm-p-error" role="alert">{{ tx.err(s.failures.cases) }}</p>
|
|
32
|
+
<p v-if="s.cases && s.cases.length === 0" class="bcm-p-muted" data-cases-empty>{{ tx.pt('private.dm.cases.empty') }}</p>
|
|
33
|
+
<ul v-if="s.cases && s.cases.length > 0" class="bcm-p-list">
|
|
34
|
+
<li v-for="c in s.cases" :key="c.caseId" :data-case="c.caseId">
|
|
35
|
+
<p>{{ tx.pt('private.dm.cases.row', { date: tx.when(c.openedAt, false) }) }} <span class="bcm-p-badge">{{ tx.pt(DM_LINE_KEYS[c.line]) }}</span></p>
|
|
36
|
+
<button v-if="c.decisionId" type="button" class="bcm-p-link" data-action="statement" @click="dm.openStatement(c.decisionId)">{{ tx.pt('private.dm.cases.statement') }}</button>
|
|
37
|
+
<p v-else class="bcm-p-muted">{{ tx.pt('private.dm.cases.open') }}</p>
|
|
38
|
+
</li>
|
|
39
|
+
</ul>
|
|
40
|
+
<button v-if="s.casesCursor" type="button" class="bcm-p-link" data-action="cases-more" @click="dm.loadCases(true)">{{ tx.pt('private.dm.inbox.more') }}</button>
|
|
41
|
+
<p v-if="s.failures.statement" class="bcm-p-error" role="alert">{{ tx.err(s.failures.statement) }}</p>
|
|
42
|
+
<div v-if="s.statement" class="bcm-p-note" data-statement>
|
|
43
|
+
<h4>{{ tx.pt('private.dm.statement.title', { date: tx.when(s.statement.decidedAt, false) }) }}</h4>
|
|
44
|
+
<p class="bcm-p-legal-body">{{ s.statement.statement }}</p>
|
|
45
|
+
<p v-if="s.statement.closesAt" class="bcm-p-muted">{{ tx.pt('private.dm.statement.closesAt', { date: tx.when(s.statement.closesAt, false) }) }}</p>
|
|
46
|
+
<p v-if="s.appealDone" data-appeal-done>{{ tx.pt('private.dm.appeal.sent') }}</p>
|
|
47
|
+
<form v-else-if="appealOpen" class="bcm-p-form" data-appeal @submit.prevent="appeal()">
|
|
48
|
+
<label>
|
|
49
|
+
{{ tx.pt('private.dm.appeal.label') }}
|
|
50
|
+
<textarea v-model="appealText" class="bcm-p-input" rows="4" data-appeal-text />
|
|
51
|
+
</label>
|
|
52
|
+
<button type="submit" class="bcm-p-btn bcm-p-primary" :disabled="appealText.trim() === '' || s.busy" data-action="appeal">{{ tx.pt('private.dm.appeal.send') }}</button>
|
|
53
|
+
</form>
|
|
54
|
+
<p v-else class="bcm-p-muted">{{ tx.pt('private.dm.appeal.closed') }}</p>
|
|
55
|
+
<p v-if="s.failures.appeal" class="bcm-p-error" role="alert">{{ tx.err(s.failures.appeal) }}</p>
|
|
56
|
+
</div>
|
|
57
|
+
</section>
|
|
58
|
+
</template>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* The composer (§7.8, §3.5): the text box, whose draft lives in the DM client's memory only (`dm.drafts`, never storage
|
|
4
|
+
* or a request — test/private/dm/nothing-leaves.spec.ts types a sentinel into it), the sentence of who receives what is
|
|
5
|
+
* written here, read from the capability matrix (composer.ts), and, before the member's first message in a
|
|
6
|
+
* conversation, the reminder of the rules. Sending hands the text to the outbox; „píše…“ is sent at most once in 3 s
|
|
7
|
+
* (the DM client's own limit) and not at all while the member has typing off.
|
|
8
|
+
*/
|
|
9
|
+
import { computed, ref, watch } from 'vue'
|
|
10
|
+
import type { Lang } from '../../i18n'
|
|
11
|
+
import type { DmViewController } from '../controller'
|
|
12
|
+
import { dmText } from '../text'
|
|
13
|
+
|
|
14
|
+
const props = defineProps<{ dm: DmViewController; conversationId: string; lang: Lang; firstMessage: boolean; replyTo: { seq: number; excerpt: string } | null }>()
|
|
15
|
+
const emit = defineEmits<{ sent: []; cancelReply: [] }>()
|
|
16
|
+
const tx = computed(() => dmText(props.lang))
|
|
17
|
+
const text = ref(props.dm.drafts.get(props.conversationId))
|
|
18
|
+
watch(
|
|
19
|
+
() => props.conversationId,
|
|
20
|
+
(cid) => {
|
|
21
|
+
text.value = props.dm.drafts.get(cid)
|
|
22
|
+
},
|
|
23
|
+
)
|
|
24
|
+
const sentence = computed(() => props.dm.composerKeys())
|
|
25
|
+
const rules = computed(() => props.dm.rulesHref())
|
|
26
|
+
|
|
27
|
+
function input(): void {
|
|
28
|
+
props.dm.drafts.set(props.conversationId, text.value)
|
|
29
|
+
if (text.value.trim() !== '') props.dm.typing(props.conversationId)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function send(): void {
|
|
33
|
+
if (text.value.trim() === '') return
|
|
34
|
+
props.dm.send(props.conversationId, text.value, props.replyTo?.seq ?? null)
|
|
35
|
+
// The text moved into the outbox: the box is empty, and so is the draft (the DM client dropped it).
|
|
36
|
+
text.value = ''
|
|
37
|
+
props.dm.drafts.delete(props.conversationId)
|
|
38
|
+
emit('sent')
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function keydown(e: KeyboardEvent): void {
|
|
42
|
+
if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {
|
|
43
|
+
e.preventDefault()
|
|
44
|
+
send()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<template>
|
|
50
|
+
<form class="bcm-p-form bcm-p-dm-composer" data-composer @submit.prevent="send">
|
|
51
|
+
<p v-if="firstMessage" class="bcm-p-note" data-rules-reminder>
|
|
52
|
+
{{ tx.pt('private.dm.composer.rulesReminder') }}
|
|
53
|
+
<a v-if="rules" :href="rules" target="_blank" rel="noopener noreferrer">{{ tx.pt('private.dm.composer.rulesLink') }}</a>
|
|
54
|
+
</p>
|
|
55
|
+
<p v-if="replyTo" class="bcm-p-muted" data-replying>
|
|
56
|
+
{{ tx.pt('private.dm.composer.replyTo', { excerpt: replyTo.excerpt }) }}
|
|
57
|
+
<button type="button" class="bcm-p-link" data-action="cancel-reply" @click="emit('cancelReply')">{{ tx.pt('private.cancel') }}</button>
|
|
58
|
+
</p>
|
|
59
|
+
<label class="bcm-p-sr" :for="`bcm-p-dm-box-${conversationId}`">{{ tx.pt('private.dm.composer.label') }}</label>
|
|
60
|
+
<textarea :id="`bcm-p-dm-box-${conversationId}`" v-model="text" class="bcm-p-input bcm-p-dm-box" rows="3" :placeholder="tx.pt('private.dm.composer.placeholder')" data-composer-box @input="input" @keydown="keydown" />
|
|
61
|
+
<div class="bcm-p-row">
|
|
62
|
+
<button type="submit" class="bcm-p-btn bcm-p-primary" :disabled="text.trim() === ''" data-action="send">{{ tx.pt('private.dm.composer.send') }}</button>
|
|
63
|
+
</div>
|
|
64
|
+
<div class="bcm-p-muted bcm-p-dm-sentence" data-composer-sentence>
|
|
65
|
+
<p v-for="k in sentence" :key="k" :data-composer-key="k">{{ tx.pt(k) }}</p>
|
|
66
|
+
</div>
|
|
67
|
+
</form>
|
|
68
|
+
</template>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* The inbox (§7.3 `dm/list`): the member's conversations, newest activity first, each with the other participant's
|
|
4
|
+
* card, the last activity and the unread count — never a text, which the inbox does not carry. A request the member
|
|
5
|
+
* sent and that is not accepted yet says so. The dock's panel and the private view's `messages` screen both show it;
|
|
6
|
+
* a row opens the conversation where the caller says (`open`).
|
|
7
|
+
*/
|
|
8
|
+
import { computed } from 'vue'
|
|
9
|
+
import type { Lang } from '../../i18n'
|
|
10
|
+
import type { DmViewController } from '../controller'
|
|
11
|
+
import { dmText } from '../text'
|
|
12
|
+
|
|
13
|
+
const props = defineProps<{ dm: DmViewController; lang: Lang }>()
|
|
14
|
+
const emit = defineEmits<{ open: [conversationId: string] }>()
|
|
15
|
+
const tx = computed(() => dmText(props.lang))
|
|
16
|
+
const s = computed(() => props.dm.state)
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<div class="bcm-p-dm-inbox" data-inbox>
|
|
21
|
+
<p v-if="s.failures.inbox" class="bcm-p-error" role="alert">{{ tx.err(s.failures.inbox) }}</p>
|
|
22
|
+
<p v-else-if="s.inbox === null" class="bcm-p-muted">{{ tx.pt('private.loading') }}</p>
|
|
23
|
+
<p v-else-if="s.inbox.length === 0" class="bcm-p-muted" data-inbox-empty>{{ tx.pt('private.dm.inbox.empty') }}</p>
|
|
24
|
+
<ul v-if="s.inbox && s.inbox.length > 0" class="bcm-p-list">
|
|
25
|
+
<li v-for="c in s.inbox" :key="c.conversationId" :class="{ 'bcm-p-unread': c.unread > 0 }" :data-inbox-row="c.conversationId">
|
|
26
|
+
<button type="button" class="bcm-p-link" data-action="open-conversation" @click="emit('open', c.conversationId)">{{ tx.who(c.counterpart) }}</button>
|
|
27
|
+
<span v-if="c.state === 'request'" class="bcm-p-badge">{{ tx.pt('private.dm.request.sent') }}</span>
|
|
28
|
+
<span v-if="c.unread > 0" class="bcm-p-badge" data-unread>{{ tx.pt('private.dm.inbox.unread', { count: c.unread }) }}</span>
|
|
29
|
+
<p class="bcm-p-muted">{{ tx.pt('private.dm.inbox.lastActivity', { date: tx.when(c.lastActivityAt) }) }}</p>
|
|
30
|
+
</li>
|
|
31
|
+
</ul>
|
|
32
|
+
<button v-if="s.inboxCursor" type="button" class="bcm-p-link" data-action="inbox-more" @click="dm.loadInbox(true)">{{ tx.pt('private.dm.inbox.more') }}</button>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* The link warning (§7.8): a link from a private message opens only after the member saw where it goes — the host
|
|
4
|
+
* written out, a reminder that the sender chose it — and confirmed. The address leaves the page only as the member's
|
|
5
|
+
* own navigation, in a new tab without a referrer, so the website and the target learn nothing of the conversation.
|
|
6
|
+
*/
|
|
7
|
+
import { computed } from 'vue'
|
|
8
|
+
import type { Lang } from '../../i18n'
|
|
9
|
+
import type { DmViewController } from '../controller'
|
|
10
|
+
import { dmText } from '../text'
|
|
11
|
+
|
|
12
|
+
const props = defineProps<{ dm: DmViewController; lang: Lang }>()
|
|
13
|
+
const tx = computed(() => dmText(props.lang))
|
|
14
|
+
const w = computed(() => props.dm.state.linkWarning)
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<div v-if="w" class="bcm-p-note bcm-p-dm-warning" role="alertdialog" :aria-label="tx.pt('private.dm.link.title')" data-link-warning>
|
|
19
|
+
<p>{{ tx.pt('private.dm.link.where', { host: w.host }) }}</p>
|
|
20
|
+
<p class="bcm-p-muted bcm-p-dm-href">{{ w.href }}</p>
|
|
21
|
+
<p class="bcm-p-muted">{{ tx.pt('private.dm.link.why') }}</p>
|
|
22
|
+
<div class="bcm-p-actions">
|
|
23
|
+
<a class="bcm-p-btn" :href="w.href" target="_blank" rel="nofollow ugc noopener noreferrer" referrerpolicy="no-referrer" data-action="link-continue" @click="dm.dismissLink()">{{ tx.pt('private.dm.link.continue') }}</a>
|
|
24
|
+
<button type="button" class="bcm-p-btn" data-action="link-cancel" @click="dm.dismissLink()">{{ tx.pt('private.cancel') }}</button>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* The aids that run on this device only (§7.8), on the private settings screen: the muted words — kept in this
|
|
4
|
+
* browser's IndexedDB, matched here, never sent (muted.ts) — and the sentence that search finds only the messages
|
|
5
|
+
* this device has loaded (search.ts).
|
|
6
|
+
*/
|
|
7
|
+
import { computed, ref } from 'vue'
|
|
8
|
+
import type { Lang } from '../../i18n'
|
|
9
|
+
import type { DmViewController } from '../controller'
|
|
10
|
+
import { dmText } from '../text'
|
|
11
|
+
|
|
12
|
+
const props = defineProps<{ dm: DmViewController; lang: Lang }>()
|
|
13
|
+
const tx = computed(() => dmText(props.lang))
|
|
14
|
+
const s = computed(() => props.dm.state)
|
|
15
|
+
const word = ref('')
|
|
16
|
+
|
|
17
|
+
async function add(): Promise<void> {
|
|
18
|
+
if (word.value.trim() === '') return
|
|
19
|
+
await props.dm.addMuted(word.value)
|
|
20
|
+
word.value = ''
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<section class="bcm-p-dm-aids" data-local-aids>
|
|
26
|
+
<h3>{{ tx.pt('private.dm.muted.title') }}</h3>
|
|
27
|
+
<p class="bcm-p-muted">{{ tx.pt('private.dm.muted.why') }}</p>
|
|
28
|
+
<p v-if="!s.mutedPersistent" class="bcm-p-note" data-muted-memory>{{ tx.pt('private.dm.muted.notKept') }}</p>
|
|
29
|
+
<ul v-if="s.muted.length > 0" class="bcm-p-list">
|
|
30
|
+
<li v-for="w in s.muted" :key="w" :data-muted-word="w">
|
|
31
|
+
<span>{{ w }}</span>
|
|
32
|
+
<button type="button" class="bcm-p-link" data-action="unmute" @click="dm.removeMuted(w)">{{ tx.pt('private.dm.muted.remove') }}</button>
|
|
33
|
+
</li>
|
|
34
|
+
</ul>
|
|
35
|
+
<form class="bcm-p-form bcm-p-row" @submit.prevent="add()">
|
|
36
|
+
<label class="bcm-p-sr" for="bcm-p-dm-mute">{{ tx.pt('private.dm.muted.label') }}</label>
|
|
37
|
+
<input id="bcm-p-dm-mute" v-model="word" class="bcm-p-input" autocomplete="off" data-mute-input />
|
|
38
|
+
<button type="submit" class="bcm-p-btn" :disabled="word.trim() === ''" data-action="mute">{{ tx.pt('private.dm.muted.add') }}</button>
|
|
39
|
+
</form>
|
|
40
|
+
<h3>{{ tx.pt('private.dm.search.title') }}</h3>
|
|
41
|
+
<p class="bcm-p-muted" data-search-sentence>{{ tx.pt('private.dm.search.settings') }}</p>
|
|
42
|
+
</section>
|
|
43
|
+
</template>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A message's text (links.ts): text nodes, and each web address a button that asks first (the link warning on click)
|
|
4
|
+
* — or plain text where links are inactive (a request, §7.3). Never markup.
|
|
5
|
+
*/
|
|
6
|
+
import { computed } from 'vue'
|
|
7
|
+
import type { DmViewController } from '../controller'
|
|
8
|
+
import { segmentsOf } from '../links'
|
|
9
|
+
|
|
10
|
+
const props = defineProps<{ dm: DmViewController; text: string; links: boolean }>()
|
|
11
|
+
const segments = computed(() => segmentsOf(props.text, { links: props.links }))
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<span class="bcm-p-dm-text"><template v-for="(seg, i) in segments" :key="i"><button v-if="seg.kind === 'link'" type="button" class="bcm-p-link bcm-p-dm-url" :data-link="seg.host" @click="dm.warnLink(seg)">{{ seg.text }}</button><template v-else>{{ seg.text }}</template></template></span>
|
|
16
|
+
</template>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* A new conversation (§7.3): the member types a handle, the audience check says whether they can write directly, only
|
|
4
|
+
* by a request, or not now — one sentence for every reason, so that none is disclosed („Tomuto člověku teď nemůžete
|
|
5
|
+
* napsat“), and an unknown or hidden handle reads the same as one nobody has. There is no directory to browse.
|
|
6
|
+
*/
|
|
7
|
+
import { computed, ref } from 'vue'
|
|
8
|
+
import type { Lang } from '../../i18n'
|
|
9
|
+
import type { DmViewController } from '../controller'
|
|
10
|
+
import { dmText } from '../text'
|
|
11
|
+
|
|
12
|
+
const props = defineProps<{ dm: DmViewController; lang: Lang }>()
|
|
13
|
+
const emit = defineEmits<{ opened: [conversationId: string] }>()
|
|
14
|
+
const tx = computed(() => dmText(props.lang))
|
|
15
|
+
const handle = ref('')
|
|
16
|
+
const a = computed(() => props.dm.state.audience)
|
|
17
|
+
const failure = computed(() => props.dm.state.failures.new ?? null)
|
|
18
|
+
|
|
19
|
+
async function start(): Promise<void> {
|
|
20
|
+
const cid = await props.dm.openHandle(handle.value)
|
|
21
|
+
if (cid) {
|
|
22
|
+
handle.value = ''
|
|
23
|
+
emit('opened', cid)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<section class="bcm-p-screen" data-dm-screen="new">
|
|
30
|
+
<h3>{{ tx.pt('private.dm.new.title') }}</h3>
|
|
31
|
+
<form class="bcm-p-form bcm-p-row" @submit.prevent="dm.checkHandle(handle)">
|
|
32
|
+
<label class="bcm-p-sr" for="bcm-p-dm-handle">{{ tx.pt('private.dm.new.handle') }}</label>
|
|
33
|
+
<input id="bcm-p-dm-handle" v-model="handle" class="bcm-p-input" autocomplete="off" :placeholder="tx.pt('private.dm.new.placeholder')" data-handle />
|
|
34
|
+
<button type="submit" class="bcm-p-btn" :disabled="handle.trim() === '' || dm.state.busy" data-action="check-handle">{{ tx.pt('private.dm.new.check') }}</button>
|
|
35
|
+
</form>
|
|
36
|
+
<p v-if="failure === 'NOT_FOUND'" data-audience="unknown">{{ tx.pt('private.dm.new.unknown') }}</p>
|
|
37
|
+
<p v-else-if="failure" class="bcm-p-error" role="alert">{{ tx.err(failure) }}</p>
|
|
38
|
+
<template v-if="a && a.handle === handle.trim()">
|
|
39
|
+
<p v-if="a.canWrite === 'no'" data-audience="no">{{ tx.pt('private.dm.new.no') }}</p>
|
|
40
|
+
<template v-else>
|
|
41
|
+
<p :data-audience="a.canWrite">{{ tx.pt(a.canWrite === 'request' ? 'private.dm.new.request' : 'private.dm.new.direct') }}</p>
|
|
42
|
+
<button type="button" class="bcm-p-btn bcm-p-primary" :disabled="dm.state.busy" data-action="open-handle" @click="start()">{{ tx.pt('private.dm.new.open') }}</button>
|
|
43
|
+
</template>
|
|
44
|
+
</template>
|
|
45
|
+
</section>
|
|
46
|
+
</template>
|