copy sharkey settings into new frontend preferences model
This commit is contained in:
parent
59ce4d6c28
commit
c371af34e8
50 changed files with 468 additions and 425 deletions
|
|
@ -3,11 +3,13 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { ref, Ref, computed, ComputedRef } from 'vue';
|
||||
import { ref, computed } from 'vue';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import type { Ref, ComputedRef } from 'vue';
|
||||
import type { MenuItem } from '@/types/menu.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { defaultStore } from '@/store.js';
|
||||
import { MenuItem } from '@/types/menu.js';
|
||||
import { prefer } from '@/preferences';
|
||||
import { store } from '@/store.js';
|
||||
|
||||
/*
|
||||
this script should eventually contain all Sharkey-specific bits of
|
||||
|
|
@ -30,7 +32,7 @@ export function visibilityIsAtLeast(a: Visibility | string, b: Visibility | stri
|
|||
}
|
||||
|
||||
export function boostMenuItems(appearNote: Ref<Misskey.entities.Note>, renote: (v: Visibility, l: boolean) => void): MenuItem[] {
|
||||
const localOnly = ref(defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly);
|
||||
const localOnly = ref(prefer.s.rememberNoteVisibility ? store.s.localOnly : prefer.s.defaultNoteLocalOnly);
|
||||
const effectiveVisibility = (
|
||||
appearNote.value.channel?.isSensitive
|
||||
? smallerVisibility(appearNote.value.visibility, 'home')
|
||||
|
|
@ -83,7 +85,7 @@ export function boostMenuItems(appearNote: Ref<Misskey.entities.Note>, renote: (
|
|||
export function computeRenoteTooltip(renoted: Ref<boolean>): ComputedRef<string> {
|
||||
return computed(() => {
|
||||
if (renoted.value) return i18n.ts.unrenote;
|
||||
if (defaultStore.state.showVisibilitySelectorOnBoost) return i18n.ts.renote;
|
||||
if (prefer.s.showVisibilitySelectorOnBoost) return i18n.ts.renote;
|
||||
return i18n.ts.renoteShift;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
type JsonLike = string | number | boolean | null | undefined | JsonLike[] | { [key: string]: JsonLike } | Map<string, JsonLike>;
|
||||
type JsonLike = string | number | boolean | null | undefined | JsonLike[] | { [key: string]: JsonLike | undefined } | Map<string, JsonLike>;
|
||||
|
||||
export function deepEqual(a: JsonLike, b: JsonLike): boolean {
|
||||
if (a === b) return true;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import type { MenuItem } from '@/types/menu.js';
|
|||
import { deepMerge } from '@/utility/merge.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { popupMenu } from '@/os.js';
|
||||
import { prefer } from '@/preferences';
|
||||
import { prefer } from '@/preferences.js';
|
||||
|
||||
export const followingTab = 'following' as const;
|
||||
export const mutualsTab = 'mutuals' as const;
|
||||
|
|
@ -37,7 +37,7 @@ export type FollowingFeedModel = {
|
|||
[Key in keyof FollowingFeedState]: WritableComputedRef<FollowingFeedState[Key]>;
|
||||
};
|
||||
|
||||
export interface FollowingFeedState {
|
||||
export type FollowingFeedState = {
|
||||
withNonPublic: boolean,
|
||||
withQuotes: boolean,
|
||||
withBots: boolean,
|
||||
|
|
@ -45,7 +45,7 @@ export interface FollowingFeedState {
|
|||
onlyFiles: boolean,
|
||||
userList: FollowingFeedTab,
|
||||
remoteWarningDismissed: boolean,
|
||||
}
|
||||
};
|
||||
|
||||
export const defaultFollowingFeedState: FollowingFeedState = {
|
||||
withNonPublic: false,
|
||||
|
|
@ -169,9 +169,9 @@ export function createModel(storage?: Ref<StorageInterface>): FollowingFeedModel
|
|||
};
|
||||
}
|
||||
|
||||
function createDefaultStorage() {
|
||||
function createDefaultStorage(): Ref<StorageInterface> {
|
||||
return computed(() => ({
|
||||
state: prefer.s.followingFeed,
|
||||
state: prefer.r.followingFeed,
|
||||
save(updated: typeof prefer.s.followingFeed) {
|
||||
prefer.s.followingFeed = updated;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ export function getNoteMenu(props: {
|
|||
noteId: appearNote.id,
|
||||
});
|
||||
|
||||
if (Date.now() - new Date(appearNote.createdAt).getTime() < 1000 * 60 && appearNote.userId === $i.id) {
|
||||
if (Date.now() - new Date(appearNote.createdAt).getTime() < 1000 * 60 && appearNote.userId === $i?.id) {
|
||||
claimAchievement('noteDeletedWithin1min');
|
||||
}
|
||||
});
|
||||
|
|
@ -541,7 +541,7 @@ export function getNoteMenu(props: {
|
|||
};
|
||||
|
||||
return {
|
||||
menu: menuItems,
|
||||
popupMenu: menuItems,
|
||||
cleanup,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,19 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Ref, defineAsyncComponent } from 'vue';
|
||||
import { defineAsyncComponent } from 'vue';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import * as os from '@/os.js';
|
||||
import { misskeyApi } from './misskey-api.js';
|
||||
import { MenuItem } from '@/types/menu.js';
|
||||
import { dateTimeFormat } from './intl-const.js';
|
||||
import type { Ref } from 'vue';
|
||||
import type { MenuItem } from '@/types/menu.js';
|
||||
import * as os from '@/os.js';
|
||||
|
||||
interface NoteEdit {
|
||||
oldDate: string;
|
||||
updatedAt: string;
|
||||
text: string | null;
|
||||
}
|
||||
|
||||
export async function getNoteVersionsMenu(props: {
|
||||
note: Misskey.entities.Note;
|
||||
|
|
@ -18,7 +24,7 @@ export async function getNoteVersionsMenu(props: {
|
|||
const isRenote = (
|
||||
props.note.renote != null &&
|
||||
props.note.text == null &&
|
||||
props.note.fileIds.length === 0 &&
|
||||
!props.note.fileIds?.length &&
|
||||
props.note.poll == null
|
||||
);
|
||||
|
||||
|
|
@ -26,11 +32,11 @@ export async function getNoteVersionsMenu(props: {
|
|||
|
||||
const cleanups = [] as (() => void)[];
|
||||
|
||||
function openVersion(info): void {
|
||||
function openVersion(info: NoteEdit): void {
|
||||
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/SkOldNoteWindow.vue')), {
|
||||
note: appearNote,
|
||||
oldText: info.text,
|
||||
updatedAt: info.oldDate ? info.oldDate : info.updatedAt,
|
||||
oldText: info.text ?? '',
|
||||
updatedAt: info.updatedAt,
|
||||
}, {
|
||||
closed: () => dispose(),
|
||||
});
|
||||
|
|
@ -43,9 +49,7 @@ export async function getNoteVersionsMenu(props: {
|
|||
|
||||
await statePromise.then((versions) => {
|
||||
for (const edit of versions) {
|
||||
const _time = edit.oldDate == null ? NaN :
|
||||
typeof edit.oldDate === 'number' ? edit.oldDate :
|
||||
(edit.oldDate instanceof Date ? edit.oldDate : new Date(edit.oldDate)).getTime();
|
||||
const _time = new Date(edit.oldDate).getTime();
|
||||
|
||||
menu.push({
|
||||
icon: 'ph-pencil-simple ph-bold ph-lg',
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
import { deepClone } from './clone.js';
|
||||
import type { Cloneable } from './clone.js';
|
||||
|
||||
export type DeepPartial<T> = {
|
||||
export type DeepPartial<T> = T | {
|
||||
[P in keyof T]?: T[P] extends Record<PropertyKey, unknown> ? DeepPartial<T[P]> : T[P];
|
||||
};
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ function isPureObject(value: unknown): value is Record<PropertyKey, unknown> {
|
|||
* valueにないキーをdefからもらう(再帰的)\
|
||||
* nullはそのまま、undefinedはdefの値
|
||||
**/
|
||||
export function deepMerge<X extends object | Record<PropertyKey, unknown>>(value: DeepPartial<X>, def: X): X {
|
||||
export function deepMerge<X extends Record<PropertyKey, unknown>>(value: DeepPartial<X>, def: X): X {
|
||||
if (isPureObject(value) && isPureObject(def)) {
|
||||
const result = deepClone(value as Cloneable) as X;
|
||||
for (const [k, v] of Object.entries(def) as [keyof X, X[keyof X]][]) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue