Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

非ログインでリバーシの戦績が見れるように #404

Merged
merged 3 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading