refactor(client): better semantics

This commit is contained in:
syuilo 2022-01-28 11:53:12 +09:00
parent 57ec04d9ec
commit b946d89ec1
32 changed files with 50 additions and 50 deletions

View File

@ -205,18 +205,18 @@ export async function openAccountMenu(opts: {
}, { }, {
text: i18n.ts.createAccount, text: i18n.ts.createAccount,
action: () => { createAccount(); }, action: () => { createAccount(); },
}], ev.currentTarget || ev.target); }], ev.currentTarget ?? ev.target);
}, },
}, { }, {
type: 'link', type: 'link',
icon: 'fas fa-users', icon: 'fas fa-users',
text: i18n.ts.manageAccounts, text: i18n.ts.manageAccounts,
to: `/settings/accounts`, to: `/settings/accounts`,
}]], ev.currentTarget || ev.target, { }]], ev.currentTarget ?? ev.target, {
align: 'left' align: 'left'
}); });
} else { } else {
popupMenu([...(opts.includeCurrentAccount ? [createItem($i)] : []), ...accountItemPromises], ev.currentTarget || ev.target, { popupMenu([...(opts.includeCurrentAccount ? [createItem($i)] : []), ...accountItemPromises], ev.currentTarget ?? ev.target, {
align: 'left' align: 'left'
}); });
} }

View File

@ -95,7 +95,7 @@ function onClick(ev: MouseEvent) {
if (props.selectMode) { if (props.selectMode) {
emit('chosen', props.file); emit('chosen', props.file);
} else { } else {
os.popupMenu(getMenu(), (ev.currentTarget || ev.target || undefined) as HTMLElement | undefined); os.popupMenu(getMenu(), (ev.currentTarget ?? ev.target || undefined) as HTMLElement | undefined);
} }
} }

View File

@ -591,7 +591,7 @@ function getMenu() {
} }
function showMenu(ev: MouseEvent) { function showMenu(ev: MouseEvent) {
os.popupMenu(getMenu(), (ev.currentTarget || ev.target || undefined) as HTMLElement | undefined); os.popupMenu(getMenu(), (ev.currentTarget ?? ev.target || undefined) as HTMLElement | undefined);
} }
function onContextmenu(ev: MouseEvent) { function onContextmenu(ev: MouseEvent) {

View File

@ -280,7 +280,7 @@ function getKey(emoji: string | Misskey.entities.CustomEmoji | UnicodeEmojiDef):
} }
function chosen(emoji: any, ev?: MouseEvent) { function chosen(emoji: any, ev?: MouseEvent) {
const el = ev && (ev.currentTarget || ev.target) as HTMLElement | null | undefined; const el = ev && (ev.currentTarget ?? ev.target) as HTMLElement | null | undefined;
if (el) { if (el) {
const rect = el.getBoundingClientRect(); const rect = el.getBoundingClientRect();
const x = rect.left + (el.offsetWidth / 2); const x = rect.left + (el.offsetWidth / 2);

View File

@ -113,7 +113,7 @@ export default defineComponent({
if (menu.length > 0) menu.push(null); if (menu.length > 0) menu.push(null);
menu = menu.concat(props.menu); menu = menu.concat(props.menu);
} }
popupMenu(menu, ev.currentTarget || ev.target); popupMenu(menu, ev.currentTarget ?? ev.target);
}; };
const showTabsPopup = (ev: MouseEvent) => { const showTabsPopup = (ev: MouseEvent) => {
@ -126,7 +126,7 @@ export default defineComponent({
icon: tab.icon, icon: tab.icon,
action: tab.onClick, action: tab.onClick,
})); }));
popupMenu(menu, ev.currentTarget || ev.target); popupMenu(menu, ev.currentTarget ?? ev.target);
}; };
const preventDrag = (ev: TouchEvent) => { const preventDrag = (ev: TouchEvent) => {

View File

@ -160,7 +160,7 @@ export default defineComponent({
action: () => { action: () => {
copyToClipboard(this.url); copyToClipboard(this.url);
} }
}], ev.currentTarget || ev.target); }], ev.currentTarget ?? ev.target);
}, },
back() { back() {

View File

@ -127,7 +127,7 @@ export default defineComponent({
text: this.$ts.attachCancel, text: this.$ts.attachCancel,
icon: 'fas fa-times-circle', icon: 'fas fa-times-circle',
action: () => { this.detachMedia(file.id) } action: () => { this.detachMedia(file.id) }
}], ev.currentTarget || ev.target).then(() => this.menu = null); }], ev.currentTarget ?? ev.target).then(() => this.menu = null);
} }
} }
}); });

View File

@ -342,7 +342,7 @@ function focus() {
} }
function chooseFileFrom(ev) { function chooseFileFrom(ev) {
selectFiles(ev.currentTarget || ev.target, i18n.ts.attachFile).then(files_ => { selectFiles(ev.currentTarget ?? ev.target, i18n.ts.attachFile).then(files_ => {
for (const file of files_) { for (const file of files_) {
files.push(file); files.push(file);
} }
@ -592,7 +592,7 @@ function insertMention() {
} }
async function insertEmoji(ev: MouseEvent) { async function insertEmoji(ev: MouseEvent) {
os.openEmojiPicker(ev.currentTarget || ev.target, {}, textareaEl); os.openEmojiPicker(ev.currentTarget ?? ev.target, {}, textareaEl);
} }
function showActions(ev) { function showActions(ev) {
@ -605,7 +605,7 @@ function showActions(ev) {
if (key === 'text') { text = value; } if (key === 'text') { text = value; }
}); });
} }
})), ev.currentTarget || ev.target); })), ev.currentTarget ?? ev.target);
} }
let postAccount = $ref<misskey.entities.UserDetailed | null>(null); let postAccount = $ref<misskey.entities.UserDetailed | null>(null);

View File

@ -109,7 +109,7 @@ export default defineComponent({
text: 'Delete some bananas', text: 'Delete some bananas',
danger: true, danger: true,
action: () => {}, action: () => {},
}], ev.currentTarget || ev.target); }], ev.currentTarget ?? ev.target);
}, },
} }
}); });

View File

@ -78,7 +78,7 @@ export const menuDef = reactive({
}]; }];
items.value = _items; items.value = _items;
}); });
os.popupMenu(items, ev.currentTarget || ev.target); os.popupMenu(items, ev.currentTarget ?? ev.target);
}, },
}, },
groups: { groups: {
@ -109,7 +109,7 @@ export const menuDef = reactive({
}]; }];
items.value = _items; items.value = _items;
}); });
os.popupMenu(items, ev.currentTarget || ev.target); os.popupMenu(items, ev.currentTarget ?? ev.target);
}, },
}, },
mentions: { mentions: {
@ -200,7 +200,7 @@ export const menuDef = reactive({
localStorage.setItem('ui', 'desktop'); localStorage.setItem('ui', 'desktop');
unisonReload(); unisonReload();
} }
}*/], ev.currentTarget || ev.target); }*/], ev.currentTarget ?? ev.target);
}, },
}, },
}); });

View File

