mirror of
https://github.com/paricafe/misskey.git
synced 2024-12-01 05:16:44 -06:00
refactor(client): better semantics
This commit is contained in:
parent
57ec04d9ec
commit
b946d89ec1
32 changed files with 50 additions and 50 deletions
|
@ -205,18 +205,18 @@ export async function openAccountMenu(opts: {
|
|||
}, {
|
||||
text: i18n.ts.createAccount,
|
||||
action: () => { createAccount(); },
|
||||
}], ev.currentTarget || ev.target);
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
},
|
||||
}, {
|
||||
type: 'link',
|
||||
icon: 'fas fa-users',
|
||||
text: i18n.ts.manageAccounts,
|
||||
to: `/settings/accounts`,
|
||||
}]], ev.currentTarget || ev.target, {
|
||||
}]], ev.currentTarget ?? ev.target, {
|
||||
align: 'left'
|
||||
});
|
||||
} else {
|
||||
popupMenu([...(opts.includeCurrentAccount ? [createItem($i)] : []), ...accountItemPromises], ev.currentTarget || ev.target, {
|
||||
popupMenu([...(opts.includeCurrentAccount ? [createItem($i)] : []), ...accountItemPromises], ev.currentTarget ?? ev.target, {
|
||||
align: 'left'
|
||||
});
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ function onClick(ev: MouseEvent) {
|
|||
if (props.selectMode) {
|
||||
emit('chosen', props.file);
|
||||
} else {
|
||||
os.popupMenu(getMenu(), (ev.currentTarget || ev.target || undefined) as HTMLElement | undefined);
|
||||
os.popupMenu(getMenu(), (ev.currentTarget ?? ev.target || undefined) as HTMLElement | undefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -591,7 +591,7 @@ function getMenu() {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -280,7 +280,7 @@ function getKey(emoji: string | Misskey.entities.CustomEmoji | UnicodeEmojiDef):
|
|||
}
|
||||
|
||||
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) {
|
||||
const rect = el.getBoundingClientRect();
|
||||
const x = rect.left + (el.offsetWidth / 2);
|
||||
|
|
|
@ -113,7 +113,7 @@ export default defineComponent({
|
|||
if (menu.length > 0) menu.push(null);
|
||||
menu = menu.concat(props.menu);
|
||||
}
|
||||
popupMenu(menu, ev.currentTarget || ev.target);
|
||||
popupMenu(menu, ev.currentTarget ?? ev.target);
|
||||
};
|
||||
|
||||
const showTabsPopup = (ev: MouseEvent) => {
|
||||
|
@ -126,7 +126,7 @@ export default defineComponent({
|
|||
icon: tab.icon,
|
||||
action: tab.onClick,
|
||||
}));
|
||||
popupMenu(menu, ev.currentTarget || ev.target);
|
||||
popupMenu(menu, ev.currentTarget ?? ev.target);
|
||||
};
|
||||
|
||||
const preventDrag = (ev: TouchEvent) => {
|
||||
|
|
|
@ -160,7 +160,7 @@ export default defineComponent({
|
|||
action: () => {
|
||||
copyToClipboard(this.url);
|
||||
}
|
||||
}], ev.currentTarget || ev.target);
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
},
|
||||
|
||||
back() {
|
||||
|
|
|
@ -127,7 +127,7 @@ export default defineComponent({
|
|||
text: this.$ts.attachCancel,
|
||||
icon: 'fas fa-times-circle',
|
||||
action: () => { this.detachMedia(file.id) }
|
||||
}], ev.currentTarget || ev.target).then(() => this.menu = null);
|
||||
}], ev.currentTarget ?? ev.target).then(() => this.menu = null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -342,7 +342,7 @@ function focus() {
|
|||
}
|
||||
|
||||
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_) {
|
||||
files.push(file);
|
||||
}
|
||||
|
@ -592,7 +592,7 @@ function insertMention() {
|
|||
}
|
||||
|
||||
async function insertEmoji(ev: MouseEvent) {
|
||||
os.openEmojiPicker(ev.currentTarget || ev.target, {}, textareaEl);
|
||||
os.openEmojiPicker(ev.currentTarget ?? ev.target, {}, textareaEl);
|
||||
}
|
||||
|
||||
function showActions(ev) {
|
||||
|
@ -605,7 +605,7 @@ function showActions(ev) {
|
|||
if (key === 'text') { text = value; }
|
||||
});
|
||||
}
|
||||
})), ev.currentTarget || ev.target);
|
||||
})), ev.currentTarget ?? ev.target);
|
||||
}
|
||||
|
||||
let postAccount = $ref<misskey.entities.UserDetailed | null>(null);
|
||||
|
|
|
@ -109,7 +109,7 @@ export default defineComponent({
|
|||
text: 'Delete some bananas',
|
||||
danger: true,
|
||||
action: () => {},
|
||||
}], ev.currentTarget || ev.target);
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
},
|
||||
}
|
||||
});
|
||||
|
|
|
@ -78,7 +78,7 @@ export const menuDef = reactive({
|
|||
}];
|
||||
items.value = _items;
|
||||
});
|
||||
os.popupMenu(items, ev.currentTarget || ev.target);
|
||||
os.popupMenu(items, ev.currentTarget ?? ev.target);
|
||||
},
|
||||
},
|
||||
groups: {
|
||||
|
@ -109,7 +109,7 @@ export const menuDef = reactive({
|
|||
}];
|
||||
items.value = _items;
|
||||
});
|
||||
os.popupMenu(items, ev.currentTarget || ev.target);
|
||||
os.popupMenu(items, ev.currentTarget ?? ev.target);
|
||||
},
|
||||
},
|
||||
mentions: {
|
||||
|
@ -200,7 +200,7 @@ export const menuDef = reactive({
|
|||
localStorage.setItem('ui', 'desktop');
|
||||
unisonReload();
|
||||
}
|
||||
}*/], ev.currentTarget || ev.target);
|
||||
}*/], ev.currentTarget ?? ev.target);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -118,7 +118,7 @@ const toggleSelect = (emoji) => {
|
|||
};
|
||||
|
||||
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', {
|
||||
fileId: file.id,
|
||||
|
@ -160,7 +160,7 @@ const remoteMenu = (emoji, ev: MouseEvent) => {
|
|||
text: i18n.ts.import,
|
||||
icon: 'fas fa-plus',
|
||||
action: () => { im(emoji) }
|
||||
}], ev.currentTarget || ev.target);
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
};
|
||||
|
||||
const menu = (ev: MouseEvent) => {
|
||||
|
@ -186,7 +186,7 @@ const menu = (ev: MouseEvent) => {
|
|||
icon: 'fas fa-upload',
|
||||
text: i18n.ts.import,
|
||||
action: async () => {
|
||||
const file = await selectFile(ev.currentTarget || ev.target);
|
||||
const file = await selectFile(ev.currentTarget ?? ev.target);
|
||||
os.api('admin/emoji/import-zip', {
|
||||
fileId: file.id,
|
||||
})
|
||||
|
@ -202,7 +202,7 @@ const menu = (ev: MouseEvent) => {
|
|||
});
|
||||
});
|
||||
}
|
||||
}], ev.currentTarget || ev.target);
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
};
|
||||
|
||||
const setCategoryBulk = async () => {
|
||||
|
|
|
@ -298,7 +298,7 @@ export default defineComponent({
|
|||
action: () => {
|
||||
alert('TODO');
|
||||
}
|
||||
}], ev.currentTarget || ev.target);
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
};
|
||||
|
||||
return {
|
||||
|
|
|
@ -112,7 +112,7 @@ export default defineComponent({
|
|||
},
|
||||
|
||||
setBannerImage(e) {
|
||||
selectFile(e.currentTarget || e.target, null).then(file => {
|
||||
selectFile(e.currentTarget ?? e.target, null).then(file => {
|
||||
this.bannerId = file.id;
|
||||
});
|
||||
},
|
||||
|
|
|
@ -127,7 +127,7 @@ export default defineComponent({
|
|||
clipId: this.clip.id,
|
||||
});
|
||||
}
|
||||
} : undefined], ev.currentTarget || ev.target);
|
||||
} : undefined], ev.currentTarget ?? ev.target);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -29,7 +29,7 @@ function menu(ev) {
|
|||
copyToClipboard(`:${props.emoji.name}:`);
|
||||
os.success();
|
||||
}
|
||||
}], ev.currentTarget || ev.target);
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ function menu(ev) {
|
|||
});
|
||||
});
|
||||
}
|
||||
}], ev.currentTarget || ev.target);
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
|
|
|
@ -92,7 +92,7 @@ export default defineComponent({
|
|||
|
||||
methods: {
|
||||
selectFile(e) {
|
||||
selectFiles(e.currentTarget || e.target, null).then(files => {
|
||||
selectFiles(e.currentTarget ?? e.target, null).then(files => {
|
||||
this.files = this.files.concat(files);
|
||||
});
|
||||
},
|
||||
|
|
|
@ -128,7 +128,7 @@ export default defineComponent({
|
|||
text: this.$ts.messagingWithGroup,
|
||||
icon: 'fas fa-users',
|
||||
action: () => { this.startGroup() }
|
||||
}], ev.currentTarget || ev.target);
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
},
|
||||
|
||||
async startUser() {
|
||||
|
|
|
@ -154,7 +154,7 @@ export default defineComponent({
|
|||
},
|
||||
|
||||
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;
|
||||
});
|
||||
},
|
||||
|
@ -214,7 +214,7 @@ export default defineComponent({
|
|||
},
|
||||
|
||||
async insertEmoji(ev) {
|
||||
os.openEmojiPicker(ev.currentTarget || ev.target, {}, this.$refs.text);
|
||||
os.openEmojiPicker(ev.currentTarget ?? ev.target, {}, this.$refs.text);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -335,7 +335,7 @@ const Component = defineComponent({
|
|||
popout(path);
|
||||
this.$router.back();
|
||||
},
|
||||
}], ev.currentTarget || ev.target);
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -32,7 +32,7 @@ function setFilter(ev) {
|
|||
includeTypes = null;
|
||||
}
|
||||
}, null, ...typeItems] : typeItems;
|
||||
os.popupMenu(items, ev.currentTarget || ev.target);
|
||||
os.popupMenu(items, ev.currentTarget ?? ev.target);
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
|
|
|
@ -448,7 +448,7 @@ export default defineComponent({
|
|||
},
|
||||
|
||||
setEyeCatchingImage(e) {
|
||||
selectFile(e.currentTarget || e.target, null).then(file => {
|
||||
selectFile(e.currentTarget ?? e.target, null).then(file => {
|
||||
this.eyeCatchingImageId = file.id;
|
||||
});
|
||||
},
|
||||
|
|
|
@ -64,7 +64,7 @@ export default defineComponent({
|
|||
icon: 'fas fa-trash-alt',
|
||||
danger: true,
|
||||
action: () => this.removeAccount(account),
|
||||
}], ev.currentTarget || ev.target);
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
},
|
||||
|
||||
addAccount(ev) {
|
||||
|
@ -74,7 +74,7 @@ export default defineComponent({
|
|||
}, {
|
||||
text: this.$ts.createAccount,
|
||||
action: () => { this.createAccount(); },
|
||||
}], ev.currentTarget || ev.target);
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
},
|
||||
|
||||
addExistingAccount() {
|
||||
|
|
|
@ -114,22 +114,22 @@ export default defineComponent({
|
|||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ function save() {
|
|||
}
|
||||
|
||||
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', {
|
||||
avatarId: file.id,
|
||||
});
|
||||
|
@ -112,7 +112,7 @@ function changeAvatar(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', {
|
||||
bannerId: file.id,
|
||||
});
|
||||
|
|
|
@ -184,7 +184,7 @@ export default defineComponent({
|
|||
themesCount,
|
||||
wallpaper,
|
||||
setWallpaper(e) {
|
||||
selectFile(e.currentTarget || e.target, null).then(file => {
|
||||
selectFile(e.currentTarget ?? e.target, null).then(file => {
|
||||
wallpaper.value = file.url;
|
||||
});
|
||||
},
|
||||
|
|
|
@ -64,7 +64,7 @@ async function chooseList(ev: MouseEvent): Promise<void> {
|
|||
text: list.name,
|
||||
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> {
|
||||
|
@ -75,7 +75,7 @@ async function chooseAntenna(ev: MouseEvent): Promise<void> {
|
|||
indicate: antenna.hasUnreadNote,
|
||||
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> {
|
||||
|
@ -86,7 +86,7 @@ async function chooseChannel(ev: MouseEvent): Promise<void> {
|
|||
indicate: channel.hasUnreadNote,
|
||||
to: `/channels/${channel.id}`,
|
||||
}));
|
||||
os.popupMenu(items, ev.currentTarget || ev.target);
|
||||
os.popupMenu(items, ev.currentTarget ?? ev.target);
|
||||
}
|
||||
|
||||
function saveSrc(): void {
|
||||
|
|
|
@ -264,7 +264,7 @@ export default defineComponent({
|
|||
},
|
||||
|
||||
menu(ev) {
|
||||
os.popupMenu(getUserMenu(this.user), ev.currentTarget || ev.target);
|
||||
os.popupMenu(getUserMenu(this.user), ev.currentTarget ?? ev.target);
|
||||
},
|
||||
|
||||
parallaxLoop() {
|
||||
|
|
|
@ -135,7 +135,7 @@ export default defineComponent({
|
|||
action: () => {
|
||||
window.open(`https://misskey-hub.net/help.md`, '_blank');
|
||||
}
|
||||
}], ev.currentTarget || ev.target);
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
},
|
||||
|
||||
number
|
||||
|
|
|
@ -119,7 +119,7 @@ export default defineComponent({
|
|||
action: () => {
|
||||
window.open(`https://misskey-hub.net/help.md`, '_blank');
|
||||
}
|
||||
}], ev.currentTarget || ev.target);
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
},
|
||||
|
||||
number
|
||||
|
|
|
@ -139,7 +139,7 @@ export default defineComponent({
|
|||
action: () => {
|
||||
window.open(`https://misskey-hub.net/help.md`, '_blank');
|
||||
}
|
||||
}], ev.currentTarget || ev.target);
|
||||
}], ev.currentTarget ?? ev.target);
|
||||
},
|
||||
|
||||
number
|
||||
|
|
|
@ -116,7 +116,7 @@ const choose = async (ev) => {
|
|||
text: i18n.ts._timelines.global,
|
||||
icon: 'fas fa-globe',
|
||||
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;
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue