handletelegram,gotd: stop get difference polling after leaving channel
This commit is contained in:
@@ -161,6 +161,13 @@ func (m *Manager) Run(ctx context.Context, api API, userID int64, opt AuthOption
|
||||
return wg.Wait()
|
||||
}
|
||||
|
||||
func (m *Manager) RemoveChannel(channelID int64, reason error) {
|
||||
if m == nil {
|
||||
return
|
||||
}
|
||||
m.state.RemoveChannel(channelID, reason)
|
||||
}
|
||||
|
||||
func (m *Manager) loadState(ctx context.Context, api API, userID int64, forget bool) (State, error) {
|
||||
onNotFound:
|
||||
var state State
|
||||
|
||||
@@ -383,6 +383,19 @@ func (s *internalState) handleChannel(ctx context.Context, channelID int64, date
|
||||
return state.Push(ctx, cu)
|
||||
}
|
||||
|
||||
func (s *internalState) RemoveChannel(channelID int64, reason error) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
s.channelsLock.Lock()
|
||||
state, ok := s.channels[channelID]
|
||||
s.channelsLock.Unlock()
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
state.stop(fmt.Errorf("%w: %w", ErrRemoveChannelState, reason))
|
||||
}
|
||||
|
||||
func (s *internalState) createAndRunChannelState(ctx context.Context, channelID, accessHash int64, initialPts int) (state *channelState) {
|
||||
state = s.newChannelState(channelID, accessHash, initialPts)
|
||||
s.channelsLock.Lock()
|
||||
|
||||
Reference in New Issue
Block a user