@ -118,7 +118,7 @@ const toggleSelect = (emoji) => {
}; };
const add = async (ev: MouseEvent) => { const add = async (ev: MouseEvent) => {
const files = await selectFiles(ev.currentTarget || ev.target, null); const files = await selectFiles(ev.currentTarget ?? ev.target, null);
const promise = Promise.all(files.map(file => os.api('admin/emoji/add', { const promise = Promise.all(files.map(file => os.api('admin/emoji/add', {
fileId: file.id, fileId: file.id,
@ -160,7 +160,7 @@ const remoteMenu = (emoji, ev: MouseEvent) => {
text: i18n.ts.import, text: i18n.ts.import,
icon: 'fas fa-plus', icon: 'fas fa-plus',
action: () => { im(emoji) } action: () => { im(emoji) }
}], ev.currentTarget || ev.target); }], ev.currentTarget ?? ev.target);
}; };
const menu = (ev: MouseEvent) => { const menu = (ev: MouseEvent) => {
@ -186,7 +186,7 @@ const menu = (ev: MouseEvent) => {
icon: 'fas fa-upload', icon: 'fas fa-upload',
text: i18n.ts.import, text: i18n.ts.import,
action: async () => { action: async () => {
const file = await selectFile(ev.currentTarget || ev.target); const file = await selectFile(ev.currentTarget ?? ev.target);
os.api('admin/emoji/import-zip', { os.api('admin/emoji/import-zip', {
fileId: file.id, fileId: file.id,
}) })
@ -202,7 +202,7 @@ const menu = (ev: MouseEvent) => {
}); });
}); });
} }
}], ev.currentTarget || ev.target); }], ev.currentTarget ?? ev.target);
}; };
const setCategoryBulk = async () => { const setCategoryBulk = async () => {

View File

@ -298,7 +298,7 @@ export default defineComponent({
action: () => { action: () => {
alert('TODO'); alert('TODO');
} }
}], ev.currentTarget || ev.target); }], ev.currentTarget ?? ev.target);
}; };
return { return {

View File

@ -112,7 +112,7 @@ export default defineComponent({
}, },
setBannerImage(e) { setBannerImage(e) {
selectFile(e.currentTarget || e.target, null).then(file => { selectFile(e.currentTarget ?? e.target, null).then(file => {
this.bannerId = file.id; this.bannerId = file.id;
}); });
}, },

View File

@ -127,7 +127,7 @@ export default defineComponent({
clipId: this.clip.id, clipId: this.clip.id,
}); });
} }
} : undefined], ev.currentTarget || ev.target); } : undefined], ev.currentTarget ?? ev.target);
} }
} }
}); });

View File

@ -29,7 +29,7 @@ function menu(ev) {
copyToClipboard(`:${props.emoji.name}:`); copyToClipboard(`:${props.emoji.name}:`);
os.success(); os.success();
} }
}], ev.currentTarget || ev.target); }], ev.currentTarget ?? ev.target);
} }
</script> </script>

View File

@ -32,7 +32,7 @@ function menu(ev) {
}); });
}); });
} }
}], ev.currentTarget || ev.target); }], ev.currentTarget ?? ev.target);
} }
defineExpose({ defineExpose({

View File

@ -92,7 +92,7 @@ export default defineComponent({
methods: { methods: {
selectFile(e) { selectFile(e) {
selectFiles(e.currentTarget || e.target, null).then(files => { selectFiles(e.currentTarget ?? e.target, null).then(files => {
this.files = this.files.concat(files); this.files = this.files.concat(files);
}); });
}, },

View File

@ -128,7 +128,7 @@ export default defineComponent({
text: this.$ts.messagingWithGroup, text: this.$ts.messagingWithGroup,
icon: 'fas fa-users', icon: 'fas fa-users',
action: () => { this.startGroup() } action: () => { this.startGroup() }
}], ev.currentTarget || ev.target); }], ev.currentTarget ?? ev.target);
}, },
async startUser() { async startUser() {

View File

@ -154,7 +154,7 @@ export default defineComponent({
}, },
chooseFile(e) { chooseFile(e) {
selectFile(e.currentTarget || e.target, this.$ts.selectFile).then(file => { selectFile(e.currentTarget ?? e.target, this.$ts.selectFile).then(file => {
this.file = file; this.file = file;
}); });
}, },
@ -214,7 +214,7 @@ export default defineComponent({
}, },
async insertEmoji(ev) { async insertEmoji(ev) {
os.openEmojiPicker(ev.currentTarget || ev.target, {}, this.$refs.text); os.openEmojiPicker(ev.currentTarget ?? ev.target, {}, this.$refs.text);
} }
} }
}); });

View File

@ -335,7 +335,7 @@ const Component = defineComponent({
popout(path); popout(path);
this.$router.back(); this.$router.back();
}, },
}], ev.currentTarget || ev.target); }], ev.currentTarget ?? ev.target);
} }
} }
}); });

View File

