Skip to content

Commit

Permalink
非ログインでリバーシの戦績が見れるように (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
kozakura913 authored Sep 4, 2024
1 parent 0aaa42f commit 851ec1f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG_YOJO.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
-

### Client
-
- Fix: 非ログインでリバーシの戦績が見れない不具合の修正 [#404](https://github.com/yojo-art/cherrypick/pull/404)

### Server
-
Expand Down
14 changes: 6 additions & 8 deletions packages/frontend/src/pages/reversi/game.board.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ import MkFolder from '@/components/MkFolder.vue';
import MkSwitch from '@/components/MkSwitch.vue';
import { deepClone } from '@/scripts/clone.js';
import { useInterval } from '@/scripts/use-interval.js';
import { signinRequired } from '@/account.js';
import { url } from '@/config.js';
import { i18n } from '@/i18n.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
Expand All @@ -164,8 +163,7 @@ import * as os from '@/os.js';
import { confetti } from '@/scripts/confetti.js';
import { defaultStore } from '@/store.js';
import { getStaticImageUrl } from '@/scripts/media-proxy.js';

const $i = signinRequired();
import { $i } from '@/account.js';

const props = defineProps<{
game: Misskey.entities.ReversiGameDetailed;
Expand All @@ -187,13 +185,13 @@ const engine = shallowRef<Reversi.Game>(Reversi.Serializer.restoreGame({
}));

const iAmPlayer = computed(() => {
return game.value.user1Id === $i.id || game.value.user2Id === $i.id;
return game.value.user1Id === $i?.id || game.value.user2Id === $i?.id;
});

const myColor = computed(() => {
if (!iAmPlayer.value) return null;
if (game.value.user1Id === $i.id && game.value.black === 1) return true;
if (game.value.user2Id === $i.id && game.value.black === 2) return true;
if (game.value.user1Id === $i?.id && game.value.black === 1) return true;
if (game.value.user2Id === $i?.id && game.value.black === 2) return true;
return false;
});

Expand Down Expand Up @@ -224,7 +222,7 @@ const isMyTurn = computed(() => {
if (!iAmPlayer.value) return false;
const u = turnUser.value;
if (u == null) return false;
return u.id === $i.id;
return u.id === $i?.id;
});

const isFederation = computed(() => {
Expand Down Expand Up @@ -376,7 +374,7 @@ async function onStreamLog(log) {
function onStreamEnded(x) {
game.value = deepClone(x.game);

if (game.value.winnerId === $i.id) {
if (game.value.winnerId === $i?.id) {
confetti({
duration: 1000 * 3,
});
Expand Down
6 changes: 2 additions & 4 deletions packages/frontend/src/pages/reversi/game.setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ import { computed, watch, ref, onMounted, shallowRef, onUnmounted } from 'vue';
import * as Misskey from 'cherrypick-js';
import * as Reversi from 'misskey-reversi';
import { i18n } from '@/i18n.js';
import { signinRequired } from '@/account.js';
import { deepClone } from '@/scripts/clone.js';
import MkButton from '@/components/MkButton.vue';
import MkRadios from '@/components/MkRadios.vue';
Expand All @@ -123,8 +122,7 @@ import MkFolder from '@/components/MkFolder.vue';
import * as os from '@/os.js';
import { MenuItem } from '@/types/menu.js';
import { useRouter } from '@/router/supplier.js';

const $i = signinRequired();
import { $i } from '@/account.js';

const router = useRouter();

Expand Down Expand Up @@ -222,7 +220,7 @@ function updateSettings(key: keyof Misskey.entities.ReversiGameDetailed) {
}

function onUpdateSettings({ userId, key, value }: { userId: string; key: keyof Misskey.entities.ReversiGameDetailed; value: any; }) {
if (userId === $i.id) return;
if (userId === $i?.id) return;
if (game.value[key] === value) return;
game.value[key] = value;
if (isReady.value) {
Expand Down
6 changes: 2 additions & 4 deletions packages/frontend/src/pages/reversi/game.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ import GameBoard from './game.board.vue';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { useStream } from '@/stream.js';
import { signinRequired } from '@/account.js';
import { useRouter } from '@/router/supplier.js';
import * as os from '@/os.js';
import { url } from '@/config.js';
import { i18n } from '@/i18n.js';
import { useInterval } from '@/scripts/use-interval.js';

const $i = signinRequired();
import { $i } from '@/account.js';

const router = useRouter();

Expand Down Expand Up @@ -74,7 +72,7 @@ async function fetchGame() {
connection.value.on('canceled', x => {
connection.value?.dispose();

if (x.userId !== $i.id) {
if (x.userId !== $i?.id) {
os.alert({
type: 'warning',
text: i18n.ts._reversi.gameCanceled,
Expand Down

0 comments on commit 851ec1f

Please sign in to comment.