Skip to content

Commit

Permalink
🎨 Custom Emoji folders no longer require manual refresh when they cha…
Browse files Browse the repository at this point in the history
…nge #11749
  • Loading branch information
88250 committed Jun 18, 2024
1 parent aa7a745 commit ed85d29
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
21 changes: 3 additions & 18 deletions kernel/model/emojis_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,40 +56,25 @@ func watchEmojis() {
go func() {
defer logging.Recover()

var (
timer *time.Timer
lastEvent fsnotify.Event
)
timer = time.NewTimer(100 * time.Millisecond)
timer := time.NewTimer(100 * time.Millisecond)
<-timer.C // timer should be expired at first

for {
select {
case event, ok := <-emojisWatcher.Events:
case _, ok := <-emojisWatcher.Events:
if !ok {
return
}

lastEvent = event
timer.Reset(time.Millisecond * 100)

if lastEvent.Op&fsnotify.Rename == fsnotify.Rename || lastEvent.Op&fsnotify.Write == fsnotify.Write {
util.PushReloadEmojiConf()
} else if lastEvent.Op&fsnotify.Remove == fsnotify.Remove {
util.PushReloadEmojiConf()
}
case err, ok := <-emojisWatcher.Errors:
if !ok {
return
}
logging.LogErrorf("watch emojis failed: %s", err)
case <-timer.C:
//logging.LogInfof("emojis changed: %s", lastEvent)
if lastEvent.Op&fsnotify.Remove == fsnotify.Remove {
util.PushReloadEmojiConf()
} else {
util.PushReloadEmojiConf()
}
util.PushReloadEmojiConf()
}
}
}()
Expand Down
10 changes: 1 addition & 9 deletions kernel/model/emojis_watcher_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,7 @@ func watchEmojis() {
}

//logging.LogInfof("emojis changed: %s", event)
if watcher.Write == event.Op {
IncSync()
}

if watcher.Remove == event.Op {
util.PushReloadEmojiConf()
} else {
util.PushReloadEmojiConf()
}
util.PushReloadEmojiConf()
case err, ok := <-emojisWatcher.Error:
if !ok {
return
Expand Down

0 comments on commit ed85d29

Please sign in to comment.