@ -32,7 +32,7 @@ function setFilter(ev) {
includeTypes = null; includeTypes = null;
} }
}, null, ...typeItems] : typeItems; }, null, ...typeItems] : typeItems;
os.popupMenu(items, ev.currentTarget || ev.target); os.popupMenu(items, ev.currentTarget ?? ev.target);
} }
defineExpose({ defineExpose({

View File

@ -448,7 +448,7 @@ export default defineComponent({
}, },
setEyeCatchingImage(e) { setEyeCatchingImage(e) {
selectFile(e.currentTarget || e.target, null).then(file => { selectFile(e.currentTarget ?? e.target, null).then(file => {
this.eyeCatchingImageId = file.id; this.eyeCatchingImageId = file.id;
}); });
}, },

View File

@ -64,7 +64,7 @@ export default defineComponent({
icon: 'fas fa-trash-alt', icon: 'fas fa-trash-alt',
danger: true, danger: true,
action: () => this.removeAccount(account), action: () => this.removeAccount(account),
}], ev.currentTarget || ev.target); }], ev.currentTarget ?? ev.target);
}, },
addAccount(ev) { addAccount(ev) {
@ -74,7 +74,7 @@ export default defineComponent({
}, { }, {
text: this.$ts.createAccount, text: this.$ts.createAccount,
action: () => { this.createAccount(); }, action: () => { this.createAccount(); },
}], ev.currentTarget || ev.target); }], ev.currentTarget ?? ev.target);
}, },
addExistingAccount() { addExistingAccount() {

View File

@ -114,22 +114,22 @@ export default defineComponent({
}; };
const importFollowing = async (ev) => { const importFollowing = async (ev) => {
const file = await selectFile(ev.currentTarget || ev.target); const file = await selectFile(ev.currentTarget ?? ev.target);
os.api('i/import-following', { fileId: file.id }).then(onImportSuccess).catch(onError); os.api('i/import-following', { fileId: file.id }).then(onImportSuccess).catch(onError);
}; };
const importUserLists = async (ev) => { const importUserLists = async (ev) => {
const file = await selectFile(ev.currentTarget || ev.target); const file = await selectFile(ev.currentTarget ?? ev.target);
os.api('i/import-user-lists', { fileId: file.id }).then(onImportSuccess).catch(onError); os.api('i/import-user-lists', { fileId: file.id }).then(onImportSuccess).catch(onError);
}; };
const importMuting = async (ev) => { const importMuting = async (ev) => {
const file = await selectFile(ev.currentTarget || ev.target); const file = await selectFile(ev.currentTarget ?? ev.target);
os.api('i/import-muting', { fileId: file.id }).then(onImportSuccess).catch(onError); os.api('i/import-muting', { fileId: file.id }).then(onImportSuccess).catch(onError);
}; };
const importBlocking = async (ev) => { const importBlocking = async (ev) => {
const file = await selectFile(ev.currentTarget || ev.target); const file = await selectFile(ev.currentTarget ?? ev.target);
os.api('i/import-blocking', { fileId: file.id }).then(onImportSuccess).catch(onError); os.api('i/import-blocking', { fileId: file.id }).then(onImportSuccess).catch(onError);
}; };

View File

@ -102,7 +102,7 @@ function save() {
} }
function changeAvatar(ev) { function changeAvatar(ev) {
selectFile(ev.currentTarget || ev.target, i18n.ts.avatar).then(async (file) => { selectFile(ev.currentTarget ?? ev.target, i18n.ts.avatar).then(async (file) => {
const i = await os.apiWithDialog('i/update', { const i = await os.apiWithDialog('i/update', {
avatarId: file.id, avatarId: file.id,
}); });
@ -112,7 +112,7 @@ function changeAvatar(ev) {
} }
function changeBanner(ev) { function changeBanner(ev) {
selectFile(ev.currentTarget || ev.target, i18n.ts.banner).then(async (file) => { selectFile(ev.currentTarget ?? ev.target, i18n.ts.banner).then(async (file) => {
const i = await os.apiWithDialog('i/update', { const i = await os.apiWithDialog('i/update', {
bannerId: file.id, bannerId: file.id,
}); });

View File

@ -184,7 +184,7 @@ export default defineComponent({
themesCount, themesCount,
wallpaper, wallpaper,
setWallpaper(e) { setWallpaper(e) {
selectFile(e.currentTarget || e.target, null).then(file => { selectFile(e.currentTarget ?? e.target, null).then(file => {
wallpaper.value = file.url; wallpaper.value = file.url;
}); });
}, },

View File

@ -64,7 +64,7 @@ async function chooseList(ev: MouseEvent): Promise<void> {
text: list.name, text: list.name,
to: `/timeline/list/${list.id}`, to: `/timeline/list/${list.id}`,
})); }));
os.popupMenu(items, ev.currentTarget || ev.target); os.popupMenu(items, ev.currentTarget ?? ev.target);
} }
async function chooseAntenna(ev: MouseEvent): Promise<void> { async function chooseAntenna(ev: MouseEvent): Promise<void> {
@ -75,7 +75,7 @@ async function chooseAntenna(ev: MouseEvent): Promise<void> {
indicate: antenna.hasUnreadNote, indicate: antenna.hasUnreadNote,
to: `/timeline/antenna/${antenna.id}`, to: `/timeline/antenna/${antenna.id}`,
})); }));
os.popupMenu(items, ev.currentTarget || ev.target); os.popupMenu(items, ev.currentTarget ?? ev.target);
} }
async function chooseChannel(ev: MouseEvent): Promise<void> { async function chooseChannel(ev: MouseEvent): Promise<void> {
@ -86,7 +86,7 @@ async function chooseChannel(ev: MouseEvent): Promise<void> {
indicate: channel.hasUnreadNote, indicate: channel.hasUnreadNote,
to: `/channels/${channel.id}`, to: `/channels/${channel.id}`,
})); }));
os.popupMenu(items, ev.currentTarget || ev.target); os.popupMenu(items, ev.currentTarget ?? ev.target);
} }
function saveSrc(): void { function saveSrc(): void {

View File

@ -264,7 +264,7 @@ export default defineComponent({
}, },
menu(ev) { menu(ev) {
os.popupMenu(getUserMenu(this.user), ev.currentTarget || ev.target); os.popupMenu(getUserMenu(this.user), ev.currentTarget ?? ev.target);
}, },
parallaxLoop() { parallaxLoop() {

View File

@ -135,7 +135,7 @@ export default defineComponent({
action: () => { action: () => {
window.open(`https://misskey-hub.net/help.md`, '_blank'); window.open(`https://misskey-hub.net/help.md`, '_blank');
} }
}], ev.currentTarget || ev.target); }], ev.currentTarget ?? ev.target);
}, },
number number

