forked from fruitriin/missRirica-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch.diff
2997 lines (2846 loc) · 96.8 KB
/
patch.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --color=auto -ru Ririca13/src/account.ts src/account.ts
--- Ririca13/src/account.ts 2023-02-13 09:01:19
+++ src/account.ts 2023-02-13 09:01:11
@@ -4,7 +4,6 @@
import { i18n } from "./i18n";
import { miLocalStorage } from "./local-storage";
import { del, get, set } from "@/scripts/idb-proxy";
-import { apiUrl } from "@/config";
import { waiting, api, popup, popupMenu, success, alert } from "@/os";
import { unisonReload, reloadChannel } from "@/scripts/unison-reload";
@@ -12,12 +11,16 @@
type Account = misskey.entities.MeDetailed;
-const accountData = miLocalStorage.getItem("account");
+let accountData = null;
+try {
+ accountData = JSON.parse(miLocalStorage.getItem("account"));
+} catch (e) {
+ miLocalStorage.removeItem("account");
+ window.location.reload();
+}
// TODO: 外部からはreadonlyに
-export const $i = accountData
- ? reactive(JSON.parse(accountData) as Account)
- : null;
+export const $i = accountData ? reactive(accountData as Account) : null;
export const iAmModerator = $i != null && ($i.isAdmin || $i.isModerator);
export const iAmAdmin = $i != null && $i.isAdmin;
@@ -34,52 +37,26 @@
await removeAccount($i.id);
const accounts = await getAccounts();
-
- //#region Remove service worker registration
- try {
- if (navigator.serviceWorker.controller) {
- const registration = await navigator.serviceWorker.ready;
- const push = await registration.pushManager.getSubscription();
- if (push) {
- await window.fetch(`${apiUrl}/sw/unregister`, {
- method: "POST",
- body: JSON.stringify({
- i: $i.token,
- endpoint: push.endpoint,
- }),
- headers: {
- "Content-Type": "application/json",
- },
- });
- }
- }
-
- if (accounts.length === 0) {
- await navigator.serviceWorker.getRegistrations().then((registrations) => {
- return Promise.all(
- registrations.map((registration) => registration.unregister())
- );
- });
- }
- } catch (err) {}
- //#endregion
-
document.cookie = "igi=; path=/";
- if (accounts.length > 0) login(accounts[0].token);
+ if (accounts.length > 0) login(accounts[0].token, accounts[0].instanceUrl);
else unisonReload("/");
}
export async function getAccounts(): Promise<
- { id: Account["id"]; token: Account["token"] }[]
+ { id: Account["id"]; token: Account["token"]; instanceUrl: string }[]
> {
return (await get("accounts")) || [];
}
-export async function addAccount(id: Account["id"], token: Account["token"]) {
+export async function addAccount(
+ id: Account["id"],
+ token: Account["token"],
+ instanceUrl: string
+) {
const accounts = await getAccounts();
if (!accounts.some((x) => x.id === id)) {
- await set("accounts", accounts.concat([{ id, token }]));
+ await set("accounts", accounts.concat([{ id, token, instanceUrl }]));
}
}
@@ -94,43 +71,32 @@
else await del("accounts");
}
-function fetchAccount(token: string): Promise<Account> {
- return new Promise((done, fail) => {
- // Fetch user
- window
- .fetch(`${apiUrl}/i`, {
- method: "POST",
- body: JSON.stringify({
- i: token,
- }),
- headers: {
- "Content-Type": "application/json",
- },
- })
- .then((res) => res.json())
- .then((res) => {
- if (res.error) {
- if (res.error.id === "a8c724b3-6e9c-4b46-b1a8-bc3ed6258370") {
- showSuspendedDialog().then(() => {
- signout();
- });
- } else {
- alert({
- type: "error",
- title: i18n.ts.failedToFetchAccountInformation,
- text: JSON.stringify(res.error),
- });
- }
- } else {
- res.token = token;
- done(res);
- }
- })
- .catch(fail);
- });
+function fetchAccount(
+ token: string,
+ instanceUrl: string
+): Promise<Account & { instanceUrl: string }> {
+ return new misskey.api.APIClient({ origin: instanceUrl, credential: token })
+ .request("i")
+ .then((res) => {
+ return { ...(res as Account), token, instanceUrl };
+ })
+ .catch((res) => {
+ if (res.error.id === "a8c724b3-6e9c-4b46-b1a8-bc3ed6258370") {
+ showSuspendedDialog().then(() => {
+ signout();
+ });
+ } else {
+ alert({
+ type: "error",
+ title: i18n.ts.failedToFetchAccountInformation,
+ text: JSON.stringify(res.error),
+ });
+ }
+ return Promise.reject(res);
+ });
}
-export function updateAccount(accountData) {
+export function updateAccount(accountData: Object) {
for (const [key, value] of Object.entries(accountData)) {
$i[key] = value;
}
@@ -138,16 +104,29 @@
}
export function refreshAccount() {
- return fetchAccount($i.token).then(updateAccount);
+ return fetchAccount($i.token, $i.instanceUrl).then(updateAccount);
}
-export async function login(token: Account["token"], redirect?: string) {
+export async function login(
+ token: Account["token"],
+ instanceUrl: string,
+ redirect?: string
+) {
waiting();
- if (_DEV_) console.log("logging as token ", token);
- const me = await fetchAccount(token);
+ if (_DEV_) console.log("logging as token ", token, instanceUrl);
+ const me = await fetchAccount(token, instanceUrl);
miLocalStorage.setItem("account", JSON.stringify(me));
+ miLocalStorage.setItem(
+ "instance",
+ JSON.stringify(
+ await new misskey.api.APIClient({
+ origin: instanceUrl,
+ credential: token,
+ }).request("meta")
+ )
+ );
document.cookie = `token=${token}; path=/; max-age=31536000`; // bull dashboardの認証とかで使う
- await addAccount(me.id, token);
+ await addAccount(me.id, token, instanceUrl);
if (redirect) {
// 他のタブは再読み込みするだけ
@@ -175,7 +154,7 @@
{},
{
done: (res) => {
- addAccount(res.id, res.i);
+ addAccount(res.id, res.i, res.instanceUrl);
success();
},
},
@@ -189,8 +168,8 @@
{},
{
done: (res) => {
- addAccount(res.id, res.i);
- switchAccountWithToken(res.i);
+ addAccount(res.id, res.i, res.instanceUrl);
+ switchAccountWithToken(res.i, res.instanceUrl);
},
},
"closed"
@@ -199,12 +178,13 @@
async function switchAccount(account: misskey.entities.UserDetailed) {
const storedAccounts = await getAccounts();
- const token = storedAccounts.find((x) => x.id === account.id).token;
- switchAccountWithToken(token);
+ const acc = storedAccounts.find((x) => x.id === account.id);
+ miLocalStorage.removeItem("lastEmojisFetchedAt");
+ switchAccountWithToken(acc.token, acc.instanceUrl);
}
- function switchAccountWithToken(token: string) {
- login(token);
+ function switchAccountWithToken(token: string, instanceUrl: string) {
+ login(token, instanceUrl);
}
const storedAccounts = await getAccounts().then((accounts) =>
@@ -232,11 +212,23 @@
const accountItemPromises = storedAccounts.map(
(a) =>
new Promise((res) => {
- accountsPromise.then((accounts) => {
- const account = accounts.find((x) => x.id === a.id);
- if (account == null) return res(null);
- res(createItem(account));
+ const client = new misskey.api.APIClient({
+ origin: a.instanceUrl,
+ credential: a.token,
});
+
+ client
+ .request("users/show", {
+ userIds: [a.id],
+ })
+ .then((accounts) => {
+ const account = accounts.find((x) => x.id === a.id);
+ if (account == null) return res(null);
+
+ client.request("meta").then((meta) => {
+ res(createItem({ ...account, host: meta.name }));
+ });
+ });
})
);
@@ -262,12 +254,6 @@
text: i18n.ts.existingAccount,
action: () => {
showSigninDialog();
- },
- },
- {
- text: i18n.ts.createAccount,
- action: () => {
- createAccount();
},
},
],
Only in src: assets
diff --color=auto -ru Ririca13/src/components/MkAchievements.vue src/components/MkAchievements.vue
--- Ririca13/src/components/MkAchievements.vue 2023-02-13 09:01:20
+++ src/components/MkAchievements.vue 2023-02-13 09:01:11
@@ -41,17 +41,11 @@
</div>
<div :class="$style.description">
{{
- withDescription
- ? i18n.ts._achievements._types["_" + achievement.name]
- .description
- : "???"
+ i18n.ts._achievements._types["_" + achievement.name].description
}}
</div>
<div
- v-if="
- i18n.ts._achievements._types['_' + achievement.name].flavor &&
- withDescription
- "
+ v-if="i18n.ts._achievements._types['_' + achievement.name].flavor"
:class="$style.flavor"
>
{{ i18n.ts._achievements._types["_" + achievement.name].flavor }}
@@ -97,11 +91,9 @@
defineProps<{
user: misskey.entities.User;
withLocked: boolean;
- withDescription: boolean;
}>(),
{
withLocked: true,
- withDescription: true,
}
);
diff --color=auto -ru Ririca13/src/components/MkClickerGame.vue src/components/MkClickerGame.vue
--- Ririca13/src/components/MkClickerGame.vue 2023-02-13 09:01:20
+++ src/components/MkClickerGame.vue 2023-02-13 09:01:12
@@ -12,7 +12,7 @@
:class="$style.button"
@click="onClick"
>
- <img src="/client-assets/cookie.png" :class="$style.img" />
+ <!-- <img src="/client-assets/cookie.png" :class="$style.img">-->
</button>
</div>
<div v-else>
diff --color=auto -ru Ririca13/src/components/MkFileListForAdmin.vue src/components/MkFileListForAdmin.vue
--- Ririca13/src/components/MkFileListForAdmin.vue 2023-02-13 09:01:20
+++ src/components/MkFileListForAdmin.vue 2023-02-13 09:01:12
@@ -47,7 +47,7 @@
<script lang="ts" setup>
import { computed } from "vue";
-import * as Acct from "misskey-js/built/acct";
+import * as Acct from "yamisskey-js/built/acct";
import MkPagination from "@/components/MkPagination.vue";
import MkDriveFileThumbnail from "@/components/MkDriveFileThumbnail.vue";
import bytes from "@/filters/bytes";
diff --color=auto -ru Ririca13/src/components/MkMention.vue src/components/MkMention.vue
--- Ririca13/src/components/MkMention.vue 2023-02-13 09:01:20
+++ src/components/MkMention.vue 2023-02-13 09:01:12
@@ -5,7 +5,11 @@
:to="url"
:style="{ background: bgCss }"
>
- <img :class="$style.icon" :src="`/avatar/@${username}@${host}`" alt="" />
+ <img
+ :class="$style.icon"
+ :src="`${$i.instanceUrl}/avatar/@${username}@${host}`"
+ alt=""
+ />
<span>
<span :class="$style.username">@{{ username }}</span>
<span
diff --color=auto -ru Ririca13/src/components/MkMenu.vue src/components/MkMenu.vue
--- Ririca13/src/components/MkMenu.vue 2023-02-13 09:01:20
+++ src/components/MkMenu.vue 2023-02-13 09:01:12
@@ -89,6 +89,7 @@
<MkAvatar :user="item.user" :class="$style.avatar" /><MkUserName
:user="item.user"
/>
+ [{{ item.user.host }}]
<span v-if="item.indicate" :class="$style.indicator"
><i class="_indicatorCircle"></i
></span>
diff --color=auto -ru Ririca13/src/components/MkNotification.vue src/components/MkNotification.vue
--- Ririca13/src/components/MkNotification.vue 2023-02-13 09:01:21
+++ src/components/MkNotification.vue 2023-02-13 09:01:13
@@ -55,7 +55,7 @@
></i>
<i
v-else-if="notification.type === 'achievementEarned'"
- class="ti ti-medal"
+ class="ti ti-military-award"
></i>
<!-- notification.reaction が null になることはまずないが、ここでoptional chaining使うと一部ブラウザで刺さるので念の為 -->
<MkReactionIcon
@@ -432,7 +432,7 @@
.t_achievementEarned {
padding: 3px;
- background: #cb9a11;
+ background: #88a6b7;
pointer-events: none;
}
diff --color=auto -ru Ririca13/src/components/MkPostForm.vue src/components/MkPostForm.vue
--- Ririca13/src/components/MkPostForm.vue 2023-02-13 09:01:21
+++ src/components/MkPostForm.vue 2023-02-13 09:01:13
@@ -252,7 +252,7 @@
import insertTextAtCursor from "insert-text-at-cursor";
import { length } from "stringz";
import { toASCII } from "punycode/";
-import * as Acct from "misskey-js/built/acct";
+import * as Acct from "yamisskey-js/built/acct";
import { throttle } from "throttle-debounce";
import MkNoteSimple from "@/components/MkNoteSimple.vue";
import XNotePreview from "@/components/MkNotePreview.vue";
@@ -811,7 +811,7 @@
visibility: visibility,
localOnly: localOnly,
files: files,
- poll: poll,
+ poll: poll || undefined,
},
};
diff --color=auto -ru Ririca13/src/components/MkReactionsViewer.reaction.vue src/components/MkReactionsViewer.reaction.vue
--- Ririca13/src/components/MkReactionsViewer.reaction.vue 2023-02-13 09:01:21
+++ src/components/MkReactionsViewer.reaction.vue 2023-02-13 09:01:13
@@ -27,7 +27,6 @@
import { $i } from "@/account";
import MkReactionEffect from "@/components/MkReactionEffect.vue";
import { claimAchievement } from "@/scripts/achievements";
-import { defaultStore } from "@/store";
const props = defineProps<{
reaction: string;
@@ -72,7 +71,6 @@
const anime = () => {
if (document.hidden) return;
- if (!defaultStore.state.animation) return;
const rect = buttonEl.value.getBoundingClientRect();
const x = rect.left + 16;
diff --color=auto -ru Ririca13/src/components/MkSignin.vue src/components/MkSignin.vue
--- Ririca13/src/components/MkSignin.vue 2023-02-13 09:01:21
+++ src/components/MkSignin.vue 2023-02-13 09:01:13
@@ -1,134 +1,55 @@
<template>
- <form
- class="eppvobhk"
- :class="{ signing, totpLogin }"
- @submit.prevent="onSubmit"
- >
- <div class="auth _gaps_m">
- <div
- v-show="withAvatar"
- class="avatar"
- :style="{
- backgroundImage: user ? `url('${user.avatarUrl}')` : null,
- marginBottom: message ? '1.5em' : null,
- }"
- ></div>
- <MkInfo v-if="message">
- {{ message }}
- </MkInfo>
- <div v-if="!totpLogin" class="normal-signin _gaps_m">
+ <form class="eppvobhk" :class="{ signing }" @submit.prevent="onSubmit">
+ <div class="normal-signin">
+ {{ i18n.ts.ririca.instance }}
+ <MkSelect v-model="instanceUrl" large :model-value="instances[0]?.url">
+ <option value="other">
+ {{ i18n.ts.ririca.selectInstanceYourself }}
+ </option>
+ <option
+ v-for="(instance, i) in instances"
+ :key="instance.url"
+ :value="instance.url"
+ :selected="i === 0"
+ >
+ {{ instance.name }}
+ </option>
+ </MkSelect>
+ <template v-if="instanceUrl === 'other'">
+ URL
<MkInput
- v-model="username"
- :placeholder="i18n.ts.username"
- type="text"
- pattern="^[a-zA-Z0-9_]+$"
+ v-model="instanceUrlOther"
:spellcheck="false"
- autocomplete="username"
autofocus
required
- data-cy-signin-username
- @update:model-value="onUsernameChange"
- >
- <template #prefix>@</template>
- <template #suffix>@{{ host }}</template>
- </MkInput>
- <MkInput
- v-if="!user || (user && !user.usePasswordLessLogin)"
- v-model="password"
- :placeholder="i18n.ts.password"
- type="password"
- :with-password-toggle="true"
- required
- data-cy-signin-password
- >
- <template #prefix><i class="ti ti-lock"></i></template>
- <template #caption
- ><button class="_textButton" type="button" @click="resetPassword">
- {{ i18n.ts.forgotPassword }}
- </button></template
- >
- </MkInput>
- <MkButton
- type="submit"
- large
- primary
- rounded
- :disabled="signing"
- style="margin: 0 auto"
- >{{ signing ? i18n.ts.loggingIn : i18n.ts.login }}</MkButton
- >
- </div>
- <div
- v-if="totpLogin"
- class="2fa-signin"
- :class="{ securityKeys: user && user.securityKeys }"
+ />
+ </template>
+ {{ i18n.ts.ririca.accessToken }}
+ <MkInput
+ v-model="token"
+ :spellcheck="false"
+ autofocus
+ required
+ data-cy-signin-username
+ ></MkInput>
+ <MkButton
+ class="_formBlock"
+ type="submit"
+ primary
+ :disabled="signing"
+ style="margin: 0 auto"
>
- <div v-if="user && user.securityKeys" class="twofa-group tap-group">
- <p>{{ i18n.ts.tapSecurityKey }}</p>
- <MkButton v-if="!queryingKey" @click="queryKey">
- {{ i18n.ts.retry }}
- </MkButton>
- </div>
- <div v-if="user && user.securityKeys" class="or-hr">
- <p class="or-msg">{{ i18n.ts.or }}</p>
- </div>
- <div class="twofa-group totp-group">
- <p style="margin-bottom: 0">{{ i18n.ts.twoStepAuthentication }}</p>
- <MkInput
- v-if="user && user.usePasswordLessLogin"
- v-model="password"
- type="password"
- :with-password-toggle="true"
- required
- >
- <template #label>{{ i18n.ts.password }}</template>
- <template #prefix><i class="ti ti-lock"></i></template>
- </MkInput>
- <MkInput
- v-model="token"
- type="text"
- pattern="^[0-9]{6}$"
- autocomplete="off"
- :spellcheck="false"
- required
- >
- <template #label>{{ i18n.ts.token }}</template>
- <template #prefix><i class="ti ti-123"></i></template>
- </MkInput>
- <MkButton
- type="submit"
- :disabled="signing"
- large
- primary
- rounded
- style="margin: 0 auto"
- >{{ signing ? i18n.ts.loggingIn : i18n.ts.login }}</MkButton
- >
- </div>
- </div>
+ {{ signing ? i18n.ts.loggingIn : i18n.ts.login }}
+ </MkButton>
</div>
- <div class="social">
+
+ <div style="display: flex; justify-content: center">
<a
- v-if="meta && meta.enableTwitterIntegration"
- class="_borderButton _margin"
- :href="`${apiUrl}/signin/twitter`"
- ><i class="ti ti-brand-twitter" style="margin-right: 4px"></i
- >{{ $t("signinWith", { x: "Twitter" }) }}</a
+ href="https://misskey.io/notes/99l9jqqun2"
+ target="_blank"
+ style="color: var(--link); text-align: center"
+ >{{ i18n.ts.ririca.howToCreateToken }}</a
>
- <a
- v-if="meta && meta.enableGithubIntegration"
- class="_borderButton _margin"
- :href="`${apiUrl}/signin/github`"
- ><i class="ti ti-brand-github" style="margin-right: 4px"></i
- >{{ $t("signinWith", { x: "GitHub" }) }}</a
- >
- <a
- v-if="meta && meta.enableDiscordIntegration"
- class="_borderButton _margin"
- :href="`${apiUrl}/signin/discord`"
- ><i class="ti ti-brand-discord" style="margin-right: 4px"></i
- >{{ $t("signinWith", { x: "Discord" }) }}</a
- >
</div>
</form>
</template>
@@ -140,7 +61,7 @@
import MkButton from "@/components/MkButton.vue";
import MkInput from "@/components/MkInput.vue";
import MkInfo from "@/components/MkInfo.vue";
-import { apiUrl, host as configHost } from "@/config";
+import MkSelect from "@/components/MkSelect.vue";
import { byteify, hexify } from "@/scripts/2fa";
import * as os from "@/os";
import { login } from "@/account";
@@ -152,14 +73,15 @@
let username = $ref("");
let password = $ref("");
let token = $ref("");
-let host = $ref(toUnicode(configHost));
-let totpLogin = $ref(false);
let credential = $ref(null);
let challengeData = $ref(null);
let queryingKey = $ref(false);
let hCaptchaResponse = $ref(null);
let reCaptchaResponse = $ref(null);
+const instanceUrl = $ref("");
+const instanceUrlOther = $ref("");
+
const meta = $computed(() => instance);
const emit = defineEmits<{
@@ -197,12 +119,21 @@
);
}
-function onLogin(res) {
+function onLogin(res: any) {
if (props.autoSet) {
- return login(res.i);
+ return login(res.i, res.instance);
}
}
+const instanceUrlResult = $computed(() => {
+ if (instanceUrl === "other") {
+ // うっかりhttps://を入れてもreplaceされるから大丈夫
+ // new URL.origin
+ return new URL("https://" + instanceUrlOther.replace("https://", ""))
+ .origin;
+ }
+ return "https://" + instanceUrl;
+});
function queryKey() {
queryingKey = true;
return navigator.credentials
@@ -237,8 +168,8 @@
});
})
.then((res) => {
- emit("login", res);
- return onLogin(res);
+ emit("login", { ...res, instance: instanceUrl });
+ return onLogin({ ...res, instance: instanceUrl });
})
.catch((err) => {
if (err === null) return;
@@ -253,38 +184,9 @@
function onSubmit() {
signing = true;
console.log("submit");
- if (!totpLogin && user && user.twoFactorEnabled) {
- if (window.PublicKeyCredential && user.securityKeys) {
- os.api("signin", {
- username,
- password,
- "hcaptcha-response": hCaptchaResponse,
- "g-recaptcha-response": reCaptchaResponse,
- })
- .then((res) => {
- totpLogin = true;
- signing = false;
- challengeData = res;
- return queryKey();
- })
- .catch(loginFailed);
- } else {
- totpLogin = true;
- signing = false;
- }
- } else {
- os.api("signin", {
- username,
- password,
- "hcaptcha-response": hCaptchaResponse,
- "g-recaptcha-response": reCaptchaResponse,
- token: user && user.twoFactorEnabled ? token : undefined,
- })
- .then((res) => {
- emit("login", res);
- onLogin(res);
- })
- .catch(loginFailed);
+ if (!token.value) {
+ login(token, instanceUrlResult);
+ signing = false;
}
}
@@ -341,6 +243,13 @@
"closed"
);
}
+
+let instances = $ref([]);
+fetch("https://instanceapp.misskey.page/instances.json").then((res) => {
+ res.json().then((data) => {
+ instances = data.instancesInfos;
+ });
+});
</script>
<style lang="scss" scoped>
diff --color=auto -ru Ririca13/src/components/MkUserPreview.vue src/components/MkUserPreview.vue
--- Ririca13/src/components/MkUserPreview.vue 2023-02-13 09:01:21
+++ src/components/MkUserPreview.vue 2023-02-13 09:01:13
@@ -77,7 +77,7 @@
<script lang="ts" setup>
import { onMounted } from "vue";
-import * as Acct from "misskey-js/built/acct";
+import * as Acct from "yamisskey-js/built/acct";
import * as misskey from "misskey-js";
import MkFollowButton from "@/components/MkFollowButton.vue";
import { userPage } from "@/filters/user";
diff --color=auto -ru Ririca13/src/components/global/MkAd.vue src/components/global/MkAd.vue
--- Ririca13/src/components/global/MkAd.vue 2023-02-13 09:01:19
+++ src/components/global/MkAd.vue 2023-02-13 09:01:11
@@ -26,7 +26,7 @@
>{{ $ts._ad.reduceFrequencyOfThisAd }}</MkButton
>
<MkButton
- v-if="$i && $i.policies.canHideAds"
+ v-if="$i && $i?.policies?.canHideAds"
:class="$style.menuButton"
@click="hide"
>{{ $ts._ad.hide }}</MkButton
@@ -111,7 +111,7 @@
let shouldHide = $ref(
chosen.value &&
$i &&
- $i.policies.canHideAds &&
+ $i?.policies?.canHideAds &&
defaultStore.state.hiddenAds.includes(chosen.value.id)
);
diff --color=auto -ru Ririca13/src/components/global/MkAvatar.vue src/components/global/MkAvatar.vue
--- Ririca13/src/components/global/MkAvatar.vue 2023-02-13 09:01:19
+++ src/components/global/MkAvatar.vue 2023-02-13 09:01:11
@@ -48,6 +48,7 @@
import { acct, userPage } from "@/filters/user";
import MkUserOnlineIndicator from "@/components/MkUserOnlineIndicator.vue";
import { defaultStore } from "@/store";
+import { $i } from "@/account";
const props = withDefaults(
defineProps<{
diff --color=auto -ru Ririca13/src/components/global/MkEmoji.vue src/components/global/MkEmoji.vue
--- Ririca13/src/components/global/MkEmoji.vue 2023-02-13 09:01:19
+++ src/components/global/MkEmoji.vue 2023-02-13 09:01:11
@@ -16,7 +16,7 @@
<img
v-else-if="char && !useOsNativeEmojis"
:class="$style.root"
- :src="url"
+ :src="char2path(char)"
:alt="alt"
decoding="async"
@pointerenter="computeTitle"
@@ -40,6 +40,7 @@
import { defaultStore } from "@/store";
import { getEmojiName } from "@/scripts/emojilist";
import { customEmojis } from "@/custom-emojis";
+import { url as instanceUrl } from "@/config";
const props = defineProps<{
emoji: string;
@@ -64,14 +65,13 @@
);
const url = computed(() => {
if (char.value) {
- return char2path(char.value);
} else if (props.host == null && !customEmojiName.includes("@")) {
const found = customEmojis.find((x) => x.name === customEmojiName);
return found ? found.url : null;
} else {
const rawUrl = props.host
- ? `/emoji/${customEmojiName}@${props.host}.webp`
- : `/emoji/${customEmojiName}.webp`;
+ ? `${instanceUrl}/emoji/${customEmojiName}@${props.host}.webp`
+ : `${instanceUrl}/emoji/${customEmojiName}.webp`;
return defaultStore.state.disableShowingAnimatedImages
? getStaticImageUrl(rawUrl)
: rawUrl;
diff --color=auto -ru Ririca13/src/components/global/MkStickyContainer.vue src/components/global/MkStickyContainer.vue
--- Ririca13/src/components/global/MkStickyContainer.vue 2023-02-13 09:01:20
+++ src/components/global/MkStickyContainer.vue 2023-02-13 09:01:11
@@ -24,7 +24,10 @@
let headerHeight = $ref<string | undefined>();
let childStickyTop = $ref(0);
-const parentStickyTop = inject<Ref<number>>(CURRENT_STICKY_TOP, ref(0));
+const parentStickyTop = inject<Ref<number>>(
+ CURRENT_STICKY_TOP,
+ ref(document.querySelector<HTMLElement>("#header")?.offsetHeight)
+);
provide(CURRENT_STICKY_TOP, $$(childStickyTop));
const calc = () => {
diff --color=auto -ru Ririca13/src/config.ts src/config.ts
--- Ririca13/src/config.ts 2023-02-13 09:01:22
+++ src/config.ts 2023-02-13 09:01:13
@@ -1,24 +1,19 @@
import { miLocalStorage } from "./local-storage";
+import { $i } from "@/account";
+import { langNames } from "@/i18n";
-const address = new URL(location.href);
+const address = $i ? new URL($i.instanceUrl) : null;
const siteName = (
document.querySelector('meta[property="og:site_name"]') as HTMLMetaElement
)?.content;
-export const host = address.host;
-export const hostname = address.hostname;
-export const url = address.origin;
+export const host = address?.host;
+export const hostname = address?.hostname;
+export const url = $i?.instanceUrl;
export const apiUrl = url + "/api";
-export const wsUrl =
- url.replace("http://", "ws://").replace("https://", "wss://") + "/streaming";
export const lang = miLocalStorage.getItem("lang");
-export const langs = _LANGS_;
-export let locale = JSON.parse(miLocalStorage.getItem("locale"));
+export const langs = langNames;
export const version = _VERSION_;
export const instanceName = siteName === "Misskey" ? host : siteName;
export const ui = miLocalStorage.getItem("ui");
export const debug = miLocalStorage.getItem("debug") === "true";
-
-export function updateLocale(newLocale) {
- locale = newLocale;
-}
diff --color=auto -ru Ririca13/src/filters/user.ts src/filters/user.ts
--- Ririca13/src/filters/user.ts 2023-02-13 09:01:22
+++ src/filters/user.ts 2023-02-13 09:01:14
@@ -1,5 +1,5 @@
import * as misskey from "misskey-js";
-import * as Acct from "misskey-js/built/acct";
+import * as Acct from "yamisskey-js/built/acct";
import { url } from "@/config";
export const acct = (user: misskey.Acct) => {
diff --color=auto -ru Ririca13/src/i18n.ts src/i18n.ts
--- Ririca13/src/i18n.ts 2023-02-13 09:01:22
+++ src/i18n.ts 2023-02-13 09:01:14
@@ -1,9 +1,75 @@
-import { markRaw } from "vue";
-import { locale } from "@/config";
import { I18n } from "@/scripts/i18n";
+import arSA from "@/locales/ar-SA.json";
+import csCZ from "@/locales/cs-CZ.json";
+import daDK from "@/locales/da-DK.json";
+import deDE from "@/locales/de-DE.json";
+import enUS from "@/locales/en-US.json";
+import esES from "@/locales/es-ES.json";
+import frFR from "@/locales/fr-FR.json";
+import idID from "@/locales/id-ID.json";
+import itIT from "@/locales/it-IT.json";
+import jaJP from "@/locales/ja-JP.json";
+import jaKS from "@/locales/ja-KS.json";
+import kabKAB from "@/locales/kab-KAB.json";
+import knIN from "@/locales/kn-IN.json";
+import koKR from "@/locales/ko-KR.json";
+import nlNL from "@/locales/nl-NL.json";
+import noNO from "@/locales/no-NO.json";
+import plPL from "@/locales/pl-PL.json";
+import ptPT from "@/locales/pt-PT.json";
+import ruRU from "@/locales/ru-RU.json";
+import skSK from "@/locales/sk-SK.json";
+import ugCN from "@/locales/ug-CN.json";
+import ukUA from "@/locales/uk-UA.json";
+import viVN from "@/locales/vi-VN.json";
+import zhCN from "@/locales/zh-CN.json";
+import zhTW from "@/locales/zh-TW.json";
-export const i18n = markRaw(new I18n(locale));
+import Fuse from "fuse.js";
-export function updateI18n(newLocale) {
- i18n.ts = newLocale;
+const languages = {
+ "ar-SA": arSA,
+ "cs-CZ": csCZ,
+ "da-DK": daDK,
+ "de-DE": deDE,
+ "en-US": enUS,
+ "es-ES": esES,
+ "fr-FR": frFR,
+ "id-ID": idID,
+ "it-IT": itIT,
+ "ja-JP": jaJP,
+ "ja-KS": jaKS,
+ "kab-KAB": kabKAB,
+ "kn-IN": knIN,
+ "ko-KR": koKR,
+ "nl-NL": nlNL,
+ "no-NO": noNO,
+ "pl-PL": plPL,
+ "pt-PT": ptPT,
+ "ru-RU": ruRU,
+ "sk-SK": skSK,
+ "ug-CN": ugCN,
+ "uk-UA": ukUA,
+ "vi-VN": viVN,
+ "zh-CN": zhCN,
+ "zh-TW": zhTW,
+} as const;
+
+export let langNames = Object.keys(languages).map((l) => {
+ return [l, languages[l]._lang_];
+});
+
+export function setLanguage(lang: keyof typeof languages) {
+ console.log(lang);
+ if (Object.keys(languages).includes(lang)) {
+ i18n = new I18n(languages[lang]);
+ return lang;
+ } else {
+ const fuse = new Fuse(Object.keys(languages));
+ const results = fuse.search(lang);
+ i18n = new I18n(languages[results[0].item]);
+ console.log(results[0]);
+ return results[0].item;
+ }
}
+export let i18n = new I18n(languages["ja-JP"]);
diff --color=auto -ru Ririca13/src/init.ts src/init.ts
--- Ririca13/src/init.ts 2023-02-13 09:01:22
+++ src/init.ts 2023-02-13 09:01:14
@@ -32,10 +32,10 @@
import widgets from "@/widgets";
import directives from "@/directives";
import components from "@/components";
-import { version, ui, lang, host, updateLocale } from "@/config";
+import { version, ui } from "@/config";
import { applyTheme } from "@/scripts/theme";
import { isDeviceDarkmode } from "@/scripts/is-device-darkmode";
-import { i18n, updateI18n } from "@/i18n";
+import { i18n, setLanguage } from "@/i18n";
import { confirm, alert, post, popup, toast } from "@/os";
import { stream } from "@/stream";
import * as sound from "@/scripts/sound";
@@ -53,9 +53,19 @@
import { miLocalStorage } from "./local-storage";
import { claimAchievement, claimedAchievements } from "./scripts/achievements";
import { fetchCustomEmojis } from "./custom-emojis";
+import { Device } from "@capacitor/device";
+import lightTheme from "@/themes/_light.json5";
+import OneSignal from "onesignal-cordova-plugin";
+import { App } from "@capacitor/app";
+export let storedDeviceInfo: Object;
(async () => {
console.info(`Misskey v${version}`);
+ const lang = await setLanguage(
+ localStorage.getItem("lang") ||
+ (await Device.getLanguageCode().value) ||
+ "ja-JP"
+ );
if (_DEV_) {
console.warn("Development mode!!!");
@@ -88,22 +98,6 @@
});
}
- //#region Detect language & fetch translations
- const localeVersion = miLocalStorage.getItem("localeVersion");
- const localeOutdated = localeVersion == null || localeVersion !== version;
- if (localeOutdated) {
- const res = await window.fetch(`/assets/locales/${lang}.${version}.json`);
- if (res.status === 200) {
- const newLocale = await res.text();
- const parsedNewLocale = JSON.parse(newLocale);
- miLocalStorage.setItem("locale", newLocale);
- miLocalStorage.setItem("localeVersion", version);
- updateLocale(parsedNewLocale);
- updateI18n(parsedNewLocale);
- }