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

frontend: cosmos: Add last #2488

Merged
merged 4 commits into from Mar 26, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/frontend/src/components/app/DnsConfigurationMenu.vue
Expand Up @@ -143,7 +143,7 @@ export default Vue.extend({
return
}

dnsEntries[dnsEntries.length - 1]?.focus()
dnsEntries.last()?.focus()
})
},
remove_dns_entry(index: number) {
Expand Down
2 changes: 1 addition & 1 deletion core/frontend/src/components/common/StatusTextWatcher.vue
Expand Up @@ -34,7 +34,7 @@ export default {
mounted() {
this.listener = mavlink2rest.startListening('STATUSTEXT').setCallback((receivedMessage) => {
const text = receivedMessage.message.text.join('')
if (this.messages?.[this.messages.length - 1] === text) {
if (this.messages?.last() === text) {
return
}
if (new RegExp(this.filter).test(text)) {
Expand Down
8 changes: 7 additions & 1 deletion core/frontend/src/cosmos.ts
Expand Up @@ -3,6 +3,7 @@ export {}
declare global {
interface Array<T> {
first(): T | undefined;
last(): T | undefined;
isEmpty(): boolean;
}

Expand All @@ -15,7 +16,12 @@ declare global {

// eslint-disable-next-line
Array.prototype.first = function<T> (this: T[]): T | undefined {
return this.isEmpty() ? undefined : this[0]
return this[0]
}

// eslint-disable-next-line
Array.prototype.last = function<T> (this: T[]): T | undefined {
return this.at(-1)
}

// eslint-disable-next-line
Expand Down