View File

@ -119,7 +119,7 @@ export default defineComponent({
action: () => { action: () => {
window.open(`https://misskey-hub.net/help.md`, '_blank'); window.open(`https://misskey-hub.net/help.md`, '_blank');
} }
}], ev.currentTarget || ev.target); }], ev.currentTarget ?? ev.target);
}, },
number number

View File

@ -139,7 +139,7 @@ export default defineComponent({
action: () => { action: () => {
window.open(`https://misskey-hub.net/help.md`, '_blank'); window.open(`https://misskey-hub.net/help.md`, '_blank');
} }
}], ev.currentTarget || ev.target); }], ev.currentTarget ?? ev.target);
}, },
number number

View File

@ -116,7 +116,7 @@ const choose = async (ev) => {
text: i18n.ts._timelines.global, text: i18n.ts._timelines.global,
icon: 'fas fa-globe', icon: 'fas fa-globe',
action: () => { setSrc('global') } action: () => { setSrc('global') }
}, antennaItems.length > 0 ? null : undefined, ...antennaItems, listItems.length > 0 ? null : undefined, ...listItems], ev.currentTarget || ev.target).then(() => { }, antennaItems.length > 0 ? null : undefined, ...antennaItems, listItems.length > 0 ? null : undefined, ...listItems], ev.currentTarget ?? ev.target).then(() => {
menuOpened.value = false; menuOpened.value = false;
}); });
}; };