Skip to content

Commit

Permalink
refactor: update reconnection use in views
Browse files Browse the repository at this point in the history
  • Loading branch information
Axolotle committed Jan 19, 2025
1 parent 5f16d03 commit 7cf26ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app/src/views/tool/ToolPower.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import { useI18n } from 'vue-i18n'
import api from '@/api'
import { useAutoModal } from '@/composables/useAutoModal'
import { useInfos } from '@/composables/useInfos'
import { useSSE } from '@/composables/useSSE'
const { t } = useI18n()
const modalConfirm = useAutoModal()
const { tryToReconnect } = useInfos()
const { tryToReconnect } = useSSE()
async function triggerAction(action: 'reboot' | 'shutdown') {
const confirmed = await modalConfirm(t('confirm_reboot_action_' + action))
if (!confirmed) return
api.put({ uri: action + '?force' }).then(() => {
const delay = action === 'reboot' ? 4000 : 10000
tryToReconnect({ attemps: Infinity, origin: action, delay })
tryToReconnect({ origin: action, delay })
})
}
</script>
Expand Down
5 changes: 2 additions & 3 deletions app/src/views/update/SystemUpdate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { useI18n } from 'vue-i18n'
import api from '@/api'
import CardCollapse from '@/components/CardCollapse.vue'
import { useAutoModal } from '@/composables/useAutoModal'
import { useInfos } from '@/composables/useInfos'
import { useSSE } from '@/composables/useSSE'
import type { SystemUpdate } from '@/types/core/api'
import { formatAppNotifs } from '../app/appData'
const { t } = useI18n()
const { tryToReconnect } = useInfos()
const { tryToReconnect } = useSSE()
const modalConfirm = useAutoModal()
const { apps, system, importantYunohostUpgrade, pendingMigrations } = await api
Expand Down Expand Up @@ -81,7 +81,6 @@ async function performSystemUpgrade() {
api.put({ uri: 'upgrade/system' }).then(() => {
if (system.value.some(({ name }) => name.includes('yunohost'))) {
tryToReconnect({
attemps: 1,
origin: 'upgrade_system',
initialDelay: 2000,
})
Expand Down

0 comments on commit 7cf26ab

Please sign in to comment.