mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-30 00:41:12 +00:00
Clean up back button in combination with modals
This commit is contained in:
parent
b4801a27a6
commit
e4902647ac
@ -49,14 +49,8 @@ If you like Coracle and want to support its development, you can donate sats via
|
|||||||
|
|
||||||
# Maintenance
|
# Maintenance
|
||||||
|
|
||||||
- [ ] Fix login flow
|
|
||||||
- [ ] Fix navigation
|
|
||||||
- Stack views?
|
|
||||||
- Put user detail in a modal?
|
|
||||||
- ReplaceState for settings modals?
|
|
||||||
- [ ] Use nip 56 for reporting
|
- [ ] Use nip 56 for reporting
|
||||||
- https://github.com/nostr-protocol/nips/pull/205#issuecomment-1419234230
|
- https://github.com/nostr-protocol/nips/pull/205#issuecomment-1419234230
|
||||||
- [ ] Mentions are sorta weird, usually mention self
|
|
||||||
- [ ] Change network tab to list relays the user is connected to
|
- [ ] Change network tab to list relays the user is connected to
|
||||||
- [ ] Sync mentions box and in-reply mentions
|
- [ ] Sync mentions box and in-reply mentions
|
||||||
- [ ] Add petnames for channels
|
- [ ] Add petnames for channels
|
||||||
@ -71,6 +65,7 @@ If you like Coracle and want to support its development, you can donate sats via
|
|||||||
- [x] Wait for profile info on login, navigate to network by default
|
- [x] Wait for profile info on login, navigate to network by default
|
||||||
- [x] Fix mention selection, inheritance, and inclusion in notes
|
- [x] Fix mention selection, inheritance, and inclusion in notes
|
||||||
- [x] Parse links without http at the beginning
|
- [x] Parse links without http at the beginning
|
||||||
|
- [x] Clean up back button in combination with modals
|
||||||
|
|
||||||
## 0.2.9
|
## 0.2.9
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
import {Router, Route, links, navigate} from "svelte-routing"
|
import {Router, Route, links, navigate} from "svelte-routing"
|
||||||
import {globalHistory} from "svelte-routing/src/history"
|
import {globalHistory} from "svelte-routing/src/history"
|
||||||
import {displayPerson, isLike} from 'src/util/nostr'
|
import {displayPerson, isLike} from 'src/util/nostr'
|
||||||
import {timedelta, now} from 'src/util/misc'
|
import {timedelta, now, sleep} from 'src/util/misc'
|
||||||
import {keys, user, pool, getRelays} from 'src/agent'
|
import {keys, user, pool, getRelays} from 'src/agent'
|
||||||
import {modal, toast, settings, logUsage, alerts, messages, loadAppData} from "src/app"
|
import {modal, toast, settings, logUsage, alerts, messages, loadAppData} from "src/app"
|
||||||
import {routes} from "src/app/ui"
|
import {routes} from "src/app/ui"
|
||||||
@ -50,8 +50,12 @@
|
|||||||
const searchIsOpen = writable(false)
|
const searchIsOpen = writable(false)
|
||||||
const toggleSearch = () => searchIsOpen.update(x => !x)
|
const toggleSearch = () => searchIsOpen.update(x => !x)
|
||||||
|
|
||||||
const closeModal = () => {
|
const closeModal = async () => {
|
||||||
modal.set(null)
|
while ($modal) {
|
||||||
|
history.back()
|
||||||
|
await sleep(1)
|
||||||
|
}
|
||||||
|
|
||||||
menuIsOpen.set(false)
|
menuIsOpen.set(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import Bugsnag from "@bugsnag/js"
|
import Bugsnag from "@bugsnag/js"
|
||||||
import {prop} from "ramda"
|
import {prop, last} from "ramda"
|
||||||
import {uuid} from "hurdak/lib/hurdak"
|
import {uuid} from "hurdak/lib/hurdak"
|
||||||
import type {Writable} from 'svelte/store'
|
import type {Writable} from 'svelte/store'
|
||||||
import {navigate} from "svelte-routing"
|
import {navigate} from "svelte-routing"
|
||||||
@ -37,24 +37,29 @@ toast.show = (type, message, timeout = 5) => {
|
|||||||
|
|
||||||
// Modals
|
// Modals
|
||||||
|
|
||||||
|
|
||||||
export const modal = {
|
export const modal = {
|
||||||
subscribe: cb => {
|
history: [],
|
||||||
const getModal = () =>
|
|
||||||
location.hash.includes('#modal=')
|
|
||||||
? JSON.parse(decodeURIComponent(escape(atob(location.hash.replace('#modal=', '')))))
|
|
||||||
: null
|
|
||||||
|
|
||||||
cb(getModal())
|
|
||||||
|
|
||||||
return globalHistory.listen(() => cb(getModal()))
|
|
||||||
},
|
|
||||||
set: data => {
|
set: data => {
|
||||||
let path = location.pathname
|
|
||||||
if (data) {
|
if (data) {
|
||||||
path += '#modal=' + btoa(unescape(encodeURIComponent(JSON.stringify(data))))
|
modal.history.push(data)
|
||||||
|
navigate(location.pathname + `#m=${modal.history.length - 1}`)
|
||||||
|
} else {
|
||||||
|
modal.history = []
|
||||||
|
navigate(location.pathname)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
subscribe: cb => {
|
||||||
|
cb(last(modal.history))
|
||||||
|
|
||||||
navigate(path)
|
return globalHistory.listen(({action}) => {
|
||||||
|
const match = location.hash.match(/\bm=(\d+)/)
|
||||||
|
const i = match ? parseInt(match[1]) : null
|
||||||
|
|
||||||
|
modal.history.splice(i === null ? -1 : i + 1)
|
||||||
|
|
||||||
|
cb(modal.history[i])
|
||||||
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
cmd.muffle(getRelays(), muffleTags)
|
cmd.muffle(getRelays(), muffleTags)
|
||||||
|
|
||||||
modal.set(null)
|
history.back()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user