Skip to content

Commit

Permalink
feat: アップデートのスキップ機能を追加 (#1708)
Browse files Browse the repository at this point in the history
* feat: アップデートのスキップ機能を追加

* FIX: 通知表示判定の処理をEditorHomeへ移動

* Apply suggestions from code review

---------

Co-authored-by: Hiroshiba <[email protected]>
  • Loading branch information
sabonerune and Hiroshiba authored Jan 15, 2024
1 parent e100dc9 commit 766131d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
25 changes: 22 additions & 3 deletions src/components/UpdateNotificationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,25 @@
</ul>
</template>
</q-card-section>
<q-card-actions align="center" class="button-area">
<q-card-actions class="button-area">
<q-checkbox
v-model="skipThisVersion"
size="xs"
dense
label="このバージョンをスキップ"
/>
<q-space />
<q-btn
padding="xs md"
label="キャンセル"
unelevated
color="surface"
text-color="display"
class="q-mt-sm"
@click="closeUpdateNotificationDialog()"
@click="
setSkipVersion();
closeUpdateNotificationDialog();
"
/>
<q-btn
padding="xs md"
Expand All @@ -56,7 +66,7 @@
</template>

<script setup lang="ts">
import { computed } from "vue";
import { computed, ref } from "vue";
import { UpdateInfo } from "@/type/preload";
const props =
Expand All @@ -70,6 +80,15 @@ const emit =
(e: "update:modelValue", value: boolean): void;
}>();
const skipThisVersion = ref<boolean>(false);
const setSkipVersion = () => {
if (skipThisVersion.value) {
// FIXME: window.electronを直に呼ばないようにする
window.electron.setSetting("skipUpdateVersion", props.latestVersion);
}
};
const modelValueComputed = computed({
get: () => props.modelValue,
set: (val) => emit("update:modelValue", val),
Expand Down
1 change: 1 addition & 0 deletions src/type/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ export const configSchema = z
.default({}),
registeredEngineDirs: z.string().array().default([]),
recentlyUsedProjects: z.string().array().default([]),
skipUpdateVersion: z.string().default(""), // FIXME: undefinedにする・rootMiscSettingSchemaに移す
})
.merge(rootMiscSettingSchema);
export type ConfigType = z.infer<typeof configSchema>;
Expand Down
14 changes: 12 additions & 2 deletions src/views/EditorHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ import draggable from "vuedraggable";
import { QResizeObserver } from "quasar";
import cloneDeep from "clone-deep";
import Mousetrap from "mousetrap";
import semver from "semver";
import { useStore } from "@/store";
import HeaderBar from "@/components/HeaderBar.vue";
import AudioCell from "@/components/AudioCell.vue";
Expand Down Expand Up @@ -644,8 +645,17 @@ onMounted(async () => {
import.meta.env.MODE !== "development" &&
store.state.acceptTerms !== "Accepted";
isUpdateNotificationDialogOpenComputed.value =
newUpdateResult.value.status == "updateAvailable";
if (newUpdateResult.value.status === "updateAvailable") {
const skipUpdateVersion = await window.electron.getSetting(
"skipUpdateVersion"
);
if (
semver.valid(skipUpdateVersion) == undefined ||
semver.gt(newUpdateResult.value.latestVersion, skipUpdateVersion)
) {
isUpdateNotificationDialogOpenComputed.value = true;
}
}
isCompletedInitialStartup.value = true;
});
Expand Down

0 comments on commit 766131d

Please sign in to comment.